#!/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.3 LIBSENTRY_VERSION=0.6.7.5 TAR_VERSION=1.13 COREUTILS_VERSION=5.2.1 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 "" 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 cd .. # make tar cd tar-$TAR_VERSION ; echo "Creating tar" # 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 ./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 cd .. # make the coreutils echo "Creating coreutils" cd coreutils-$COREUTILS_VERSION ; patch -p1 < $TEMP_DIR/src2pkg-helpers-$SRC2PKG_HELPERS_VERSION/coreutils-mini.diff ./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 #( cd $TEMP_DIR/PKG/usr/libexec/src2pkg/bin ; ln -sf ginstall install ) 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 # install new package -upgrading if necessary cd /usr/src/src2pkg/src2pkg-helpers upgradepkg --install-new ./src2pkg-helpers-$SRC2PKG_HELPERS_VERSION-$ARCH-1.tgz /usr/bin/rm -rf $TEMP_DIR echo "" echo $GREEN"DONE! "$NORMAL"src2pkg is now ready to use."