#!/bin/sh # $Id$ # Copyright (c) 2005,2006 Eric Hameleers # Distributed under the terms of the GNU General Public License, Version 2 # ------------------------------------------------------------------------------ # # Slackware SlackBuild script # =========================== # By: Eric Hameleers # For: ifplugd # URL: http://0pointer.de/lennart/projects/ifplugd/ # Needs: libdaemon # Changelog: # 0.23-1: 13/apr/2004 by Eric Hameleers # * Initial build # 0.28-1: 07/oct/2005 by Eric Hameleers # * Update. # 0.28-2: 07/nov/2006 by Eric Hameleers # * Rebuilt for Slackware 11.0. Patched interface.c to compile when # kernel-headers-2.6.x is installed. # # ------------------------------------------------------------------------------ # # Run 'sh SlackBuild --cleanup' to build a Slackware package. # The package (.tgz) plus descriptive .txt file are created in /tmp . # Install using 'installpkg'. # # ------------------------------------------------------------------------------ # --- INIT --- # Set initial variables: CWD=`pwd` if [ "$TMP" = "" ]; then TMP=/tmp fi PRGNAM=ifplugd VERSION=0.28 ARCH=i486 BUILD=2 PKG=$TMP/package-$PRGNAM if [ ! -d $TMP/tmp-$PRGNAM ]; then mkdir -p $TMP/tmp-$PRGNAM # location to build the source fi if [ ! -d $PKG ]; then mkdir -p $PKG # place for the package to be built fi # Clean up left-overs rm -r $PKG/* # --- PACKAGE BUILDING --- # Explode the package framework: cd $PKG explodepkg $CWD/_$PRGNAM.tar.gz echo "+=================+" echo "| $PRGNAM-$VERSION |" echo "+=================+" cd $TMP/tmp-$PRGNAM echo "Extracting the source tarball..." tar xzvf $CWD/$PRGNAM-$VERSION.tar.gz cd $PRGNAM-$VERSION patch -p1 < $CWD/${PRGNAM}.action.patch patch -p0 < $CWD/${PRGNAM}.interface.patch chown -R root:root . ./configure --with-initdir=/etc/rc.d \ --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var \ 2>&1 | tee $CWD/config.log make 2>&1 | tee $CWD/make.log installwatch -o $CWD/install.log make DESTDIR=$PKG install mv $PKG/etc/rc.d/ifplugd $PKG/etc/rc.d/rc.ifplugd.new chmod -x $PKG/etc/rc.d/rc.ifplugd.new # --- POST-INSTALL SCRIPT --- mkdir -p $PKG/install cat <<_EOT_ >> $PKG/install/doinst.sh config() { for infile in \$1; do NEW="\$infile" 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... done } config etc/rc.d/rc.ifplugd.new # Update rc.local so that the ifplugd daemon will be started on boot if ! grep "rc.ifplugd" etc/rc.d/rc.local 1>/dev/null 2>&1 ; then cat <<-_EOM_ >> etc/rc.d/rc.local if [ -x /etc/rc.d/rc.ifplugd ]; then # Start ifplugd echo "Starting ifplugd: /etc/rc.d/rc.ifplugd start" /etc/rc.d/rc.ifplugd start fi _EOM_ fi _EOT_ # --- DOCUMENTATION --- mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION cp -a LICENSE \ doc/{NEWS,README.SuSE,README,README.html,style.css,SUPPORTED_DRIVERS} \ $PKG/usr/doc/$PRGNAM-$VERSION chown root.root $PKG/usr/doc/$PRGNAM-$VERSION/* chmod -R a-w $PKG/usr/doc/$PRGNAM-$VERSION/* gzip -9f $PKG/usr/man/*/* # --- OWNERSHIP, RIGHTS --- chown -R root:root $PKG chmod -R o-w $PKG # --- PACKAGE DESCRIPTION --- mkdir -p $PKG/install 2>/dev/null cat $CWD/${PRGNAM}.slack-desc > $PKG/install/slack-desc # --- BUILDING --- # Build the package: cd $PKG makepkg --linkadd y --chown n $TMP/$PRGNAM-$VERSION-$ARCH-$BUILD.tgz (cd $TMP && md5sum $PRGNAM-$VERSION-$ARCH-$BUILD.tgz > $PRGNAM-$VERSION-$ARCH-$BUILD.tgz.md5) cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $TMP/$PRGNAM-$VERSION-$ARCH-$BUILD.txt cd $CWD # Clean up the extra stuff: if [ "$1" = "--cleanup" ]; then rm -rf $TMP/tmp-$PRGNAM rm -rf $PKG fi