#!/bin/bash ## src2pkg.build-noarch ## This script builds the 'noarch' src2pkg package, ## including the libsentry library and tar-1.13 sources. Once you ## have built the package is installed, it must be run once ## as 'root' with the command 'src2pkg --setup'. Then you can build other ## packages from source using the src2pkg/trackinstall tools. ## src2pkg --setup can also be run during the installation of ## the package if you choose. either way, this serves to compile ## the libsentry library and tar program which src2pkg uses. CWD=$(pwd) # use /tmp if you can't write to the current working directory TEMP_DIR=$CWD NAME="src2pkg" VERSION="1.9.5" BUILD="3" ARCH='noarch' LIBSENTRY_VERSION="0.6.7.4" TAR_VERSION=1.13 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 if not available # This is just for building the src2pkg noarch package, not for the package itself 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/static 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/* # reset these two dirs chmod 755 $PKG_DIR/usr/libexec/src2pkg/lib chmod 755 $PKG_DIR/usr/libexec/src2pkg/static # create a dummy file for libsentry -this ensures that the library is removed by removepkg echo "dummy" > $PKG_DIR/usr/libexec/src2pkg/lib/libsentry.so chown root:root $PKG_DIR/usr/libexec/src2pkg/lib/libsentry.so # set the dummy as non-executable. This serves as a test for src2pkg. When src2pkg # has been properly setup, libsentry is compiled and replaces this dummy file. chmod 644 $PKG_DIR/usr/libexec/src2pkg/lib/libsentry.so # 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 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 # 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 # now copy the setup script which is run by 'src2pkg --setup' 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 # create a dummy of tar-1.13 so it gets removed by removepkg 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 "Creating Package..." cd $PKG_DIR ; # use our new tar-1.13 so the package is created properly, if tar-1.13 is # not available on the system. Other versions may cause problems. $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 libsentry-$LIBSENTRY_VERSION rm -rf tar-$TAR_VERSION fi