From: Stephen Waits Date: 2006-04-16T14:14:43+09:00 Subject: Improved bundle making script.. --------------030202010200080809080600 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I've finally had a chance to spend some time cleaning up my little bundle making tool. I've found it useful (albeit not under Locomotive) and hope someone else may find it helpful too. It's been tested on Linux (Kubuntu 5.10) and FreeBSD 5.3. An earlier version worked fine on OS X; however, I've not tested it recently. The script is attached to this message. Patches welcome! --Steve --------------030202010200080809080600 Content-Type: application/x-sh; name="make-bundle.sh" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="make-bundle.sh" #!/bin/sh # TO DO # # * add bdb # * get openssl to work when static (Ruby build is screwed) # * add sqlite3 # * add mysql # * add imagemagick and rmagick # * download latest gem to avoid gem install multiple choice problem # * don't rebuild libs if they already exist? # * skip ncurses bootstrap if infocmp exists? # * better documentation througout # * automatically determine latest versions? # Instructions # # On Debian/Ubuntu/Kubuntu apt-get install build-essential # # Requires: # * a Posix like environment (i.e. not Windows) # * sh (or bash) # * sed # * tar (with -z support) # * a fetch program (fetch, wget, or curl) ############################################################################### # package URLs ############################################################################### NCURSES_URL="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.5.tar.gz" GDBM_URL="ftp://ftp.gnu.org/gnu/gdbm/gdbm-1.8.3.tar.gz" RUBY_URL="ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.4.tar.gz" RUBYGEMS_URL="http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz" ICONV_URL="http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.2.tar.gz" ZLIB_URL="http://www.zlib.net/zlib-1.2.3.tar.gz" READLINE_URL="ftp://ftp.gnu.org/gnu/readline/readline-5.1.tar.gz" OPENSSL_URL="http://www.openssl.org/source/openssl-0.9.8a.tar.gz" ############################################################################### # Find a fetch program ############################################################################### FETCH_EXE=`which fetch` WGET_EXE=`which wget` CURL_EXE=`which curl` if [ -x "$FETCH_EXE" ]; then FETCH="$FETCH_EXE -a" elif [ -x "$WGET_EXE" ]; then FETCH="$WGET_EXE" elif [ -x "$CURL_EXE" ]; then FETCH="$CURL_EXE -O" else echo "Error: No suitable fetch program found." exit 1 fi echo "Using '${FETCH}' to fetch packages" ############################################################################### # setup our build environment ############################################################################### # use all absolute paths SCRIPTDIR=`pwd` # our main script dir TMPBASE=$SCRIPTDIR/tmp-bundler # all of our transient stuff goes here PKGDIR=$TMPBASE/pkg # where we download packages BUILDDIR=$TMPBASE/build # where we unzip packages and and compile them LIBDIR=$TMPBASE/libraries # our libs LIBBOOTSTRAPDIR=$TMPBASE/libstrap # used for a temp build of ncurses BUNDIR=$SCRIPTDIR/bundle # final bundle directory for i in $BUNDIR $LIBDIR $BUILDDIR $LIBBOOTSTRAPDIR do echo "Removing ${i}" rm -rf $i done for i in $PKGDIR $BUILDDIR $LIBDIR $LIBBOOTSTRAPDIR $BUNDIR do echo "Creating ${i}" mkdir -p $i done ############################################################################### # function to fetch, extract, build, and install a package # # takes 4 parameters: # * the URL of the package # * the configure command for the package # * the make command for the package # * the install command for the package ############################################################################### do_package() { # get parameters URL=$1 CONFIGURE_CMD=$2 MAKE_CMD=$3 INSTALL_CMD=$4 # parse out file name from URL, and then directory name FILENAME=`echo ${URL} | sed -e 's/.*\///'` DIRNAME=`echo ${FILENAME} | sed -e 's/\.tgz//' -e 's/\.tar\.gz//'` # save original directory ORIG_DIR=`pwd` # fetch the package echo "Fetching ${FILENAME} from ${URL}" cd $PKGDIR if [ -f $FILENAME ]; then echo "... already exists" else $FETCH $URL fi # extract it echo "Extracting ${FILENAME}" cd $BUILDDIR LOGFILE=`pwd`/extract-$FILENAME.log tar zxvf "$PKGDIR/$FILENAME" > $LOGFILE 2>&1 if [ "$?" -ne "0" ]; then echo "Error extracting ${FILENAME}" echo "See ${LOGFILE} for details" exit 1 fi # configure, build, and install it echo "Building ${DIRNAME}" cd $DIRNAME LOGFILE=`pwd`/build-$DIRNAME.log echo "$CONFIGURE_CMD" > $LOGFILE && \ $CONFIGURE_CMD >> $LOGFILE 2>&1 && \ echo "$MAKE_CMD" >> $LOGFILE && \ $MAKE_CMD >> $LOGFILE 2>&1 && \ echo "$INSTALL_CMD" >> $LOGFILE && \ $INSTALL_CMD >> $LOGFILE 2>&1 if [ "$?" -ne "0" ]; then echo "Error building ${DIRNAME}" echo "See ${LOGFILE} for details" exit 1 fi # done cd $ORIG_DIR } ############################################################################### # zlib # depends on: nothing # required by: ruby ############################################################################### CONFIGURE="./configure --prefix=$LIBDIR" do_package "$ZLIB_URL" "$CONFIGURE" "make" "make install" ############################################################################### # libiconv # depends on: nothing # required by: ruby ############################################################################### CONFIGURE="./configure --prefix=$LIBDIR --enable-static --disable-shared --disable-rpath" do_package "$ICONV_URL" "$CONFIGURE" "make" "make install" ############################################################################### # gdbm # depends on: nothing # required by: ruby ############################################################################### CONFIGURE="./configure --prefix=$LIBDIR --enable-static --disable-shared" INSTALL="make install install-compat BINOWN=$USER BINGRP=$GROUP" do_package "$GDBM_URL" "$CONFIGURE" "make" "$INSTALL" ############################################################################### # ncurses # depends on: nothing # required by: ruby, readline ############################################################################### # build once to a bootstrap directory so we can get a database, and infocmp CONFIGURE="./configure --prefix=$LIBBOOTSTRAPDIR --with-static --without-shared --without-rpath --without-debug --without-profile --without-ada" do_package "$NCURSES_URL" "$CONFIGURE" "make" "make install" # build a second time, except embed a few termcaps (needed database & infocmp 1st) OLD_PATH=$PATH PATH="$LIBBOOTSTRAPDIR/bin:$PATH" FALLBACKS="ansi,linux,screen,screen-w,vt52,vt100,vt102,vt220,xterm,xterm-color,xterm-mono" CONFIGURE="./configure --prefix=$LIBDIR --with-static --without-shared --without-rpath --without-debug --without-profile --without-ada --without-progs --disable-database --with-fallbacks=$FALLBACKS" do_package "$NCURSES_URL" "$CONFIGURE" "make" "make install" PATH=$OLD_PATH ############################################################################### # readline # depends on: ncurses # required by: ruby ############################################################################### CONFIGURE="./configure --prefix=$LIBDIR --enable-static --disable-shared" do_package "$READLINE_URL" "$CONFIGURE" "make" "make install" ############################################################################### # openssl # depends on: nothing # required by: ruby ############################################################################### # openssl is *BROKEN* - static libssl.a conflicts with digest extension(s) # in static Ruby build, which is a major hackfuck anyway #CONFIGURE="#./config --prefix=$LIBDIR --openssldir=$LIBDIR -L$LIBDIR/lib -I$LIBDIR/include no-shared no-asm" #do_package "$OPENSSL_URL" "$CONFIGURE" "make" "make install" ############################################################################### # ruby # depends on: zlib, gdbm, iconv, ncurses, readline, openssl # required by: rubygems ############################################################################### LDFLAGS="-L${LIBDIR}/lib" CPPFLAGS="-I${LIBDIR}/include" CONFIGURE="./configure --prefix=$BUNDIR --enable-static --disable-shared --disable-rpath --with-static-linked-ext --enable-install-doc --with-curses-dir=$LIBDIR --with-dbm-dir=$LIBDIR --with-gdbm-dir=$LIBDIR --with-iconv-dir=$LIBDIR --with-openssl-dir=$LIBDIR --with-readline-dir=$LIBDIR --with-zlib-dir=$LIBDIR" do_package "$RUBY_URL" "$CONFIGURE" "make" "make install" ############################################################################### # rubygems # depends on: ruby # required by: any gems ############################################################################### PATH="${BUNDIR}/bin:$PATH" RUBY="${BUNDIR}/bin/ruby" CONFIGURE="$RUBY setup.rb" # hack - actually configures AND installs MAKE="gem update --system -y" # hack - actually upgrades INSTALL="echo . > /dev/null" # hack - do nothing do_package "$RUBYGEMS_URL" "$CONFIGURE" "$MAKE" "$INSTALL" ############################################################################### # various gems # depends on: rubygems ############################################################################### #gem install rails -y #gem install capistrano -y ############################################################################### # Build mounter scripts ############################################################################### cd $BUNDIR $RUBY <