gnublin
authorgnublin <michael@wagnertech.de>
Wed, 21 Jun 2017 12:30:26 +0000 (14:30 +0200)
committergnublin <michael@wagnertech.de>
Wed, 21 Jun 2017 12:30:26 +0000 (14:30 +0200)
tools/cpan2deb [new file with mode: 0755]
tools/make/configure

diff --git a/tools/cpan2deb b/tools/cpan2deb
new file mode 100755 (executable)
index 0000000..8d43bf8
--- /dev/null
@@ -0,0 +1,105 @@
+#!/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 <module>"
+
+if [ $# -ne 1 ]; then
+       echo $usage
+       exit 1
+fi
+
+#cd $HOME
+if [ -d locallib ]; then
+       rm -rf locallib
+fi
+#if [ -d build ]; then
+#      rm -rf build
+#fi
+
+start_dir=$(pwd)
+
+echo "call CPAN ..."
+cpan -m $1 1>$start_dir/cpan.out 2>&1 || (echo "cpan failed"; exit 1)
+
+# find build directory
+mname=$1
+name=lib${mname/::/-}-perl
+name=${name,,*}
+builddir=$(ls -rtd ~/.cpan/build/*/ |tail -1)
+
+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
+
+arch=all
+
+# move locallib content
+mkdir -p $name/usr/
+
+for dir in $(ls ~/locallib); do
+       case $dir in
+       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 <mail@wagnertech.de>
+Description: $1 perl modul
+EOF
+
+fakeroot dpkg-deb --build $name
+cp $name.deb ${name}_$version$arch_name.deb
+echo "${name}_$version$arch_name.deb erstellt."
+
index 3dfa084..6d8a67f 100755 (executable)
@@ -88,13 +88,14 @@ then
 fi
 
 # copy package control
-control=$(find src -name $paket.control)
+control=$(find -L src -name $paket.control)
+build_number=${build#*_}
 if [ -z "$control" ]
 then
        echo "warning: control file not found"
        echo "  this file is necessary for any package production."
 else   
-       sed "s/%BUILD%/$build/" $control |sed "s/%ARCH%/$ARCH/" >$paket.control
+       sed "s/%BUILD%/$build_number/" $control |sed "s/%ARCH%/$ARCH/" >$paket.control
        echo "$paket.control written."
 
        # extract version
@@ -102,7 +103,7 @@ else
 fi
 
 # check for copy file
-copy=$(find src -name $paket.cp)
+copy=$(find -L src -name $paket.cp)
 if [ -n "$copy" ]
 then
        ln -sf $copy .