#!/bin/bash # src2pkg.setup # Copyright 2007-2008 Gilbert Ashley # This script builds the binaries and libraries needed by src2pkg to function properly. The src2pkg package # contains no binaries when first installed, so this script must be run to setup src2pkg for use on your system. # This method is used to ensure that the binaries and libraries work properly on your system, no matter # which architecture and OS version you are running. It also provides a check to be sure that your system # has the basic tools needed to compile software. Otherwise src2pkg would not work anyway. SRC2PKG_HELPERS_VERSION=0.5 LIBSENTRY_VERSION=0.6.7.6 TAR_VERSION=1.13 COREUTILS_VERSION=5.2.1 UNIONFS_FUSE_VERSION=0.23 # we use this arbitrary location because of possible problems if /tmp is mounted on tmpfs TEMP_DIR=/usr/src/src2pkg/builds/src2pkg-helpers if [[ -d $TEMP_DIR ]] ; then rm -rf $TEMP_DIR fi mkdir -p $TEMP_DIR # ANSI COLORS CRE="" NORMAL="" # RED: Failure or error message RED="" # GREEN: Success message GREEN="" # YELLOW: Warnings YELLOW="" # BLUE: Summary messages BLUE="" # CYAN: Current Process CYAN="" if [[ "$UPDATE" = "1" ]] ; then echo $CYAN"NOTICE - "$NORMAL"Updating src2pkg-helpers program:" echo "Your installed version of src2pkg-helpers needs to be" echo "updated. An installed version was found which doesn't" echo "match the current version. src2pkg will now compile," echo "package and install the new version of src2pkg-helpers." else echo $CYAN"NOTICE - "$NORMAL"Setting up src2pkg-helpers:" echo " src2pkg uses a few binary programs and shared" echo " libraries when creating packages. These binaries" echo " should be compiled on your system to ensure best" echo " compatibility. src2pkg uses a special routine to" echo " create a package of these programs and libraries," echo " called src2pkg-$SRC2PKG_HELPERS_VERSION, which is then installed by" echo " src2pkg. Once finished, src2pkg is ready for use." echo " If you later upgrade src2pkg to a newer version," echo " there is no need to remove the src2pkg-helpers" echo " package manually. src2pkg will notify you if it" echo " needs to be upgraded. If so, this can be easily" echo " done by running 'src2pkg --setup' again." echo "" echo " TEMP_DIR=$TEMP_DIR" echo "" fi sleep 4 . /usr/libexec/src2pkg/FUNCTIONS get_flags if [[ $ARCH = "x86_64" ]] ; then CFLAGS="-O2 -fPIC" elif [[ $ARCH = "i486" ]] || [[ $ARCH = "i586" ]] || [[ $ARCH = "i686" ]] ; then CFLAGS="-O2" fi export CFLAGS cd $TEMP_DIR ; echo "Unpacking sources..." tar xf /usr/src/src2pkg/src2pkg-helpers/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION.tar.bz2 cd src2pkg-helpers-$SRC2PKG_HELPERS_VERSION # make the libs ( cd libsentry-$LIBSENTRY_VERSION ; echo "Creating libsentry" make mkdir -p $TEMP_DIR/PKG/usr/libexec/src2pkg/lib cp libsentry.so $TEMP_DIR/PKG/usr/libexec/src2pkg/lib chmod 755 $TEMP_DIR/PKG/usr/libexec/src2pkg/lib/libsentry.so ) # make tar ( cd tar-$TAR_VERSION ; echo "Creating tar-1.13" # patch -p1 < $TEMP_DIR/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION/tar-1.13-bzip2.diff # version 0.2: patch -p1 < $TEMP_DIR/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION/01*.diff patch -p1 < $TEMP_DIR/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION/02*.diff patch -p1 < $TEMP_DIR/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION/03*.diff patch -p1 < $TEMP_DIR/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION/04*.diff patch -p1 < $TEMP_DIR/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION/05*.diff patch -p1 < $TEMP_DIR/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION/06*.diff ./configure --disable-nls --with-ncursesw --enable-widec make mkdir -p $TEMP_DIR/PKG/usr/libexec/src2pkg/bin cp src/tar $TEMP_DIR/PKG/usr/libexec/src2pkg/bin/tar-1.13 chmod 755 $TEMP_DIR/PKG/usr/libexec/src2pkg/bin/tar-1.13 ) # make the coreutils ( cd coreutils-$COREUTILS_VERSION ; echo "Creating coreutils" patch -p1 < $TEMP_DIR/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION/coreutils-mini.diff # prevent aclocal from running find . -name aclocal.m4 -exec touch {} \; # prevent Automake from running find . -name Makefile.in -exec touch {} \; # prevent Autoheader from running # find . -name 'stamp-h?.in' -exec touch {} \; # prevent Autoconf from running find . -name configure -exec touch {} \; ./configure make cd src for prog in cat chmod chown cp ginstall groups link ln mkdir mknod mv readlink rm rmdir stat touch unlink; do cp $prog $TEMP_DIR/PKG/usr/libexec/src2pkg/bin chmod 755 $TEMP_DIR/PKG/usr/libexec/src2pkg/bin/$prog done # this is already in the doinst.sh #( cd $TEMP_DIR/PKG/usr/libexec/src2pkg/bin ; ln -sf ginstall install ) ) # make unionfs-fuse if fuse is present and unionfs-fuse is not already present # No, make it anyway -it's just a few KB anyway # if [[ $(which unionfs &> /dev/null) ]] ; then # echo "Skipping creation of unionfs-fuse -you have it installed already." # else if [[ -f /usr/include/fuse.h ]] ; then if [[ -L /usr/lib/libfuse.so ]] || [[ -L /usr/lib/libfuse.so ]] ; then echo "Creating unionfs-fuse" ( cd unionfs-fuse-$UNIONFS_FUSE_VERSION make cp src/unionfs $TEMP_DIR/PKG/usr/libexec/src2pkg/bin chmod 755 $TEMP_DIR/PKG/usr/libexec/src2pkg/bin/unionfs ) fi else echo "Skipping creation of unionfs-fuse -you don't have fuse installed." fi # fi mkdir -p $TEMP_DIR/PKG/install cp /usr/src/src2pkg/src2pkg-helpers/slack-desc $TEMP_DIR/PKG/install cp /usr/src/src2pkg/src2pkg-helpers/doinst.sh $TEMP_DIR/PKG/install mkdir -p $TEMP_DIR/PKG/usr/doc/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION cp $TEMP_DIR/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION/README $TEMP_DIR/PKG/usr/doc/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION # remove any old package rm -f /usr/src/src2pkg/src2pkg-helpers/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION-$ARCH-1.tgz # make the new package cd $TEMP_DIR/PKG makepkg -l n -c n /usr/src/src2pkg/src2pkg-helpers/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION-$ARCH-1.tgz if [ $? = 0 ] ; then echo $CYAN"Notice - "$NORMAL"The finished package: src2pkg-helpers-$SRC2PKG_HELPERS_VERSION-$ARCH-1.tgz" echo " is located in: /usr/src/src2pkg/src2pkg-helpers/" # install new package -upgrading if necessary cd /usr/src/src2pkg/src2pkg-helpers upgradepkg --install-new --reinstall ./src2pkg-helpers-$SRC2PKG_HELPERS_VERSION-$ARCH-1.tgz if [ $? = 0 ] ; then /usr/bin/rm -rf $TEMP_DIR echo "" echo $GREEN"DONE! "$NORMAL"src2pkg is now ready to use." else echo $RED"Failed! "$NORMAL"Failed to install package: src2pkg-helpers-$SRC2PKG_HELPERS_VERSION-$ARCH-1.tgz" fi else echo $RED"Failed! "$NORMAL"Failed to build package: src2pkg-helpers-$SRC2PKG_HELPERS_VERSION-$ARCH-1.tgz" # to clean up, or not to clean up # /usr/bin/rm -rf $TEMP_DIR fi