#!/bin/bash # src2pkg-bootstrap.src2pkg ## This script builds the src2pkg package, ## including the libsentry 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) # use /tmp if you can't write to the current working directory TEMP_DIR=$CWD NAME="src2pkg" VERSION="1.9.1" BUILD="1" ARCH='noarch' LIBSENTRY_VERSION="0.6.7.3" TAR_VERSION=1.13 BB_VERSION=1.2.2 FAKEROOT_VERSION=1.5.10 NORMAL="" # RED: Failure or error message RED="" # GREEN: Success message GREEN="" # BLUE: Summary messages BLUE="" PKG_DIR=$TEMP_DIR/$NAME-$VERSION-$ARCH-$BUILD PACKAGE=$TEMP_DIR/$NAME-$VERSION-$ARCH-$BUILD.tgz [[ -d $PKG_DIR ]] && echo "Removing existing PKG_DIR" && rm -rf $PKG_DIR [[ -e $PACKAGE ]] && echo "Removing existing package" && rm -rf $PACKAGE echo "" cd $TEMP_DIR ; # build and use our own static copy of tar for consistent results and safety #! [[ -d $TEMP_DIR/tar ]] && mkdir -p $TEMP_DIR/tar cd $TEMP_DIR ; if ! [[ $(which tar-1.13) ]] ; then echo "Creating a local static copy of the tar program." echo "" echo "Unpacking tar..." tar xjf $CWD/tar-$TAR_VERSION.tar.bz2 if [[ "$TAR_VERSION" = "1.13" ]] ; then cd tar-$TAR_VERSION echo "patching tar..." echo "This adds support for bzip2:" patch -p1 < $CWD/tar-$TAR_VERSION-bzip2.diff fi echo -n "configuring tar..." if [[ $ARCH = "x86_64" ]] ; then CFLAGS="-O2 -fPIC -static -s" ./configure --disable-nls --with-ncursesw --enable-widec &> /dev/null elif [[ $ARCH = "i486" ]] ; then CFLAGS='-O2' ./configure --disable-nls --with-ncursesw --enable-widec &> /dev/null else ./configure --disable-nls --with-ncursesw --enable-widec &> /dev/null fi if [[ $? -eq 0 ]] ; then echo $GREEN"Done"$NORMAL else echo "tar failed to configure... exiting." exit fi echo -n "compiling tar..." if [[ $ARCH = "x86_64" ]] ; then CFLAGS='-O2 -fPIC' LDFLAGS="-static -s" make &> /dev/null elif [[ $ARCH = "i486" ]] ; then CFLAGS='-O2' LDFLAGS="-static -s" make &> /dev/null else LDFLAGS="-static -s" make &> /dev/null fi if [[ $? -eq 0 ]] ; then echo $GREEN"Done\n"$NORMAL else echo "tar failed to compile... exiting." exit fi TAR=$TEMP_DIR/tar-1.13/src/tar else TAR=$(which tar-1.13) fi # build the package echo "Creating Package Tree..." mkdir -p $PKG_DIR chown root:root $PKG_DIR chmod 755 $PKG_DIR # make all the dirs at once: mkdir -p $PKG_DIR/install mkdir -p $PKG_DIR/etc/src2pkg mkdir -p $PKG_DIR/usr/bin mkdir -p $PKG_DIR/usr/libexec/src2pkg mkdir -p $PKG_DIR/usr/src/src2pkg/src2pkg mkdir -p $PKG_DIR/usr/man/man1 mkdir -p $PKG_DIR/usr/doc/$NAME-$VERSION mkdir -p $PKG_DIR/usr/libexec/src2pkg/lib mkdir -p $PKG_DIR/usr/libexec/src2pkg/bin chown -R root:root $PKG_DIR chmod -R 755 $PKG_DIR cp -a $CWD/Resources/libexec/* $PKG_DIR/usr/libexec/src2pkg chown root:root $PKG_DIR/usr/libexec/src2pkg/* chmod 644 $PKG_DIR/usr/libexec/src2pkg/* # create dummy files for libfakeroot and libsentry echo "dummy" > $PKG_DIR/usr/libexec/src2pkg/lib/libsentry.so echo "dummy" > $PKG_DIR/usr/libexec/src2pkg/lib/libfakeroot-0.so echo "dummy" > $PKG_DIR/usr/libexec/src2pkg/lib/libfakeroot.la echo "dummy" > $PKG_DIR/usr/libexec/src2pkg/lib/libfakeroot.a chown root:root $PKG_DIR/usr/libexec/src2pkg/lib/* chmod 644 $PKG_DIR/usr/libexec/src2pkg/lib/* # and a dummy for the faked program echo "dummy" > $PKG_DIR/usr/libexec/src2pkg/bin/faked chown root:root $PKG_DIR/usr/libexec/src2pkg/bin/faked chmod 644 $PKG_DIR/usr/libexec/src2pkg/bin/faked # src2pkg cp -a $CWD/Resources/bin/src2pkg $PKG_DIR/usr/bin # trackinstall cp -a $CWD/Resources/bin/trackinstall $PKG_DIR/usr/bin # disrpm cp -a $CWD/Resources/bin/disrpm $PKG_DIR/usr/bin # tracklist can be run by non-root users so place it in /usr/bin cp -a $CWD/Resources/bin/tracklist $PKG_DIR/usr/bin # install the libsentry wrapper cp -a $CWD/Resources/bin/sentry $PKG_DIR/usr/bin chown root:root $PKG_DIR/usr/bin/* chmod 755 $PKG_DIR/usr/bin/* # config files cp -a $CWD/Resources/etc/* $PKG_DIR/etc/src2pkg chown root:root $PKG_DIR/etc/src2pkg/* chmod 644 $PKG_DIR/etc/src2pkg/* # docs cp -a $CWD/Resources/doc/* $PKG_DIR/usr/doc/$NAME-$VERSION chown -R root:root $PKG_DIR/usr/doc/$NAME-$VERSION/* chmod 644 $PKG_DIR/usr/doc/$NAME-$VERSION/* # manpage(s) cp -a $CWD/Resources/man/* $PKG_DIR/usr/man/man1 chown -R root:root $PKG_DIR/usr/man/man1/* chmod 644 $PKG_DIR/usr/man/man1/* gzip $PKG_DIR/usr/man/man1/* chown -R root:root $PKG_DIR/usr/man/man1/* chmod 644 $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 # Now add the sources to the package # libsentry sources cp -a $CWD/libsentry-$LIBSENTRY_VERSION.tar.bz2 $PKG_DIR/usr/src/src2pkg/src2pkg cp -a $CWD/fakeroot-$FAKEROOT_VERSION.tar.bz2 $PKG_DIR/usr/src/src2pkg/src2pkg # tar sources and patch cp -a $CWD/tar-$TAR_VERSION.tar.bz2 $PKG_DIR/usr/src/src2pkg/src2pkg cp -a $CWD/tar-1.13-bzip2.diff $PKG_DIR/usr/src/src2pkg/src2pkg # busybox sources and config file cp -a $CWD/busybox-$BB_VERSION.tar.bz2 $PKG_DIR/usr/src/src2pkg/src2pkg cp -a $CWD/busybox-static.config $PKG_DIR/usr/src/src2pkg/src2pkg # now copy the setup script cp -a $CWD/src2pkg.setup $PKG_DIR/usr/src/src2pkg/src2pkg chown root:root $PKG_DIR/usr/src/src2pkg/src2pkg/* chmod 644 $PKG_DIR/usr/src/src2pkg/src2pkg/* # chmod 755 $PKG_DIR/usr/src/src2pkg/src2pkg/src2pkg.setup # create a repo skeleton in /usr/src/src2pkg mkdir -p $PKG_DIR/usr/src/src2pkg/sources mkdir -p $PKG_DIR/usr/src/src2pkg/packages mkdir -p $PKG_DIR/usr/src/src2pkg/scripts # now create the static dir mkdir -p $PKG_DIR/usr/libexec/src2pkg/static chown root:root $PKG_DIR/usr/libexec/src2pkg/static chmod 755 $PKG_DIR/usr/libexec/src2pkg/static # create dummies of tar-1.13 and busybox echo "dummy" >> $PKG_DIR/usr/libexec/src2pkg/static/tar-1.13 chown root:root $PKG_DIR/usr/libexec/src2pkg/static/tar-1.13 chmod 644 $PKG_DIR/usr/libexec/src2pkg/static/tar-1.13 echo "dummy" >> $PKG_DIR/usr/libexec/src2pkg/static/busybox chown root:root $PKG_DIR/usr/libexec/src2pkg/static/busybox chmod 644 $PKG_DIR/usr/libexec/src2pkg/static/busybox echo "Creating Package..." cd $PKG_DIR ; # use our new tar-1.13 so the package is created properly $TAR cvf $NAME-$VERSION-$ARCH-$BUILD.tar . gzip -9 $NAME-$VERSION-$ARCH-$BUILD.tar mv $NAME-$VERSION-$ARCH-$BUILD.tar.gz ../$NAME-$VERSION-$ARCH-$BUILD.tgz echo "Finished Package is located in:" echo "$PACKAGE" echo "" echo "Use 'installpkg $NAME-$VERSION-$ARCH-$BUILD$SIG.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." if [[ $1 = "--cleanup" ]] ; then cd $TEMP_DIR ; rm -rf $NAME-$VERSION-$ARCH-$BUILD$SIG rm -rf busybox-$BB_VERSION rm -rf libsentry-$LIBSENTRY_VERSION rm -rf tar-$TAR_VERSION fi