#!/bin/sh ############################# ## Build script for: quagga ## Creator: http://kaneda.bohater.net/slackware ## Date: 2007.05.04 MYIN="kan" SLKCFLAGS="-O2 -march=i486 -mcpu=i686" ARCH="i486" WGET="/usr/bin/wget -c" CWD=`pwd` TMP=/tmp PKG_DIR="/usr/src/slackpackages" ######################### ## Lets set the name of the program here so we can use it later. NAME=quagga ## Set the versions for packages here, these must match the source file version. PROGRAM_VER=0.99.6 ## Set the BUILD the $MYIN comes from the global config file in /etc BUILD=1$MYIN ## Location to download the source SRC_LOC="http://www.quagga.net/download/$NAME-$PROGRAM_VER.tar.gz" ## Set initial variables these should be standard in most packages: PKG=$TMP/package-$NAME if [ ! -d "$PKG_DIR" ] ; then mkdir -p $PKG_DIR fi ## Now we go grab the source for the user. Again global config has the wget line ## We will check if it is here and if not then download if [ -f $CWD/$NAME-$PROGRAM_VER.tar.gz ]; then echo "Source present not downloading" else $WGET $SRC_LOC || true fi if [ ! -f $CWD/$NAME-$PROGRAM_VER.tar.gz ]; then echo "ERROR: File cant be downloaded" exit fi ## Ok time to make sure the area is clean and unarchive the file rm -rf $PKG mkdir -p $PKG cd $TMP rm -rf $NAME-$PROGRAM_VER tar xvzf $CWD/$NAME-$PROGRAM_VER.tar.gz # Compile cd $TMP/$NAME-$PROGRAM_VER if [ "`pwd`" == "/tmp" ] ; then echo "ERROR: something is wrong... we cant cd $TMP/$NAME-$PROGRAM_VER" exit fi chown -R root.root . export CFLAGS=$SLKCFLAGS ./configure --prefix=/usr --enable-user=nobody --enable-group=nobody --localstatedir=/var/run/quagga --sysconfdir=/etc/quagga --enable-vtysh --enable-exampledir=/usr/doc/quagga-$PROGRAM_VER/examples/ make make install DESTDIR=$PKG # Doc files mkdir -p $PKG/usr/doc/$NAME-$PROGRAM_VER cp -f AUTHORS COPYING ChangeLog INSTALL INSTALL.quagga.txt NEWS README SERVICES $PKG/usr/doc/$NAME-$PROGRAM_VER/ # Strip cd $PKG find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null # Gzip man pages gzip -9q $PKG/usr/man/*/* gzip -9q $PKG/usr/man/*/*/* # Fix bin if Slackware < 11.0 if [ "`cat /etc/slackware-version |cut -d " " -f 2 | cut -d "." -f 1`" -lt 11 ] ; then for DIRECTORY in sbin usr/sbin bin usr/bin usr/local/bin usr/X11R6/bin; do if [ -d $DIRECTORY ]; then chown -R root.bin $DIRECTORY chmod -R 755 $DIRECTORY fi done fi # Fix bad permission find $PKG -perm +0111 -exec chmod 755 {} \; find $PKG \! -perm +0111 -exec chmod 644 {} \; # Install dir mkdir -p $PKG/install if [ ! -z "`ls /var/log/packages/requiredbuilder-*`" ] ; then requiredbuilder -p -y $PKG fi mkdir -p $PKG/usr/src/slackbuilds/ # Copy SlackBuild file cp -f $CWD/$0 $PKG/usr/src/slackbuilds/ mkdir -p $PKG/var/run/$NAME chown nobody.nobody $PKG/var/run/$NAME mkdir -p $PKG/etc/quagga cp $PKG/usr/doc/quagga-$PROGRAM_VER/examples/bgpd.conf.sample $PKG/etc/quagga/bgpd.conf.new cp $PKG/usr/doc/quagga-$PROGRAM_VER/examples/ospfd.conf.sample $PKG/etc/quagga/ospfd.conf.new cp $PKG/usr/doc/quagga-$PROGRAM_VER/examples/ripd.conf.sample $PKG/etc/quagga/ripd.conf.new cp $PKG/usr/doc/quagga-$PROGRAM_VER/examples/vtysh.conf.sample $PKG/etc/quagga/vtysh.conf.new cp $PKG/usr/doc/quagga-$PROGRAM_VER/examples/zebra.conf.sample $PKG/etc/quagga/zebra.conf.new chown -R nobody.nobody $PKG/etc/quagga/ # Create slack-desc cat > $PKG/install/slack-desc << END |-----handy-ruler------------------------------------------------------| quagga: $NAME $PROGRAM_VER (Quagga Routing Software Suite) quagga: quagga: Quagga is a routing software suite, providing implementations of quagga: OSPFv2, OSPFv3, RIP v1 and v2, RIPv3 and BGPv4 for Unix platforms, quagga: particularly FreeBSD, Linux, Solaris and NetBSD. Quagga is a fork quagga: of GNU Zebra which was developed by Kunihiro Ishiguro. guagga: The Quagga tree aims to build a more involved community around quagga: Quagga than the current centralised model of GNU Zebra. quagga: quagga: My other Slackware packages : http://kaneda.bohater.net/slackware/ END # Create doinst.sh cat > $PKG/install/doinst.sh << END config() { NEW="\$1" OLD="\`dirname \$NEW\`/\`basename \$NEW .new\`" # If there's no config file by that name, mv it over: if [ ! -r \$OLD ]; then mv \$NEW \$OLD elif [ "\`cat \$OLD | md5sum\`" = "\`cat \$NEW | md5sum\`" ]; then # toss the redundant copy rm \$NEW fi # Otherwise, we leave the .new copy for the admin to consider... } config etc/quagga/bgpd.conf.new config etc/quagga/ospfd.conf.new config etc/quagga/ripd.conf.new config etc/quagga/zebra.conf.new config etc/quagga/vtysh.conf.new config etc/rc.d/rc.quagga.new config etc/rc.d/rc.watchquagga.new END mkdir -p $PKG/etc/rc.d # Create /etc/rc.d/rc.quagga.new cat > $PKG/etc/rc.d/rc.quagga.new << END #!/bin/sh start() { echo -n "Starting zebra: " && /usr/sbin/zebra -d && echo "done" echo -n "Starting bgpd: " && /usr/sbin/bgpd -d && echo "done" echo -n "Starting ripd: " && /usr/sbin/ripd -d && echo "done" echo -n "Starting ospfd: " && /usr/sbin/ospfd -d && echo "done" } stop() { killall zebra 2>/dev/null killall bgpd 2>/dev/null killall ripd 2>/dev/null killall ospfd 2>/dev/null } restart() { stop && sleep 2s && start } case "\$1" in 'start') start ;; 'stop') stop ;; 'restart') restart ;; *) echo "usage \$0 start|stop|restart" esac END # Create /etc/rc.d/rc.watchquagga.new cat > $PKG/etc/rc.d/rc.watchquagga.new << END #!/bin/sh start() { if [ -x /usr/sbin/watchquagga ]; then echo -n "Starting watchquagga: " # watch zebra and ospfd daemons by default /usr/sbin/watchquagga -dz -R '/etc/rc.d/rc.quagga restart' zebra ospfd echo "done" fi } stop() { killall watchquagga 2>/dev/null } restart() { stop && sleep 2s && start } case "\$1" in 'start') start ;; 'stop') stop ;; 'restart') restart ;; *) echo "usage \$0 start|stop|restart" esac END # Build the package: cd $PKG makepkg -l y -c n $TMP/$NAME-$PROGRAM_VER-$ARCH-$BUILD.tgz mv $TMP/$NAME-$PROGRAM_VER-$ARCH-$BUILD.tgz $PKG_DIR/ #The end echo "Your $NAME package is complete." echo "It is located in $PKG_DIR. Check The Linuxpackages.net for other packages..."