#!/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_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 # 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 " only the script components of src2pkg. Since src2pkg" echo " also uses shared libraries, they must be compiled" echo " before you can use src2pkg. Compiling them on your" echo " system insures that these libs are compatible with" echo " your kernel and glibc version and OS version." echo " srcpkg also creates its' own copy of the tar program." 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-$LIBSENTRY_VERSION ) echo $GREEN"Done!"$NORMAL fi cd $TEMP_DIR ; # build and use our own static copy of tar for consistent results and safety 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 # 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 echo $GREEN"DONE! "$NORMAL"src2pkg is now ready to use." cd $TEMP_DIR ; rm -rf libsentry-$LIBSENTRY_VERSION rm -rf tar-$TAR_VERSION ( cd /tmp && rm -rf $TEMP_DIR )