#!/bin/sh
# Set initial variables:
CWD=`pwd`
if [ "$TMP" = "" ]; then
TMP=/tmp
fi
PKG=$TMP/package-uucp
VERSION=1.07
ARCH=${ARCH:-i486}
BUILD=1
if [ "$ARCH" = "i386" ]; then
SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
elif [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
elif [ "$ARCH" = "s390" ]; then
SLKCFLAGS="-O2"
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2"
fi
if [ ! -d $TMP ]; then
mkdir -p $TMP # location to build the source
fi
if [ ! -d $PKG ]; then
mkdir -p $PKG # place for the package to be built
fi
# Explode the package framework:
cd $PKG
explodepkg $CWD/_uucp.tar.gz
cd $TMP
tar xzvf $CWD/uucp-$VERSION.tar.gz
cd uucp-$VERSION
zcat $CWD/policy.h.diff.gz | patch -p1 --verbose
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
--with-oldconfigdir=/etc/uucp/oldconfig \
--with-newconfigdir=/etc/uucp
make
make install DESTDIR=$PKG
chgrp bin $PKG/usr/bin/* $PKG/usr/sbin/*
strip --strip-unneeded $PKG/usr/bin/* $PKG/usr/sbin/*
gzip -9 $PKG/usr/man/man?/*
gzip -9 $PKG/usr/info/*
rm -f $PKG/usr/info/dir.gz
# Setuid uucp binaries may only be run by members of the uucp group:
( cd $PKG/usr/bin
chgrp uucp cu uucp uuname uustat uux
chmod 4554 cu uucp uuname uustat uux
cd ../sbin
chgrp uucp uucico uuxqt
chmod 4554 uucico uuxqt
)
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
# Build the package:
cd $PKG
makepkg -l y -c n $TMP/uucp-$VERSION-$ARCH-$BUILD.tgz
# Clean up the extra stuff:
if [ "$1" = "--cleanup" ]; then
rm -rf $TMP/uucp-$VERSION
rm -rf $PKG
fi