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
|
#!/bin/bash
# Slackware build script for ipcalc-ng
# Original author: Alexander Verbovetsky, Moscow, Russia
# Modified & now maintained by B. Watson <urchlay@slackware.uk>.
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
# 20250924 bkw: v1.0.3, BUILD=2
# - take over maintenance.
# - relicense as WTFPL.
# - add COPYING to doc dir.
# - script cleanup.
# - remove libmaxminddb from REQUIRES, since I couldn't make it work.
# - mention GeoIP as an optional dep.
# - add prebuilt man page, get rid of rubygem-ronn and its deps.
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=ipcalc-ng
VERSION=${VERSION:-1.0.3}
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"
elif [ "$ARCH" = "aarch64" ]; 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 ipcalc-$VERSION
tar xvf $CWD/ipcalc-$VERSION.tar.gz
cd ipcalc-$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 {} +
# 20250925 bkw: undocumented, for use by me.
if [ "${MAKEMAN:-no}" != "yes" ]; then
# don't build the man page (no -D to disable it, have to sed).
sed -i '/^ronn/,/^$/d' meson.build
echo "==== Using prebuilt man page."
else
if ! ronn --version >/dev/null; then
echo "!!!! Can't build man page, install rubygem-ronn and its deps"
exit 0
fi
echo "==== Building man page."
fi
# 20250925 bkw: it only builds with one of libmaxminddb or GeoIP,
# not both. I couldn't actually get libmaxminddb to work, so I
# removed it from REQUIRES and disabled it below. GeoIP is
# optional, autodetected, documented in README.
mkdir build
cd build
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
meson .. \
--buildtype=release \
--infodir=/usr/info \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--localstatedir=/var \
--mandir=/usr/man \
--prefix=/usr \
--sysconfdir=/etc \
-Duse_maxminddb=disabled \
-Dstrip=true
"${NINJA:=ninja}"
DESTDIR=$PKG $NINJA install
cd ..
if [ -e build/ipcalc.1 ]; then
echo "==== Copying new man page to \$CWD"
cp build/ipcalc.1 $CWD
fi
# 20250925 bkw: include a man page symlink named after the package
# name, to help out new users.
MAN1=$PKG/usr/man/man1
mkdir -p $MAN1
gzip -9c < $CWD/ipcalc.1 > $MAN1/ipcalc.1.gz
ln -s ipcalc.1.gz $MAN1/$PRGNAM.1.gz
# 20250925 bkw: did we build with GeoIP support? Can't use ldd because
# it gets dlopen'ed at runtime. This works:
WITHGEO=WITHOUT
strings $PKG/usr/bin/ipcalc | grep -q libGeoIP.so && WITHGEO=WITH
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a COPYING NEWS README.md $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild
mkdir -p $PKG/install
sed "s,@WITHGEO@,$WITHGEO," \
$CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
|