#!/bin/bash # # ELS script to build shadow-4.0.3. # # The shadow package is a security enhancement to the standard login, # passwd and associated programs found in the util-linux package. # # For source code visit: ftp://ftp.pld-linux.org/software/shadow/ # # # This script is public domain software and may be freely copied. # # This script 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. # # # 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 exists 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 # The source code for xmalloc.c needs to be patched, otherwise the # build will fail with the error, "conflicting types for malloc". # So first make a copy of the source code and then patch it. cp -dpR $SRC_DIR/* $BUILD_DIR cd $BUILD_DIR patch -p1 <<"END-OF-PATCH" diff -ur shadow-4.0.3.orig/libmisc/xmalloc.c shadow-4.0.3/libmisc/xmalloc.c --- shadow-4.0.3.orig/libmisc/xmalloc.c 1998-12-28 14:34:56.000000000 -0600 +++ shadow-4.0.3/libmisc/xmalloc.c 2008-05-09 21:10:40.000000000 -0500 @@ -16,7 +16,7 @@ #include "defines.h" -extern char *malloc(); + char * xmalloc(size_t size) END-OF-PATCH # Configure the package for FHS compliance and i586 processor. export CC="gcc -march=i586" ./configure \ --build=i586-pc-linux-gnu \ --mandir=/usr/share/man \ --prefix=/usr \ --sysconfdir=/etc \ --without-libcrack \ --without-selinux # 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. make DESTDIR=$STAGING_DIR 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 # Remove incorrect vipw symlink and create vigr symlink. rm $STAGING_DIR/bin/vipw ln -s vipw $STAGING_DIR/usr/sbin/vigr # Move some binaries to /usr hierarchy. Anything that is not critical # to system recovery does not need to be in the root hierarchy. mv $STAGING_DIR/bin/groups $STAGING_DIR/usr/bin mv $STAGING_DIR/bin/sg $STAGING_DIR/usr/bin # Keep a copy of the license document. install -D -o root -g root -m 644 $SRC_DIR/doc/LICENSE \ $STAGING_DIR/usr/share/doc/$PKG_NAME/LICENSE # Strip binaries and libraries and compress documentation. strip $STAGING_DIR/bin/* strip --strip-debug $STAGING_DIR/lib/* strip $STAGING_DIR/usr/bin/* strip $STAGING_DIR/usr/sbin/* gzip -r $STAGING_DIR/usr/share/man gzip -r $STAGING_DIR/usr/share/doc # Create the package if ! [ "$PKG_COMMAND" = "" ]; then export $PKG_NAME $STAGING_DIR $PKG_COMMAND else cd $STAGING_DIR tar -zcf ../$PKG_NAME.i586.tar.gz * fi # end of blueprint