aboutsummaryrefslogtreecommitdiff
path: root/system/lv/lv.SlackBuild
blob: 9a008e146e3c8f1c1d0eebb572f5839a6ab980ce (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
#!/bin/bash

# Slackware build script for lv

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

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

# 20201111 bkw: added at v4.51_7. The original upstream for this is
# long gone (dead website), but the maintainer of the Debian package
# continues to develop this. So I'm treating Debian as upstream, and
# the _7 in VERSION is the Debian patchlevel.

# 20201115 bkw: add 2 new patches from Debian git, BUILD=2.

PRGNAM=lv
VERSION=${VERSION:-4.51_7}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

# Nothing uses LIBDIRSUFFIX, don't bother with it.
if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
else
  SLKCFLAGS="-O2"
fi

set -e

SRCVER=${VERSION%_*}  # 1.23_4 => 1.23
DEBVER=${VERSION#*_}  # 1.23_4 => 4

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$SRCVER.orig
tar xvf $CWD/${PRGNAM}_$SRCVER.orig.tar.?z
cd $PRGNAM-$SRCVER.orig
tar xvf $CWD/${PRGNAM}_$SRCVER-$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.
for i in $( cat debian/patches/series ); do
  patch -p1 < "debian/patches/$i"
done

# Local patches. 4 of these were written by the SlackBuild author, sent
# upstream (to the Debian maintainer). The height and filename patches
# are from Debian's git.
for i in $( cat $CWD/patches/series ); do
  patch -p1 < "$CWD/patches/$i"
done

# I wish there were --disable-termcap and/or --enable-ncurses options.
# The configure script is hardcoded: if termcap is found, it uses that
# and never looks for ncurses. Since termcap is pretty well deprecated
# here in the 21st century, we'd much rather use ncurses...
sed -i 's,termcap,ncurses,g' src/configure

# libdir is /usr/share because all that gets installed there is the lv
# help file (which is just a pre-rendered version of the man page).
cd build
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
../src/configure \
  --enable-fastio \
  --prefix=/usr \
  --libdir=/usr/share \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --mandir=/usr/man \
  --build=$ARCH-slackware-linux

make
make install DESTDIR=$PKG

# binary already stripped
gzip -9 $PKG/usr/man/man1/$PRGNAM.1
ln -s $PRGNAM.1.gz $PKG/usr/man/man1/lgrep.1.gz

cd ..
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a README* GPL* hello.* debian/changelog $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

# Japanese-language sections in the HTML docs are in some kind of
# non-Unicode encoding. lv autodetects it just fine, but nothing else
# seems to, so use lv itself to convert them to UTF-8. This is helpful
# if you're reading the files locally with a browser: there's no HTTP
# headers to specify the encoding, and UTF-8 is more likely to be
# autodetected or just guessed at.
for i in *.html; do
  $PKG/usr/bin/lv -Ou8 $i > $PKG/usr/doc/$PRGNAM-$VERSION/$i
done

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:-tgz}