#!/bin/bash # src2pkg-bootstrap.src2pkg ## This script builds the src2pkg/src2pkg package, ## including the installwatch libraries. Once you ## have built the src2pkg package, install it using ## the 'installpkg' command. Then you can build other ## packages from source using the src2pkg/src2pkg tools. CWD=$(pwd) NAME="src2pkg" VERSION="1.1" BUILD="1" LIBNAME="installwatch" LIBVERSION="0.6.3" # use /tmp if you can't write to the current working directory TEMP_DIR=$CWD NORMAL="" # RED: Failure or error message RED="" # GREEN: Success message GREEN="" # BLUE: Summary messages BLUE="" # set the ARCH if [[ "$(uname -m)" = "ppc" ]] ; then ARCH="powerpc" elif [[ "$(uname -i)" = "i386" ]] ; then ARCH="i486" elif [[ "$(uname -m)" = "x86_64" ]] ; then ARCH="x86_64" fi PKG_DIR=$TEMP_DIR/$NAME-$VERSION-$ARCH-$BUILD SRC_DIR=$TEMP_DIR/$LIBNAME-$LIBVERSION PACKAGE=$TEMP_DIR/$NAME-$VERSION-$ARCH-$BUILD.tgz # clean up stale files and start fresh rm -rf $PKG_DIR rm -rf $SRC_DIR rm -f $PACKAGE # build the installwatch library cd $TEMP_DIR ; echo "Unpacking sources..." tar xf $CWD/$LIBNAME-$LIBVERSION.tar.bz2 echo "Compiling $LIBNAME..." cd $SRC_DIR; if [[ $ARCH = "x86_64" ]] ; then CFLAGS='-O2 -fPIC' make 1> /dev/null 2> /dev/null else make 1> /dev/null 2> /dev/null fi if [[ -e $SRC_DIR/installwatch.so ]] ; then echo "Installwatch Libraries successfully built." else echo "Installwatch Libraries build Failed!" && exit 1 fi # build the package echo "Creating Package Tree..." mkdir -p $PKG_DIR/usr/libexec/src2pkg chmod 755 $PKG_DIR/usr/libexec/src2pkg cp -a $CWD/Resources/libexec/* $PKG_DIR/usr/libexec/src2pkg cp -a $SRC_DIR/installwatch.so $PKG_DIR/usr/libexec/src2pkg chown root.root $PKG_DIR/usr/libexec/src2pkg/* chmod 755 $PKG_DIR/usr/libexec/src2pkg/installwatch* chmod 644 $PKG_DIR/usr/libexec/src2pkg/FUNCTIONS chmod 644 $PKG_DIR/usr/libexec/src2pkg/DEFINES # src2pkg mkdir -p $PKG_DIR/usr/sbin cp -a $CWD/Resources/sbin/src2pkg $PKG_DIR/usr/sbin chown root.root $PKG_DIR/usr/sbin/src2pkg chmod 755 $PKG_DIR/usr/sbin/src2pkg # trackinstall cp -a $CWD/Resources/sbin/trackinstall $PKG_DIR/usr/sbin chown root.root $PKG_DIR/usr/sbin/trackinstall chmod 755 $PKG_DIR/usr/sbin/trackinstall # disrpm mkdir -p $PKG_DIR/usr/bin cp -a $CWD/Resources/bin/disrpm $PKG_DIR/usr/bin chown root.root $PKG_DIR/usr/bin/disrpm chmod 755 $PKG_DIR/usr/bin/disrpm # tracklist can be run by non-root users so place it in /usr/bin mkdir -p $PKG_DIR/usr/bin cp -a $CWD/Resources/bin/tracklist $PKG_DIR/usr/bin chown root.root $PKG_DIR/usr/bin/tracklist chmod 755 $PKG_DIR/usr/bin/tracklist # config files mkdir -p $PKG_DIR/etc/src2pkg cp -a $CWD/Resources/etc/* $PKG_DIR/etc/src2pkg chown root.root $PKG_DIR/etc/src2pkg/* chmod 755 $PKG_DIR/etc/src2pkg chmod 644 $PKG_DIR/etc/src2pkg/* # docs mkdir -p $PKG_DIR/usr/doc/$NAME-$VERSION cp -a $CWD/Resources/doc/* $PKG_DIR/usr/doc/$NAME-$VERSION cp -a $SRC_DIR/README $PKG_DIR/usr/doc/$NAME-$VERSION/README.installwatch chown -R root.root $PKG_DIR/usr/doc/$NAME-$VERSION # manpage(s) mkdir -p $PKG_DIR/usr/man/man1 cp -a $CWD/Resources/man/* $PKG_DIR/usr/man/man1 gzip $PKG_DIR/usr/man/man1/* # slack-desc and doinst.sh mkdir -p $PKG_DIR/install cp -a $CWD/slack-desc $PKG_DIR/install cp $CWD/doinst.sh $PKG_DIR/install echo "Creating Package..." cd $PKG_DIR ; makepkg -l y -c n $PACKAGE 1> /dev/null 2> /dev/null echo "Finished Package is located in:" echo "$PACKAGE" echo "" echo "Use 'installpkg $NAME-$VERSION-$ARCH-$BUILD.tgz' to install the package." echo "Then you can use the 'src2pkg' program to build sources and/or generate" echo "src2pkg scripts for build customization."