summaryrefslogtreecommitdiffstats
path: root/system/csh/csh.SlackBuild
blob: 2cc0858b65b301ef0919bee0b11ee4e66e8e907a (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash

# Slackware build script for csh

# Written by B. Watson (yalhcru@gmail.com)

# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.

# 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:-20110502_6}
BUILD=${BUILD:-2}
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}.orig"

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $DIRNAM
tar xvf $CWD/$TARNAM.tar.gz
cd $DIRNAM
tar xvf $CWD/${PRGNAM}_${MAINVER}-$DEBVER.debian.tar.[xg]z
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. Except one...
for diff in debian/patches/*.diff; do
  [ "$( basename $diff )" != "09_sys_signame.diff" ] && patch -p1 < $diff
done

# My own patch, keeps csh.h from defining its own (tiny) BUFSIZ. Might
# make I/O more efficient, and allows /etc/profile.d/coreutils-dircolors.sh
# to set a giant $LS_OPTIONS value without "Word too long" error.
patch -p1 < $CWD/bufsiz.diff

# 20210827 bkw: my own patch, glibc >= 2.32 no longer exports
# sys_siglist so we have to use sigdescr_np() instead. Ditto
# sys_signame and sigabbrev_np(). See glibc changelog:
# https://sourceware.org/pipermail/libc-announce/2020/000029.html
# This patch replaces Debian's 09_sys_signame.diff.
patch -p1 < $CWD/glibc-2.32-sys_siglist.diff

# use Slackware standard flags
sed -i "1iCFLAGS=$SLKCFLAGS -fcommon" 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 -

# 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

DOCDIR=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $DOCDIR
cp -a USD.doc/paper.* $DOCDIR
cat $CWD/$PRGNAM.SlackBuild > $DOCDIR/$PRGNAM.SlackBuild
cat $CWD/README_Slackware.txt > $DOCDIR/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