#!/bin/bash # # ELS script to build sysvinit-2.86. # # The sysvinit package contains init as well as shutdown, sulogin and # other utilities with init and sulogin being statically-linked. # # Static linking provides an extra degree of fault-tolerance by # ensuring that init can still function even if libraries become # corrupted or deleted. The best fault-tolerance can be achieved # when sysvinit-static is used with bash-static as a root shell. # # Source code is from ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/ # # # 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 # Remove "-static" from the source path using sed. SRC_DIR=$(echo "$SRC_DIR" | sed s/-static//) 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 # This is not one of the packages that can be configured and built # completely outside of the source tree. So in order to leave the # original source untouched, the contents of $SRC_DIR are first copied # to $BUILD_DIR. The copy in $BUILD_DIR is then modified to suit the # configuration. cp -dpR $SRC_DIR/* $BUILD_DIR # This is not really a configuration change, it is to make sure that # /dev/initctl gets created properly in the staging area. cd $BUILD_DIR/src # Configuration is done by passing variables to make in order to over- # ride the values defined in the Makefile. The CC variable is used to # configure the use of gcc and i586 compatible code. make CC="gcc -march=i586" STATIC="-static" # Check return code and bail if it looks bad. if [ $? -gt 0 ]; then echo "$PKG_NAME: Build failed!" exit 16 fi # Set up a directory structure and install into staging area. mkdir $STAGING_DIR/bin mkdir $STAGING_DIR/dev mkdir $STAGING_DIR/sbin mkdir $STAGING_DIR/usr mkdir $STAGING_DIR/usr/bin mkdir $STAGING_DIR/usr/include mkdir $STAGING_DIR/usr/share mkdir $STAGING_DIR/usr/share/man mkdir $STAGING_DIR/usr/share/man/man1 mkdir $STAGING_DIR/usr/share/man/man5 mkdir $STAGING_DIR/usr/share/man/man8 make ROOT=$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 # Create the initctl pipe that gets skipped during installs using # the ROOT variable. mknod -m 600 $STAGING_DIR/dev/initctl p # Keep a copy of the license document. install -D -o root -g root -m 644 $SRC_DIR/COPYRIGHT \ $STAGING_DIR/usr/share/doc/$PKG_NAME/LICENSE # Compress documentation to save space. 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