158 lines
4.8 KiB
Bash
158 lines
4.8 KiB
Bash
#!/bin/bash
|
|
|
|
# Slackware build script for csh
|
|
|
|
# Written by B. Watson (urchlay@slackware.uk)
|
|
|
|
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
|
|
|
|
# 20250115 bkw:
|
|
# - update for v20240808_2 (sync with Debian again).
|
|
# - remove timespec.diff, it's no longer needed.
|
|
|
|
# 20230919 bkw:
|
|
# - update for v20230828_1 (sync with Debian sid).
|
|
# - remove old no-longer-needed bufsiz.diff and glibc-2.32-sys_siglist.diff.
|
|
# - add timespec.diff to work around breakage in csh's time builtin.
|
|
# - add remove_publib_dep.diff to avoid an external publib dependency.
|
|
# - update csh.login a bit (new csh has a different default $prompt).
|
|
# - mention bad profile scripts in README_Slackware.txt.
|
|
# - fix the man page slightly.
|
|
|
|
# 20220409 bkw: BUILD=2
|
|
# - fix doinst.sh: only create bin/csh symlink if bin exists, which
|
|
# fixes installing the package with 'installpkg -root /some/path'.
|
|
|
|
# 20210827 bkw:
|
|
# - update to latest debian patch (6), add deb version to VERSION.
|
|
# - add -current fix for recent glibc.
|
|
|
|
# 20170621 bkw:
|
|
# - update to latest debian patch (-2.2, needed for -current).
|
|
# - quit compiling with -Werror (also needed for -current).
|
|
# - BUILD=2.
|
|
|
|
cd $(dirname $0) ; CWD=$(pwd)
|
|
|
|
PRGNAM=csh
|
|
VERSION=${VERSION:-20240808_2}
|
|
BUILD=${BUILD:-1}
|
|
TAG=${TAG:-_SBo}
|
|
PKGTYPE=${PKGTYPE:-tgz}
|
|
|
|
if [ -z "$ARCH" ]; then
|
|
case "$( uname -m )" in
|
|
i?86) ARCH=i586 ;;
|
|
arm*) ARCH=arm ;;
|
|
*) ARCH=$( uname -m ) ;;
|
|
esac
|
|
fi
|
|
|
|
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
|
|
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
|
|
exit 0
|
|
fi
|
|
|
|
TMP=${TMP:-/tmp/SBo}
|
|
PKG=$TMP/package-$PRGNAM
|
|
OUTPUT=${OUTPUT:-/tmp}
|
|
|
|
if [ "$ARCH" = "i586" ]; then
|
|
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
|
|
LIBDIRSUFFIX=""
|
|
elif [ "$ARCH" = "i686" ]; then
|
|
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
|
|
LIBDIRSUFFIX=""
|
|
elif [ "$ARCH" = "x86_64" ]; then
|
|
SLKCFLAGS="-O2 -fPIC"
|
|
LIBDIRSUFFIX="64"
|
|
else
|
|
SLKCFLAGS="-O2"
|
|
LIBDIRSUFFIX=""
|
|
fi
|
|
|
|
set -e
|
|
|
|
MAINVER="${VERSION%_*}" # 123_4 => 123
|
|
DEBVER="${VERSION#*_}" # 123_4 => 4
|
|
|
|
# Grr.
|
|
TARNAM="${PRGNAM}_${MAINVER}.orig"
|
|
DIRNAM="${PRGNAM}-${MAINVER}"
|
|
|
|
rm -rf $PKG
|
|
mkdir -p $TMP $PKG $OUTPUT
|
|
cd $TMP
|
|
rm -rf $DIRNAM
|
|
tar xvf $CWD/$TARNAM.tar.xz
|
|
cd $DIRNAM
|
|
tar xvf $CWD/${PRGNAM}_${MAINVER}-$DEBVER.debian.tar.xz
|
|
chown -R root:root .
|
|
find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} + -o \
|
|
\! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} +
|
|
|
|
# Apply all of Debian's patches.
|
|
# 20250115 bkw: series file has a commented-out patch, deal with it.
|
|
for diff in $( grep -v '^#' debian/patches/series ); do
|
|
if [ -e "debian/patches/$diff" ]; then
|
|
echo "=== Applying $diff"
|
|
patch -p1 < debian/patches/$diff
|
|
fi
|
|
done
|
|
|
|
# 20230919 bkw: My own patch. Provides an implementations of
|
|
# xrealloc(), and replaces xfree() with free(), so we don't have
|
|
# publib as a dependency.
|
|
# 20250115 bkw: Patch had to be reworked for v20240808_2.
|
|
patch -p1 < $CWD/remove_publib_dep.diff
|
|
|
|
# 20230919 bkw: Missing prototype for closefrom(). We don't want
|
|
# to #include <bsd/unistd.h> to get it, so just prepend it. This
|
|
# probably didn't cause a problem anyway.
|
|
sed -i '1ivoid closefrom(int lowfd);' misc.c
|
|
|
|
# use Slackware standard flags.
|
|
# 20230919 bkw: _VIS thing just silences a meaningless warning. it's
|
|
# meaningless because it only applies to strnvis() and strnunvis(),
|
|
# neither of which is called by csh.
|
|
sed -i "1iCFLAGS=$SLKCFLAGS -fcommon -DLIBBSD_OPENBSD_VIS" Makefile
|
|
|
|
# The LIBC= isn't even used, but Slackware64's pmake is broken: it has
|
|
# /usr/lib/libc.a hard-coded, and pmake wants to build that (and can't),
|
|
# even though the csh binary is dynamic and doesn't even need libc.a!
|
|
# Also don't know why I have to make const.h separately, but it works.
|
|
pmake const.h NOGCCERROR=1
|
|
pmake LIBC=/usr/lib$LIBDIRSUFFIX/libc.a NOGCCERROR=1
|
|
cd USD.doc
|
|
pmake paper.ps paper.txt
|
|
cd -
|
|
|
|
# 20230919 bkw: word length is BUFSIZ (by default in 20230828_1, no
|
|
# patching required). This is 8192 bytes on x86 and x86_64, so fix
|
|
# the man page.
|
|
sed -i '/Words can be no/s,1024,8192,' csh.1
|
|
|
|
# I think this is the first time I've ever seen 'make install' gzip the
|
|
# man pages and strip the binary! BSD FTW!
|
|
mkdir -p $PKG/usr/bin $PKG/usr/man/man1
|
|
pmake install DESTDIR=$PKG BINDIR=/usr/bin MANDIR=/usr/man
|
|
|
|
# Technically this conflicts with Slackware's etc package, but the file
|
|
# that's modified still works exactly the same with tcsh. Also it's a .new
|
|
# config file, requires manual intervention.
|
|
mkdir -p $PKG/etc
|
|
cat $CWD/csh.login > $PKG/etc/csh.login.new
|
|
|
|
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
|
|
mkdir -p $PKGDOC
|
|
cp -a USD.doc/paper.* $PKGDOC
|
|
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild
|
|
cat $CWD/README_Slackware.txt > $PKGDOC/README_Slackware.txt
|
|
|
|
mkdir -p $PKG/install
|
|
cat $CWD/slack-desc > $PKG/install/slack-desc
|
|
cat $CWD/doinst.sh > $PKG/install/doinst.sh
|
|
|
|
cd $PKG
|
|
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
|