#!/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.9" BUILD="3" ARCH='noarch' TAR_VERSION=1.13 SRC2PKG_HELPERS_VERSION=0.5 LIBSENTRY_VERSION=0.6.7.6 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/src2pkg-helpers/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/src2pkg-helpers/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 # create the package tree and all directories echo "Creating Package Tree..." mkdir -p $PKG_DIR chown root:root $PKG_DIR chmod 755 $PKG_DIR # make all the dirs at once so we can chmod them all at once: mkdir -p $PKG_DIR/install mkdir -p $PKG_DIR/etc/src2pkg mkdir -p $PKG_DIR/usr/bin mkdir -p $PKG_DIR/usr/man/man1 mkdir -p $PKG_DIR/usr/doc/$NAME-$VERSION mkdir -p $PKG_DIR/usr/share/icons mkdir -p $PKG_DIR/usr/share/src2pkg/sounds mkdir -p $PKG_DIR/usr/share/src2pkg/common-licenses # private lib and bin dirs mkdir -p $PKG_DIR/usr/libexec/src2pkg mkdir -p $PKG_DIR/usr/libexec/src2pkg/lib mkdir -p $PKG_DIR/usr/libexec/src2pkg/bin # usr/src mkdir -p $PKG_DIR/usr/src/src2pkg/src2pkg mkdir -p $PKG_DIR/usr/src/src2pkg/src2pkg-helpers # create a repo skeleton in /usr/src/src2pkg mkdir -p $PKG_DIR/usr/src/src2pkg/builds mkdir -p $PKG_DIR/usr/src/src2pkg/packages mkdir -p $PKG_DIR/usr/src/src2pkg/scripts mkdir -p $PKG_DIR/usr/src/src2pkg/sources # chown and chmod all the directories in the package 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 chmod 755 $PKG_DIR/usr/libexec/src2pkg/bin # src2pkg cp -a $CWD/Resources/bin/src2pkg $PKG_DIR/usr/bin # src2pkg-dnd cp -a $CWD/Resources/bin/src2pkg-dnd $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 # install the sb2sp utility cp -a $CWD/Resources/bin/sb2sp $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 cp -a $PKG_DIR/etc/src2pkg/src2pkg.conf.new $PKG_DIR/usr/doc/$NAME-$VERSION/src2pkg.conf.example chown -R root:root $PKG_DIR/usr/doc/$NAME-$VERSION/* chmod 755 $PKG_DIR/usr/doc/$NAME-$VERSION # place a copy of this script in the docs also cp ${0} $PKG_DIR/usr/doc/$NAME-$VERSION chmod 644 $PKG_DIR/usr/doc/$NAME-$VERSION/$(basename ${0}) find $PKG_DIR/usr/doc/$NAME-$VERSION -type d -exec chmod 755 {} \; find $PKG_DIR/usr/doc/$NAME-$VERSION -type f -exec chmod 644 {} \; # src2pkg icons cp -a $CWD/Resources/share/icons/* $PKG_DIR/usr/share/icons/ chown -R root:root $PKG_DIR/usr/share/icons find $PKG_DIR/usr/share/icons -type f -exec chmod 644 {} \; # src2pkg sounds cp -a $CWD/Resources/share/sounds/* $PKG_DIR/usr/share/src2pkg/sounds chown root:root $PKG_DIR/usr/share/src2pkg/sounds/* chmod 644 $PKG_DIR/usr/share/src2pkg/sounds/* # src2pkg common-licenses cp -a $CWD/Resources/share/common-licenses/* $PKG_DIR/usr/share/src2pkg/common-licenses chown root:root $PKG_DIR/usr/share/src2pkg/common-licenses/* chmod 644 $PKG_DIR/usr/share/src2pkg/common-licenses/* # src2pkg locales list cp -a $CWD/Resources/share/all-locales.txt $PKG_DIR/usr/share/src2pkg chown root:root $PKG_DIR/usr/share/src2pkg/all-locales.txt chmod 644 $PKG_DIR/usr/share/src2pkg/all-locales.txt # config.guess and config.sub cp -a $CWD/Resources/share/config.guess $PKG_DIR/usr/share/src2pkg cp -a $CWD/Resources/share/config.sub $PKG_DIR/usr/share/src2pkg chown root:root $PKG_DIR/usr/share/src2pkg/config.* chmod 644 $PKG_DIR/usr/share/src2pkg/config.* # the desktop file mkdir -p $PKG_DIR/usr/share/applications cp -a $CWD/Resources/share/src2pkg-dnd.desktop $PKG_DIR/usr/share/applications chown root:root $PKG_DIR/usr/share/applications/src2pkg-dnd.desktop chmod 644 $PKG_DIR/usr/share/applications/src2pkg-dnd.desktop # 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 src2pkg-helpers sources to the package cp -a $CWD/src2pkg-helpers/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION.tar.bz2 $PKG_DIR/usr/src/src2pkg/src2pkg-helpers cp -a $CWD/src2pkg-helpers/src2pkg-helpers.src2pkg $PKG_DIR/usr/src/src2pkg/src2pkg-helpers cp -a $CWD/src2pkg-helpers/slack-desc $PKG_DIR/usr/src/src2pkg/src2pkg-helpers cp -a $CWD/src2pkg-helpers/doinst.sh $PKG_DIR/usr/src/src2pkg/src2pkg-helpers chmod 644 $PKG_DIR/usr/src/src2pkg/src2pkg-helpers/* # now copy the setup script which is run by 'src2pkg --setup' cp -a $CWD/src2pkg-helpers/src2pkg.setup $PKG_DIR/usr/src/src2pkg/src2pkg chown root:root $PKG_DIR/usr/src/src2pkg/src2pkg/src2pkg.setup chmod 644 $PKG_DIR/usr/src/src2pkg/src2pkg/src2pkg.setup 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