#!/bin/bash # # Blueprint to build netkit-telnet-0.17. # # netkit-telnet contains a command-line telnet client and a telnet # server daemon. Telnet transmits passwords in clear text which can # comprimise security. # # Source is from ftp://ftp.uk.linux.org/pub/linux/Networking/netkit/ # # # 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 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 # # A number of files must be fixed before they will compile properly. # These files lack either #include or #include # The original files are renamed and sed scripts are used to insert # the appropriate #include statments into new files. The sed scripts # are sensitive to the line breaks, so do not alter them. cd $BUILD_DIR/telnet mv main.cc main.cc.orig sed -e '/#include /a\ #include ' main.cc.orig >main.cc mv network.cc network.cc.orig sed -e '/#include /a\ #include ' network.cc.orig >network.cc mv terminal.cc terminal.cc.orig sed -e '/#include /a\ #include \ #include ' terminal.cc.orig >terminal.cc mv utilities.cc utilities.cc.orig sed -e '/#include /a\ #include \ #include ' utilities.cc.orig >utilities.cc mv netlink.cc netlink.cc.orig sed -e '/#include /a\ #include ' netlink.cc.orig >netlink.cc # Configure the package for FHS compliance and i386 processor. cd $BUILD_DIR export CC="gcc -mcpu=i386" export CXX="g++ -mcpu=i386" $SRC_DIR/configure \ --installroot=$STAGING_DIR \ --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. install -m 755 -o root -g root -d $STAGING_DIR/usr/bin install -m 755 -o root -g root -d $STAGING_DIR/usr/sbin install -m 755 -o root -g root -d $STAGING_DIR/usr/man/man1 install -m 755 -o root -g root -d $STAGING_DIR/usr/man/man5 install -m 755 -o root -g root -d $STAGING_DIR/usr/man/man8 make 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. # Make a symlink telnetd that points to in.telnetd to be consistent # with the telnetd -> in.telnetd manpage. ln -s in.telnetd $STAGING_DIR/usr/sbin/telnetd # # Since the configure script does not recognize the "--mandir=" option # the man directory needs to be moved manually. mkdir $STAGING_DIR/usr/share mv $STAGING_DIR/usr/man $STAGING_DIR/usr/share/man # # Remove the telnetd.8 symlink to in.telnetd.8 and replace it with a # file that uses the groff include directive instead. This makes it # easier to use compressed manpages later. rm $STAGING_DIR/usr/share/man/man8/telnetd.8 echo ".so in.telnetd.8" >$STAGING_DIR/usr/share/man/man8/telnetd.8 # # Space saving tweaks gzip $STAGING_DIR/usr/share/man/man1/*.1 gzip $STAGING_DIR/usr/share/man/man5/*.5 gzip $STAGING_DIR/usr/share/man/man8/*.8 # # end of netkit-telnet blueprint