aboutsummaryrefslogtreecommitdiff
path: root/graphics/qiv/qiv.SlackBuild
blob: 6c1ffd6b2645e0adee566a0d650b822db22b9c56 (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 qiv

# Written by Pablo Santamaria (email removed)

# Modified & now maintained by B. Watson <urchlay@slackware.uk>. Original
# version had no license, modified version released under the WTFPL. See
# http://www.wtfpl.net/txt/copying/ for details.

# 20250328 bkw:
# - Update for v2.3.4. This is a release on upstream's codeberg page,
#   but the homepage hasn't been updated yet. codeberg's URLs are
#   "unstable" due to content-disposition, so the script has to
#   handle 2 possible filenames.

# 20241228 bkw: BUILD=2
# - support AVIF images. libheif handles them, just have to add the
#   filename extension and magic to main.h (in new_formats.diff).
# - mention libheif as an optional dep in README.
# - update qiv-allfmt.sqf to include libheif and its deps.

# 20230605 bkw:
# - Update for v2.3.3.
# - JPEG 2000 works now, so enable it in the Makefile.
# - WMF is broken. Fixed by adding new libwmf-type1-fonts optional
#   dep. Documented in README.
# - Rework new_formats.diff. Script can no longer build old version.
# - Fix and update qiv-allfmt.sqf.

# 20191231 bkw:
# - Add libopenraw (raw camera image) formats, BUILD=2.
# - Remove mention of wmf-pixbuf loader from README and .sqf
#   since there's a Slackware update that removes the need for it.

# 20191226 bkw:
# - Upgrade for v2.3.2. This was released a month after my last update,
#   but the download page on the site doesn't link to it (found it just
#   now by editing the URL for v2.3.1), so my update-checker script
#   never saw it...
# - As compensation for my tardiness, add support for a bunch of new
#   image types.

# 20170209 bkw:
# - Take over maintenance
# - i486 => i586
# - Add latest fixes from upstream's git
# - Get rid of redundant stripping of binaries and gzipping
#   of man pages (upstream's 'make install' already does it)
# - Don't install README.INSTALL

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

PRGNAM=qiv
VERSION=${VERSION:-2.3.4}
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"
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
else
  SLKCFLAGS="-O2"
fi

set -e

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

# Patch to add potential support for various image formats. This patch
# doesn't actually contain any code for decoding/displaying new image
# formats. All it does is add file extensions and magic to the list
# of filetypes qiv will attempt to display via imlib and/or pixbuf.
# It's up to imlib/pixbuf to actually support the image types. Some of
# these are already supported in Slackware, a few require optional deps
# (see README).

# For the optional ones (e.g. webp), this patch doesn't do any harm
# if the support library's not installed. All it does is make qiv warn
# "Unable to read file" on stderr, instead of silently skipping it.

patch -p1 < $CWD/new_formats.diff

# Three sed expressions here. In order:
# 1. Make qiv build with our compiler flags.
# 2. Disable the test, since it requires X to be running and
#    accepting connections from root.
# 3. Put man page where Slackware likes them.
sed -i -e "s/-O2 -Wall/$SLKCFLAGS/" \
       -e "s|\./qiv|echo &|"        \
       -e 's,/share/man,/man,g'     \
       Makefile

make
make install PREFIX=$PKG/usr

# binary already stripped, man pages already gzipped

rm -f README.INSTALL  # don't need this in a binary package
chmod 644 contrib/*   # docs shouldn't be executable even if they're scripts
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a Changelog README* intro.jpg contrib/ $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$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