#!/bin/bash # # Blueprint to build net-tools-1.60. # # net-tools contains the 'ifconfig' and 'route' utilities that are # needed to configure network interfaces. There other useful utilities # as well. # # Source code is from http://www.tazenda.demon.co.uk/phil/net-tools/ # # 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 # # 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 # # The configure script for this package does not take any command-line # options. Instead, it interactively creates a config.h file that # contains the configuration options. Two sed scripts can be used to # automate the process by deleting all but the relevant lines from # config.in and putting the results in config.h and then generating # config.make based on the values in config.h. This has the effect of # accepting the default answers to the interactive config questions. # Additional configuration is done by changing 1 and 0 values for # certain parameters. # cd $BUILD_DIR sed \ -e "/^\*/d" \ -e "/^#/d" \ -e "/^=/d" \ -e "s/^bool '.*' /#define /" \ -e "s/ n/ 0/" \ -e "s/ y/ 1/" \ -e "s/HAVE_AFIPX 1/HAVE_AFIPX 0/" \ -e "s/HAVE_AFATALK 1/HAVE_AFATALK 0/" \ -e "s/HAVE_AFAX25 1/HAVE_AFAX25 0/" \ -e "s/HAVE_AFNETROM 1/HAVE_AFNETROM 0/" \ -e "s/HAVE_AFX25 1/HAVE_AFX25 0/" \ -e "s/HAVE_HWARC 1/HAVE_HWARC 0/" \ -e "s/HAVE_HWSTRIP 1/HAVE_HWSTRIP 0/" \ -e "s/HAVE_HWTR 1/HAVE_HWTR 0/" \ -e "s/HAVE_HWAX25 1/HAVE_HWAX25 0/" \ -e "s/HAVE_HWNETROM 1/HAVE_HWNETROM 0/" \ -e "s/HAVE_HWX25 1/HAVE_HWX25 0/" \ -e "s/HAVE_HWFR 1/HAVE_HWFR 0/" \ -e "s/HAVE_MII 0/HAVE_MII 1/" \ config.in > config.h # # The sed script regular expressions are explained below: # "/^\*/d" delete any lines that start with an asterisk (*) # "/^#/d" delete any lines that start with a hash mark (#) # "/^=/d" delete any lines that start with an equal sign (=) # "s/^bool '.*' /#define/" # change lines starting with "bool 'some-text'" to #define # "s/ n/ 0/" change n to 0 # "s/ y/ 1/" change y to 1 # The remaining substitutions disable support for some of the less # common address families and hardware types. # # Check the return status of the sed script configuration. if [ $? -gt 0 ]; then echo "$PKG_NAME: Configuration failed!" exit 8 fi # # Now generate config.make using config.h sed \ -e "/.*1/s/#define //" \ -e "/.*0/s/#define /# /" \ -e "s/ 1/=1/" \ -e "s/ 0/=0/" \ config.h > config.make # # The sed script regular expressions are explained below: # "/.*1/s/#define //" remove #define from any lines ending with 1 # "/.*0/s/#define /# /" similar to above only prepend with # on 0 lines # "s/ 1/=1/" change 1 to =1 # "s/ 0/=0/" change 0 to =0 # # # Check the return status of the sed script configuration. if [ $? -gt 0 ]; then echo "$PKG_NAME: Configuration failed!" exit 8 fi # Build the package. export CC="gcc -mcpu=i386" 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. make BASEDIR=$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 # # Anything not essential to system start-up or restore is moved out of # /bin, /sbin and into /usr/bin, /usr/sbin. mkdir $STAGING_DIR/usr/bin mv $STAGING_DIR/bin/netstat $STAGING_DIR/usr/bin mkdir $STAGING_DIR/usr/sbin mv $STAGING_DIR/sbin/arp $STAGING_DIR/usr/sbin mv $STAGING_DIR/sbin/plipconfig $STAGING_DIR/usr/sbin mv $STAGING_DIR/sbin/rarp $STAGING_DIR/usr/sbin mv $STAGING_DIR/sbin/slattach $STAGING_DIR/usr/sbin # # end of net-tools blueprint