X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=tools%2Fcpan2deb;h=8d43bf873b7342ef6bfc9d5f41683ee32af23965;hb=c1ce8dfbcdc21aa3a4577d54918b7698b2da25d2;hp=3fb1c47e3e057309bfe73d386b546739471275c4;hpb=afd81146024d4bc81b67509735a5e43aca714328;p=projects.git diff --git a/tools/cpan2deb b/tools/cpan2deb index 3fb1c47..8d43bf8 100755 --- a/tools/cpan2deb +++ b/tools/cpan2deb @@ -1,6 +1,28 @@ #!/bin/bash set -e +function process_lib { + pushd ~/locallib 1>/dev/null + if [ $(ls lib/p*/ |wc -w) -eq 1 ] + then + # seems to be arichtecturalsub dir + arch_dir=$(ls lib/p*/) + cd lib/p*/ + mv $arch_dir/* . + rmdir $arch_dir + cd ../.. + fi + + # check, if there is a real archtecturel depandence + shared_lib=$(find . -name "*.so") + if [ -n "$shared_lib" ] + then + arch=$(arch) + fi + popd 1>/dev/null + mv ~/locallib/lib $name/usr/ +} + usage="cpan2deb " if [ $# -ne 1 ]; then @@ -8,71 +30,76 @@ if [ $# -ne 1 ]; then exit 1 fi -cd $HOME +#cd $HOME if [ -d locallib ]; then rm -rf locallib fi -if [ -d build ]; then - rm -rf build -fi - -cpan -m $1 1>cpan.out 2>&1 || (echo "cpan failed"; exit 1) -builddir=$(ls -rt ~/.cpan/build |tail -1) -cd ~/.cpan/build/$builddir -perl Makefile.PL PREFIX="~/locallib" -make -make install 1>~/cpan.out 2>&1 -echo "Module $1 installed to ~/locallib, output written to cpan.out" -cd - -mkdir build +#if [ -d build ]; then +# rm -rf build +#fi -# build copy file -#grep "^Installing" cpan.out |sed "s/Installing //" >build/cpan.tmp +start_dir=$(pwd) -cd build +echo "call CPAN ..." +cpan -m $1 1>$start_dir/cpan.out 2>&1 || (echo "cpan failed"; exit 1) -# edit copy file -#awk '{FS="/";} \ -#/lib/ {print $0" $1/usr/share/perl5";} \ -#/man/ {print $0" $1/usr/share/man";}' cpan.tmp >cpan.cp - -# build package name -version=$(perl -M$1 -e 'print $ARGV[0]->VERSION' $1) +# find build directory mname=$1 name=lib${mname/::/-}-perl name=${name,,*} +builddir=$(ls -rtd ~/.cpan/build/*/ |tail -1) -mkdir -p $name/DEBIAN -cat << EOF >$name/DEBIAN/control -Package: $name -Version: $version -Section: base -Priority: optional -Architecture: all -Depends: -Maintainer: WagnerTech UG -Description: $1 perl modul -EOF +pushd $builddir 1>/dev/null + perl Makefile.PL INSTALL_BASE="~/locallib" + make + make install 1>>~/cpan.out 2>&1 + echo "Module $1 installed to ~/locallib, output written to $start_dir/cpan.out" +popd 1>/dev/null -# execute copy script -#mkdir -p $name/usr/share/perl5 -#mkdir -p $name/usr/share/man -#. cpan.cp $name +arch=all # move locallib content -mkdir -p $name/usr/local/ +mkdir -p $name/usr/ for dir in $(ls ~/locallib); do case $dir in - lib) ;; - share) mv ~/locallib/share $name/usr/local/ + lib) process_lib + ;; + share) mv ~/locallib/share $name/usr/ ;; man) mv ~/locallib/man $name/usr/ ;; esac done +# check version +export PERL5LIB="$start_dir/$name/usr/lib/perl5:$PERL5LIB" +version=$(perl -M$mname -e 'print $ARGV[0]->VERSION' $mname) + +arch_name="" +if [ "$arch" != "all" ] +then + arch_name="_$arch" + if [ "$arch" = "i686" ] + then + # i686-Paketarchitektur gibt es nicht + arch="i386" + fi +fi + +mkdir -p $name/DEBIAN +cat << EOF >$name/DEBIAN/control +Package: $name +Version: $version +Section: base +Priority: optional +Architecture: $arch +Depends: +Maintainer: WagnerTech UG +Description: $1 perl modul +EOF + fakeroot dpkg-deb --build $name -cp $name.deb ${name}_$version.deb -echo "${name}_$version.deb erstellt." +cp $name.deb ${name}_$version$arch_name.deb +echo "${name}_$version$arch_name.deb erstellt." +