recipes: Rename 'pkghashtag' variable to 'pkgcategory'
[dragora.git] / recipes / compressors / bzip2 / recipe
blobe2748f3b8dbd528254b7c6f5117b28b05f958a24
1 # Build recipe for bzip2.
3 # Copyright (c) 2016-2018 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 #    http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 program=bzip2
18 version=1.0.6
19 release=2
21 # Define a category for the output of the package name
22 pkgcategory=compressors
24 tarname=${program}-${version}.tar.gz
26 # Remote source(s)
27 fetch="
28 http://mirror.fsf.org/dragora/v3/sources/$tarname
29 http://www.bzip.org/${version}/$tarname
32 description="
33 A high-quality data compressor program.
35 Bzip2 is a high quality compressor that uses the best compression
36 techniques (from the PPM family of statistical compressors).
37 In general, the compression is considerabily better than other
38 compressors, based on LZ77/LZ78 algorithm.
40 The author of bzip2 is Julian Seward.
43 homepage=http://www.bzip.org
44 license=Custom
46 # Source documentation
47 docs="CHANGES LICENSE README"
48 docsdir="${docdir}/${program}-${version}"
50 build()
52     set -e
54     unpack "${tardir}/$tarname"
56     cd "$srcdir"
58     # Set sane permissions
59     chmod -R u+w,go-w,a+rX-s .
61     # Apply a patch to install the documentation (thanks to LFS)
62     patch -Np1 -i "${worktree}/patches/bzip2/bzip2-1.0.6-install_docs-1.patch"
64     # Ensure installation of relative symbolic links (thanks to LFS)
65     sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
67     # Ensure the man pages are installed into the correct location
68     sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile
70     # Ensure location for libraries
71     sed -i "s@(PREFIX)/lib@(PREFIX)/lib${libSuffix}@g" Makefile
73     # Build bzip2.
74     #
75     # Provide shared libraries for third party programs
76     make -f Makefile-libbz2_so
77     make clean
79     # Recompile program for static linking
80     make LDFLAGS="$QILDFLAGS -static"
81     make PREFIX="${destdir}/usr" install
83     # Copy shared libraries into package destination
84     cp -f -p libbz2.so* "${destdir}/usr/lib${libSuffix}"
86     # Library measurement
87     strip -s "${destdir}/usr/lib${libSuffix}/libbz2.so.1.0.6"
89     # Make soft links providing compatibility
90     (
91         cd "${destdir}/usr/lib${libSuffix}" || exit 1
92         ln -sf libbz2.so.1.0.6 libbz2.so.1.0
93         ln -sf libbz2.so.1.0.6 libbz2.so
94     )
96     # Compress and link man pages (if needed)
97     if test -d "${destdir}/$mandir"
98     then
99         (
100             cd "${destdir}/$mandir"
101             find . -type f -exec lzip -9 '{}' +
102             find . -type l | while read -r file
103             do
104                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
105                 rm -- "$file"
106             done
107         )
108     fi
110     # Copy the rest of the documentation
111     mkdir -p "${destdir}${docsdir}"
113     for file in $docs
114     do
115         cp -p $file "${destdir}${docsdir}"
116     done