#!/bin/bash # src2pkg.setup # Copyright 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_SRC_DIR=$(pwd) # build in /tmp for sanity (if not peace of mind...) TEMP_DIR=/tmp/src2pkg.setup LIBSENTRY_VERSION="0.6.7.3" TAR_VERSION=1.13 BB_VERSION=1.2.2 FAKEROOT_VERSION=1.5.10 # 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="" echo $CYAN"NOTICE - "$NORMAL"Setting up src2pkg for the first time." echo " When first installed the src2pkg package contains" echo " no binaries or libraries which it needs to function." echo " We build them in-place to insure compatibility with" echo " your system, no matter which architecture or OS you" echo " are using. This also provides a check to be sure that" echo " you have the basic programs installed for compiling." echo "" if ! [[ -d $TEMP_DIR ]] ; then mkdir -p $TEMP_DIR else echo -n $BLUE"Removing old sources - "$NORMAL ( cd $TEMP_DIR && rm -rf libsentry-$LIBSENTRY_VERSION ) ( cd $TEMP_DIR && rm -rf tar-$TAR_VERSION ) ( cd $TEMP_DIR && rm -rf busybox-$BB_VERSION ) echo $GREEN"Done!"$NORMAL fi echo " src2pkg uses statically-linked binaries for some operations." echo " Most are supplied by the busybox program, but we also install a" echo " separate static copy of the tar program which is used throughout." echo " We also compile libsentry -the essential library used by src2pkg," echo " and the the fakeroot library so normal users can build packages." echo "" cd $TEMP_DIR ; echo -n $BLUE"Unpacking busybox - "$NORMAL tar xjf $SRC2PKG_SRC_DIR/busybox-$BB_VERSION.tar.bz2 rm -f busybox-$BB_VERSION/.config cp -a $SRC2PKG_SRC_DIR/busybox-static.config busybox-$BB_VERSION/.config chown -R root:root busybox-$BB_VERSION echo $GREEN"Done!"$NORMAL cd busybox-$BB_VERSION ; echo -n $BLUE"Configuring busybox - "$NORMAL make oldconfig 1> /dev/null echo $GREEN"Done!"$NORMAL echo -n $BLUE"Compiling busybox - "$NORMAL if [[ $ARCH = "x86_64" ]] ; then CFLAGS='-O2 -fPIC' make &> /dev/null elif [[ $ARCH = "i486" ]] ; then CFLAGS='-O2' make &> /dev/null else make &> /dev/null fi if [[ $? -eq 0 ]] ; then echo $GREEN"Done!"$NORMAL else echo "" echo $RED"FAILED! "$NORMAL"Busybox failed to compile... exiting." exit 1 fi echo -n $BLUE"Creating busybox links - "$NORMAL make install &> /dev/null echo $GREEN"Done!"$NORMAL # 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 ; echo -n $BLUE"Unpacking tar - "$NORMAL tar xjf $SRC2PKG_SRC_DIR/tar-$TAR_VERSION.tar.bz2 chown -R root:root tar-$TAR_VERSION echo $GREEN"Done!"$NORMAL cd tar-$TAR_VERSION ; patch -p1 < $SRC2PKG_SRC_DIR/tar-$TAR_VERSION-bzip2.diff &> /dev/null echo -n $BLUE"Configuring tar - "$NORMAL 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 "" echo $RED"FAILED! "$NORMAL"Tar failed to configure... exiting." exit 1 fi echo -n $BLUE"Compiling tar - "$NORMAL 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!"$NORMAL else echo "" echo $RED"FAILED! "$NORMAL"Tar failed to compile... exiting." exit 1 fi # build the libsentry library cd $TEMP_DIR ; echo -n $BLUE"Unpacking libsentry sources - "$NORMAL tar xjf $SRC2PKG_SRC_DIR/libsentry-$LIBSENTRY_VERSION.tar.bz2 echo $GREEN"Done!"$NORMAL chown -R root:root libsentry-$LIBSENTRY_VERSION echo -n $BLUE"Compiling libsentry - "$NORMAL cd libsentry-$LIBSENTRY_VERSION ; if [[ $ARCH = "x86_64" ]] ; then CFLAGS='-O2 -fPIC' make 1> /dev/null 2> /dev/null elif [[ $ARCH = "i486" ]] ; then CFLAGS='-O2' make 1> /dev/null 2> /dev/null else make 1> /dev/null 2> /dev/null fi if [[ -e $TEMP_DIR/libsentry-$LIBSENTRY_VERSION/libsentry.so ]] ; then echo $GREEN"Done!" else echo "" echo $RED"FAILED! "$NORMAL"Building libsentry failed... exiting." exit 1 fi # libfakeroot cd $TEMP_DIR ; echo -n $BLUE"Unpacking fakeroot sources - "$NORMAL tar xjf $SRC2PKG_SRC_DIR/fakeroot-$FAKEROOT_VERSION.tar.bz2 echo $GREEN"Done!"$NORMAL chown -R root:root fakeroot-$FAKEROOT_VERSION echo -n $BLUE"Compiling fakeroot - "$NORMAL cd fakeroot-$FAKEROOT_VERSION ; mkdir install_local if [[ $ARCH = "x86_64" ]] ; then CFLAGS='-O2 -fPIC' make 1> /dev/null 2> /dev/null elif [[ $ARCH = "i486" ]] ; then CFLAGS='-O2' make 1> /dev/null 2> /dev/null fi export CFLAGS ./configure --prefix=/usr/libexec/src2pkg &> /dev/null make &> /dev/null if [[ -e $TEMP_DIR/fakeroot-$FAKEROOT_VERSION/libfakeroot.o ]] ; then echo $GREEN"Done!" echo $BLUE"Installing fakeroot - "$NORMAL rm -f /usr/libexec/src2pkg/lib/* rm -f /usr/libexec/src2pkg/bin/* make install &> /dev/null rm -f /usr/libexec/src2pkg/bin/fakeroot rm -rf /usr/libexec/src2pkg/share # make sure these didn't get changed chown root:root /usr/libexec/src2pkg chmod 755 /usr/libexec/src2pkg # change the perms for all the installed libs chown -R root:root /usr/libexec/src2pkg/bin chmod -R 755 /usr/libexec/src2pkg/bin # change the perms for all the installed libs chown -R root:root /usr/libexec/src2pkg/lib chmod -R 755 /usr/libexec/src2pkg/lib chmod 644 /usr/libexec/src2pkg/lib/libfakeroot.a else echo "" echo $RED"FAILED! "$NORMAL"Building fakeroot failed... exiting." exit 1 fi # install the stuff echo -n $BLUE"Installing libs and programs - "$NORMAL # remove any stale copies rm -f /usr/libexec/src2pkg/lib/libsentry.so cp -a $TEMP_DIR/libsentry-$LIBSENTRY_VERSION/libsentry.so /usr/libexec/src2pkg/lib chown root:root /usr/libexec/src2pkg/lib/libsentry.so chmod 755 /usr/libexec/src2pkg/lib/libsentry.so # Install static tar # remove stale copies rm -f /usr/libexec/src2pkg/static/tar-1.13 cp -a $TEMP_DIR/tar-$TAR_VERSION/src/tar /usr/libexec/src2pkg/static/tar-1.13 chown root:root /usr/libexec/src2pkg/static/tar-1.13 chmod 755 /usr/libexec/src2pkg/static/tar-1.13 # busybox cp -a $TEMP_DIR/busybox-$BB_VERSION/_install/bin/busybox /usr/libexec/src2pkg/static # fix perms chown root:root $PKG_DIR/usr/libexec/src2pkg/static/busybox chmod 755 $PKG_DIR/usr/libexec/src2pkg/static/busybox echo $GREEN"DONE! "$NORMAL"src2pkg is now ready to use." cd $TEMP_DIR ; rm -rf busybox-$BB_VERSION rm -rf libsentry-$LIBSENTRY_VERSION rm -rf tar-$TAR_VERSION ( cd /tmp && rm -rf $TEMP_DIR )