#!/bin/bash # # ELS script to build inetdxtra-20081113. # # inetdxtra contains a number of lightweight server daemons that # can be run fron inetd. There is a tiny dhcp, dns, jabber server # and more. # # Source code is from: http://sourceforge.net/projects/inetdxtra # # # 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 "-20081113" from the source path using sed. SRC_DIR=$(echo "$SRC_DIR" | sed s/-20081113//) 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 # Configuration is done by overriding values in the Makefile. cd $BUILD_DIR make CC="gcc -march=i586" PREFIX=/opt/$PKG_NAME/sbin # 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 the staging area. install -m755 -d $STAGING_DIR/opt/$PKG_NAME/sbin make PREFIX=$STAGING_DIR/opt/$PKG_NAME/sbin install install -m755 -d $STAGING_DIR/opt/$PKG_NAME/man/man8 install -m755 -d $STAGING_DIR/opt/$PKG_NAME/doc # Install docs and sample configs manually as Makefile doesn't do it. install -m644 $BUILD_DIR/inetd.conf.sample $STAGING_DIR/opt/$PKG_NAME/doc install -m644 $BUILD_DIR/in.ctcs/README $STAGING_DIR/opt/$PKG_NAME/doc/README.in.ctcs install -m644 $BUILD_DIR/in.dhcp/README $STAGING_DIR/opt/$PKG_NAME/doc/README.in.dhcp install -m644 $BUILD_DIR/in.dhcp/in.dhcp.conf.sample $STAGING_DIR/opt/$PKG_NAME/doc install -m644 $BUILD_DIR/in.dns/README $STAGING_DIR/opt/$PKG_NAME/doc/README.in.dns install -m644 $BUILD_DIR/in.jabberd/README $STAGING_DIR/opt/$PKG_NAME/doc/README.in.jabberd install -m644 $BUILD_DIR/in.mvp/README $STAGING_DIR/opt/$PKG_NAME/doc/README.in.mvp install -m644 $BUILD_DIR/in.smtp/README $STAGING_DIR/opt/$PKG_NAME/doc/README.in.smtp install -m644 $BUILD_DIR/in.www/README $STAGING_DIR/opt/$PKG_NAME/doc/README.in.www # Man pages take a little more work since they're in the wrong section. # Basically, it goes like this: # Dump the uncompressed contents of the original manpage to sed which then # edits only the first line of the file, changing 1 to 8 and then passes # the altered manpage to gzip which recompresses it and places it in the # correct directory. zcat $BUILD_DIR/in.jabberd/man/in.jabberd.1.gz | sed 1s/1/8/ | gzip > $STAGING_DIR/opt/$PKG_NAME/man/man8/in.jabberd.8.gz zcat $BUILD_DIR/in.www/man/in.www.1.gz | sed 1s/1/8/ | gzip > $STAGING_DIR/opt/$PKG_NAME/man/man8/in.www.8.gz # Keep a copy of the license document. install -D -o root -g root -m 644 $SRC_DIR/COPYING \ $STAGING_DIR/opt/$PKG_NAME/doc/LICENSE # Strip binaries and compress documentation to save space. strip $STAGING_DIR/opt/$PKG_NAME/sbin/* gzip -r $STAGING_DIR/opt/$PKG_NAME/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