aboutsummaryrefslogtreecommitdiff
path: root/system/fdclone/fdclone.SlackBuild
blob: 52a1c20afca8502e06481978426d93877fcfcb42 (plain)
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
134
135
136
137
138
139
#!/bin/bash

# Slackware build script for fdclone

# Written by B. Watson (urchlay@slackware.uk)

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

# This build script owes a debt to the Debian fdclone build
# script. Unlike the Debian build though, I install the binary & man
# pages as "fdclone", not "fd", because SBo already has an "fd". I
# also don't see the point of the stub fdsh man page.

# 20210826 bkw: BUILD=2
# - include missing ToAdmin doc file
# - convert Japanese docs to UTF-8, since nothing on Slackware autodetects
#   ISO-2002-JP (now you can read them with e.g. less).
# - hardcode built-in paths to less and vim (simpler code, and safer too)

cd $(dirname $0) ; CWD=$(pwd)

PRGNAM=fdclone
SRCNAM=FD
VERSION=${VERSION:-3.01j}
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

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $SRCNAM-$VERSION
tar xvf $CWD/$SRCNAM-$VERSION.tar.gz
cd $SRCNAM-$VERSION
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 {} \+

# Patches from Debian. Not going to apply the one that stops the
# Makefile from stripping the binary, since that's what we want.
patch -p1 < $CWD/01_previous_changes.patch
patch -p1 < $CWD/30_makefilein_setting.patch

# Set the default pager & editor to things that actually exist on
# Slackware. The user's EDITOR and PAGER will override these, or they
# can be set system-wide by the admin, in the config file.
sed -i -e "s,/usr/bin/pager,/usr/bin/less," \
       -e "s,/usr/bin/editor,/usr/bin/vi," \
       fd.h

make config
make CFLAGS="$SLKCFLAGS" \
     PREFIX=/usr \
     CONFDIR=/etc/$PRGNAM

# make install fails to create this:
mkdir -p $PKG/usr/man/man1

make install \
     PREFIX=$PKG/usr \
     DATADIR=$PKG/usr/share/$PRGNAM \
     MANDIR=$PKG/usr/man/man1 \
     EMANDIR=$PKG/usr/man/man1 \
     JMANDIR=$PKG/usr/man/ja/man1 \
     JCATDIR=$PKG/usr/man/ja/man1 \
     DEFRC=$PKG/etc/$PRGNAM/fd2rc

# Rename to avoid conflict with system/fd
rename /fd /$PRGNAM \
  $PKG/usr/bin/fd \
  $PKG/usr/man/man1/fd.1 \
  $PKG/usr/man/ja/man1/fd.1

# De-hardlinkify
rm -f $PKG/usr/bin/fdsh
ln -s $PRGNAM $PKG/usr/bin/fdsh
rm -f $PKG/usr/man/man1/fdsh.1 $PKG/usr/man/ja/man1/fdsh.1
gzip -9 $PKG/usr/man/man1/$PRGNAM.1 $PKG/usr/man/ja/man1/$PRGNAM.1
ln -s $PRGNAM.1.gz $PKG/usr/man/man1/fdsh.1.gz
ln -s $PRGNAM.1.gz $PKG/usr/man/ja/man1/fdsh.1.gz

# Don't install fd2rc as a .new config, since it sources
# fd2rc.siteconfig, which can override anything in fd2rc,
# and the comments at the top explain this clearly.
mkdir -p $PKG/etc/$PRGNAM
cat $CWD/fd2rc > $PKG/etc/$PRGNAM/fd2rc
echo "# fd2rc.siteconfig - see fd2rc for options you can use here" > \
  $PKG/etc/$PRGNAM/fd2rc.siteconfig.new

PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC

# Convert the Japanese-language docs to UTF-8 encoding.
for i in FAQ HISTORY LICENSES README TECHKNOW ToAdmin; do
   iconv -f ISO-2022-JP -t UTF-8 $i > $PKGDOC/$i
   cp -a $i.eng $PKGDOC/$i.eng
done

cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild

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