#!/bin/bash # # Blueprint to build gzip-1.2.4a. # # gzip is used for compression and decompression of files. # # Source code can be downloaded from http://www.gzip.org. # # This architect blueprint is copyright (c)2003-2004 David Horton # dhorton@nospam.speakeasy.net # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to: # # Free Software Foundation, Inc. # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # # # Define the package name, source directory, build directory and # staging directory paths. Prefixes to directories may be overridden # by setting shell variables SRC, BUILD and STAGING. For example, # doing "export SRC=/root/foo" before calling this script will override # the default /usr/src and set SRC_DIR to /root/foo/$PKG_NAME instead. # PKG_NAME=$(basename $0) SRC_DIR=${SRC:-/usr/src}/$PKG_NAME BUILD_DIR=${BUILD:-/var/tmp/build}/$PKG_NAME STAGING_DIR=${STAGING:-/var/tmp/staging}/$PKG_NAME # # Check that the source directory really exits and bail out if not. if ! [ -d $SRC_DIR ]; then echo "$PKG_NAME: Cannot find source code directory $SRC_DIR." exit 1 fi # # Do not overwrite existing build directory. if [ -d $BUILD_DIR ]; then echo "$PKG_NAME: Build directory $BUILD_DIR already exists." exit 2 else mkdir -p $BUILD_DIR fi # # Do not overwrite existing staging directory. if [ -d $STAGING_DIR ]; then echo "$PKG_NAME: Staging directory $STAGING_DIR already exists." exit 4 else mkdir -p $STAGING_DIR fi # # Configure the package for FHS compliance and i386 processor. export CC="gcc -mcpu=i386" cd $BUILD_DIR $SRC_DIR/configure \ --host=i386-pc-linux-gnu \ --prefix=/usr # # Check return status and bail out if it's non-zero. if [ $? -gt 0 ]; then echo "$PKG_NAME: Configuration failed!" exit 8 fi # Build the package. make # # Check return code and bail if it looks bad. if [ $? -gt 0 ]; then echo "$PKG_NAME: Build failed!" exit 16 fi # # Install into staging area overriding make variables as needed. mkdir $STAGING_DIR/usr make \ prefix=$STAGING_DIR/usr \ install # # Check return code and bail if it looks bad. if [ $? -gt 0 ]; then echo "$PKG_NAME: Installation to staging area failed!" exit 32 fi # # Do some post-install tweaking # # Move gzip into the /bin directory so that it can be used in recovery # situations when the /usr hierarchy may not be mounted. mkdir $STAGING_DIR/bin mv $STAGING_DIR/usr/bin/gzip $STAGING_DIR/bin # # gunzip and zcat are just links to gzip and not really separate files. # Since gzip was moved, gunzip and zcat will need to move too. This is # done by deleting gunzip and zcat and then recreating them as symbolic # links to gzip. Using symbolic links, rather than hard links, makes # it a little more obvious that gunzip and zcat are just other ways of # calling gzip. rm $STAGING_DIR/usr/bin/gunzip $STAGING_DIR/usr/bin/zcat ln -s gzip $STAGING_DIR/bin/gunzip ln -s gzip $STAGING_DIR/bin/zcat # # There is one other file in /usr/bin that is also hard linked. rm $STAGING_DIR/usr/bin/zcmp ln -s zdiff $STAGING_DIR/usr/bin/zcmp # # Fix the scripts in /usr/bin by removing bogus PATH variable caused by # installing into the $STAGING_DIR directory. for FILE in zdiff zforce zgrep zmore znew; do mv $STAGING_DIR/usr/bin/$FILE $STAGING_DIR/usr/bin/$FILE.old sed -e '/PATH=/d' $STAGING_DIR/usr/bin/$FILE.old > $STAGING_DIR/usr/bin/$FILE chmod 755 $STAGING_DIR/usr/bin/$FILE rm $STAGING_DIR/usr/bin/$FILE.old done # # Move info and man directories since gzip's configure script does not # recognize "--infodir=" or "--mandir=" options. mkdir $STAGING_DIR/usr/share mv $STAGING_DIR/usr/man $STAGING_DIR/usr/share/man mv $STAGING_DIR/usr/info $STAGING_DIR/usr/share/info # # There are also hard linked manpages that correspond to the hard # linked binaries above. Rather than removing them and then making a # symbolic link, another trick can be used. Creating a manpage with # a line like ".so man1/othermanpage.1" will tell the manpage viewer # to open up another manpage. This trick was learned from the procps # package's pkill.1 manpage. rm $STAGING_DIR/usr/share/man/man1/gunzip.1 rm $STAGING_DIR/usr/share/man/man1/zcat.1 echo ".so man1/gzip.1" >$STAGING_DIR/usr/share/man/man1/gunzip.1 echo ".so man1/gzip.1" >$STAGING_DIR/usr/share/man/man1/zcat.1 rm $STAGING_DIR/usr/share/man/man1/zcmp.1 echo ".so man1/zdiff.1" >$STAGING_DIR/usr/share/man/man1/zcmp.1 # # Remove the empty /usr/lib directory rmdir $STAGING_DIR/usr/lib # # end of gzip blueprint