#!/bin/bash #(C)DatuX 2008 all rights reserved # Gets a .deb debian package from a packagename out of the svn tree. cd `dirname $0` CWD=`pwd` PKG=$1 TARGET=$2 if ! [ -e "$TARGET" ]; then echo "Usage: "; echo " $0 packagename /path/to/target/dir" echo echo "This will convert the syn3 svn-package to a debian package and put it in the target dir." echo "Also outputs a .deb.syn3 file which is used by $0 to allow intelligent caching." exit 1 fi mkdir -p $TARGET 2>/dev/null if TAR=`./findfile "$PKG.pkg"`; then BASEPATH=`echo $TAR| sed 's/.pkg$//'` || exit 1 FULLNAME=`./pkgname $TAR | sed 's/.tgz//'`.deb || exit 1 BUILDPATH=`./findbuild $PKG` || exit 1 #calc MD5 sum of files that are used to generate the .deb. MD5="`cat $BUILDPATH.md5 $BASEPATH.arch $BASEPATH.version $BASEPATH.{preinst,postinst,prerm,postrm} 2>/dev/null| md5sum`" || exit 1 else TAR=`./findpkg $PKG` || exit 1 FULLNAME=`echo $TAR | sed 's@.*/@@' | sed 's/.tgz//' `.deb || exit 1 BUILDPATH= MD5=`cat $TAR| md5sum ` || exit 1 fi echo "Tar= $TAR"; echo "Fullname= $FULLNAME"; echo "Buildpath= $BUILDPATH"; echo "MD5= $MD5"; #do we need to rebuild the .deb file? #check if the md5 we build the .deb against still matches: if ! grep -x "$MD5" $TARGET/$FULLNAME.syn3 &>/dev/null; then echo -n " (creating) " >&2 #tempdir and cleanup TMP=`mktemp -d` || exit 1 trap "rm -r $TMP" 0 #echo "Installing in $TMP:" TGZ=`./findpkg $PKG` || exit 1 ROOT=$TMP installpkg $TGZ &>/dev/null || exit 1 #HACK:we bepalen de runtime dependencys nu nog aan de hand van de build time deps. #dit moet nog anders. #BUILDSCRIPT=`./findbuild $PKG`.SlackBuild || return 0 #DEPS="`cat "$BUILDSCRIPT"|egrep '^#NEED:|^#DEP:'|cut -f2 -d':'`" || exit 1 DEPS= #echo "Adding control file.." mkdir $TMP/DEBIAN CONTROL=$TMP/DEBIAN/control echo "Package: $PKG" > $CONTROL #hackerdehack VER=`cat $BASEPATH.version` if ! [ "$VER" ]; then VER=0.0 fi echo "Version: $VER" >> $CONTROL echo "Maintainer: root@datux.nl" >> $CONTROL echo "Description: Auto generated package by Syn-3 getdeb." >> $CONTROL if [ "$DEPS" ]; then echo "Depends: `echo $DEPS| sed 's/ /, /g'`" >> $CONTROL fi #copy install scripts cp $BASEPATH.{preinst,postinst,prerm,postrm} $TMP/DEBIAN/ 2>/dev/null #translate architecture to a debian-compatible one. #this is either: all or i386 DEBARCH=`cat $BASEPATH.arch | sed 's/noarch/all/' | sed 's/i.86/i386/'`; if ! [ "$DEBARCH" ]; then DEBARCH=i386 fi echo "Architecture: $DEBARCH" >> $CONTROL dpkg-deb --nocheck -b $TMP $TARGET/$PKG.deb >/dev/null || exit 1 #store md5 for the situation we've build against echo "$MD5" > $TARGET/$FULLNAME.syn3 fi #echo the absolute path to the created or cached deb package echo "$TARGET/$FULLNAME" exit 0