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 vif
# Written by B. Watson (urchlay@slackware.uk)
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
# Note to self: the actual upstream download file doesn't seem
# to change names (it's "vif-current.tar.gz") when there's a new
# version... but the top-level dir inside the tarball does have the
# version number (e.g. vif-1.2.16/). So I host the tarball myself,
# renamed to match the version number. See getsrc.sh.
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=vif
VERSION=${VERSION:-1.2.16}
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
# "make check" doesn't work until after the package has been installed
# (and even then it's checking the installed version, not the binaries
# we just built).
if [ "${CHECK:-no}" = "yes" ]; then
CHECK=yes
if [ ! -x /usr/bin/vif ]; then
CHECK=no
elif [ "$( /usr/bin/vif -v | head -1 | cut -d' ' -f2 )" != "$VERSION" ]; then
CHECK=no
fi
if [ "$CHECK" = "no" ]; then
cat <<EOF
To use CHECK=yes, you must first build and install vif without it,
then re-run this script with CHECK=yes.
EOF
exit 1
fi
fi
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
# Some files have +x for no reason, do not revert to template.
find -L . -type f -a -exec chmod 644 {} + -o \
-type d -a -exec chmod 755 {} +
LIB=lib$LIBDIRSUFFIX
# Make the man page show the vif version.
sed -i "/\\.Os/s,LINUX,$VERSION," src/man/vif.1
# Upstream hardcodes silent make rules, I need to see the compile
# commands, so...
find . -name Makefile | xargs sed -i '/\$(\(C_COMPILER\|VIF\))/s,@ *,,'
# Can't pass CFLAGS or COPT just for optimization flags...
sed -i "/COPT/s,-O2,$SLKCFLAGS," Makefile
[ "$CHECK" = "yes" ] && make check 2>&1 | tee make_check.log
# The recursive Makefiles can't be parallelized. Using -jN where N>1
# works, but spews "jobserver unavailable" warnings.
# Allowing CC overrides in the env, but this *does not* compile
# with Slack 15.0's clang.
make -j1 C_COMPILER=${CC:-gcc} LOCDIR=/usr
# Do not use 'make install', it doesn't support DESTDIR, and does a
# "make clean" followed by "make all", so we can't use LOCDIR=$PKG/usr
# either (the $PKG would end up hardcoded in the binaries). Also,
# 'make install' uses sudo, which would normally be OK since we run as
# root, but if the local sysadmin has removed root from /etc/sudoers,
# it would break...
mkdir -p $PKG/usr/{bin,$LIB,include,man/man1}
install -s -m0755 src/bin/vif $PKG/usr/bin
install -m0644 src/include/vif.h $PKG/usr/include
install -m0644 src/lib/libvif.a $PKG/usr/$LIB
gzip -9c < src/man/vif.1 > $PKG/usr/man/man1/vif.1.gz
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a AUTHORS COPYING NEWS README $PKGDOC
[ "$CHECK" = "yes" ] && cp -a make_check.log $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
|