#!/bin/bash # packager : Fred. Galusik (fred~AT~zenwalk.fr) # source location : # last revised : softname='' softversion='' packageversion='' arch='i486' cpu='i686' prefix=/usr # log ;) ( # parameters needed for the build process buildir=$(pwd) srcpkg="$buildir/$softname-$softversion.tar.gz" src="$buildir/$softname-$softversion" package="$softname-$softversion-$arch-$packageversion" dest="$buildir/$package" # prepare the build result directory dest="$buildir/$package" rm -rf $dest mkdir -p $dest mkdir -p $dest/install mkdir -p $dest/usr/doc/$softname-$softversion mkdir -p $dest/usr/src/$softname-$softversion # Slack-desc cat < $dest/install/slack-desc |-----handy-ruler------------------------------------------------------| $softname: $softname: $softname: $softname: $softname: $softname: $softname: $softname: $softname: $softname: $softname: EOF # extract the source code cd $buildir tar xvf $srcpkg cd $src # build export CFLAGS="-O2 -march=$arch -mtune=$cpu" export CXXFLAGS="-O2 -march=$arch -mtune=$cpu" ./configure \ --prefix=$prefix \ --enable-static=no \ --program-prefix="" \ --program-suffix="" \ make make install DESTDIR=$dest # add 'default' files cp -a \ AUTHORS COPYING INSTALL README ChangeLog \ $dest/usr/doc/$softname-$softversion # Compress Man Pages ( cd $dest/$prefix/man find . -name "*.?" | xargs gzip -9 ) # Strip ( cd $dest find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null ) # .desktop file cat << "EOF" > $dest/usr/share/applications/$softname.desktop [Desktop Entry] Encoding=UTF-8 Name= Name[fr]= Comment= Comment[fr]= Exec= Icon= Terminal=false Type=Application Categories=Application;System; StartupNotify=true EOF # Make the package freedesktop compliant cp $buildir/$softname-$softversion/pixmaps/$softname.png $dest/usr/share/icons/hicolor/48x48/apps/$softname.png # ZenBuild cp $buildir/build-$softname.sh $dest/$prefix/src/$softname-$softversion # set target permissions chown -R root:root $dest cd $dest find . -perm 664 -exec chmod 644 {} \; find . -perm 600 -exec chmod 644 {} \; find . -perm 444 -exec chmod 644 {} \; find . -perm 400 -exec chmod 644 {} \; find . -perm 440 -exec chmod 644 {} \; find . -perm 777 -exec chmod 755 {} \; find . -perm 775 -exec chmod 755 {} \; find . -perm 511 -exec chmod 755 {} \; find . -perm 711 -exec chmod 755 {} \; find . -perm 555 -exec chmod 755 {} \; # real packaging work cd $dest makepkg -l y -c n $dest.tgz # md5sum signature cd $buildir md5sum $package.tgz > $package.md5 # log ;) ) 2>&1 | tee "$softname-$softversion-build.log"