IGNOREPATH=/etc:/home:/var:/dev:/boot:/root:/tmp:/usr/local:/bin:/sbin:/mnt:/usr/src
STRIPLIB=y
STRIPBIN=y

VERSION=2004_01_05
PROGNAME="hotplug $VERSION"
DESC="\
hotplug (scripts to handle hotplugging Cardbus and USB devices)        \n\
                                                                       \n\
This package contains scripts used to initialize and configure         \n\
Cardbus and USB hardware at boot time or when it is plugged into the   \n\
machine (aka hotplugging).  The /sbin/hotplug script is called by the  \n\
kernel to load the appropriate support modules and set up the device.  \n\
                                                                       \n\
Linux hotplug support is developed by the Linux Hotplugging Project:   \n\
  http://linux-hotplug.sourceforge.net/"

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=http://sourceforge.net/projects/linux-hotplug/
PKGNAME=hotplug-$VERSION-s390-$BUILD
TAG=REC

compile() {
   tar -yxvf $CWD/hotplug-$VERSION.tar.bz2
   cd hotplug-$VERSION/
   rm -f etc/hotplug/usb.agent.orig etc/hotplug/usb.agent.rej
   chown -R root.root .
   find . -perm 775 | xargs chmod 755
   find . -perm 664 | xargs chmod 644

   # Expand the list of modules to not load automatically:
   zcat $CWD/hotplug.blacklist.diff.gz | patch -p1
   # Fix net.agent to use rc.inet1:
   zcat $CWD/hotplug.netagent.diff.gz | patch -p1
   # Use usbfs, not usbdevfs.
   zcat $CWD/hotplug.usbfs.diff.gz | patch -p1
   # Use {usb/pci}modules to find modules.
   zcat $CWD/hotplug.lister.diff.gz | patch -p1
   # quell a pointless error message
   zcat $CWD/hotplug.inputrc.diff.gz | patch -p1
   # Log entry/exit to rc.hotplug:
   zcat $CWD/hotplug.logging.diff.gz | patch -p1
   # Don't stuff the logs full of warnings about attempts to load unneeded modules:
   zcat $CWD/hotplug.logstooverbose.diff.gz | patch -p1
}

install() {
   make install prefix=/package-hotplug mandir=/package-hotplug/usr/man
   # For whatever reason, these don't get installed by default
   cp -a etc/hotplug/dasd.* etc/hotplug/tape.* /package-hotplug/etc/hotplug

   mkdir -p /package-hotplug/usr/doc/hotplug-$VERSION
   cp -a ChangeLog README /package-hotplug/usr/doc/hotplug-$VERSION

   mkdir -p /package-hotplug/etc/rc.d
   mv /package-hotplug/etc/init.d/hotplug /package-hotplug/etc/rc.d/rc.hotplug
   rmdir /package-hotplug/etc/init.d

   mv /package-hotplug/etc/hotplug/blacklist /package-hotplug/etc/hotplug/blacklist.new
   mv /package-hotplug/etc/hotplug/usb.usermap /package-hotplug/etc/hotplug/usb.usermap.new

   mkdir -p /package-hotplug/usr/lib/hotplug/firmware

   mkdir -p /package-hotplug/var/log/setup
   cp -a $CWD/setup.hotplug /package-hotplug/var/log/setup/setup.hotplug 

   ( cd /package-hotplug/usr/man/man8
     rm -f *.gz
     gzip -9 *.8
   )

   rm -rf /package-hotplug/etc/rc.d/init.d \
          /package-hotplug/var/log/hotplug \
          /package-hotplug/var/run
}

attributes() {
   chown -R root.bin $PKG/package-hotplug/sbin
   chmod 755 $PKG/package-hotplug/var/log/setup/setup.hotplug
   chmod 644 $PKG/package-hotplug/etc/hotplug/hotplug.functions
}

special() {
   cd $PKG
   mv package-hotplug/* ./
   rmdir package-hotplug

   cd $CTL
   cat $CWD/slack-desc > slack-desc

   zcat $CWD/doinst.sh.gz >> doinst.sh
   sed -e 's%package-hotplug/%%g' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new
}

