#!/bin/bash

# devs.SlackBuild
# by Stuart Winter <stuart@armedslack.org> for the Slackware porting Project.
# Based on the original Slackware build script.
# 31-May-2004

# Paths to skeleton port's source & real Slackware source tree:
export CWD=$SLACKSOURCE/$PKGSERIES/$PACKAGE
export PORTCWD=$PWD

# Temporary build locations:
export TMPBUILD=$TMP/build-$PACKAGE
export PKG=$TMP/package-$PACKAGE
mkpkgdirs # Delete and re-create temporary directories

# Start fakeroot server:
start_fakeroot

# Explode the package framework:
( cd $PKG
  explodepkg $CWD/_devs.tar.gz )

# The Iyonix uses a USB mouse (/dev/input);
# The RiscStation & A7000+ is ps2 (/dev/psaux)
# The Omega uses .. who knows; does anyone *have* one? ;-)
# The StrongARM RiscPC & SUN SPARC use /dev/sunmouse 
mknod $PKG/dev/sunmouse c 10 6
chgrp sys $PKG/dev/sunmouse
# And for clarity:
# nah -- I don't like this after all. Not now it's /dev/input/mice
# for Linux 2.6; this is just crufty.
#if [ "${PORTARCH}" = "arm" ]; then
#   ( cd $PKG/dev && ln -fs sunmouse riscpcmouse )
#fi

# Extract source:
tar zxvvf $CWD/makedev_2.3.1.orig.tar.gz
cd MAKEDEV-*
slackhousekeeping

# Apply patches (please see devs.SlackBuild.orig for the purpose of the patches)
zcat $CWD/makedev_2.3.1-46.2.diff.gz | patch -p1 -E
zcat $CWD/makedev_2.3.1.hd.diff.gz | patch -p1 -E
zcat $CWD/makedev.hd.diff.gz | patch -p1 -E

# Install the package's guts:
cat MAKEDEV > $PKG/dev/MAKEDEV
cat README > $PKG/dev/README.MAKEDEV
install -m644 MAKEDEV.man $PKG/usr/man/man8/MAKEDEV.8

# Apply some of the generic Slackware packaging policies:
cd $PKG
slackgzpages -i # compress man & info pages and delete usr/info/dir
slackdesc       # install slack-desc and doinst.sh

# Build the package:
if [ $PORTARCH = arm ]; then
   slackmp # run makepkg
  else
   makepkg -l y -c n $PKGSTORE/$PKGSERIES/$PACKAGE-$VERSION-$ARCH-$BUILD.tgz
fi

# Perform any final checks on the package:
cd $PKG
slackhlinks     # search for any hard links
