qi: new version. Use tar(1) in the unpack function to cover general archives compres...
[dragora.git] / recipes / compressors / unzip / recipe
blobba21a329d394f3a56428924b578102342b4eb202
1 # Build recipe for unzip.
3 # Copyright (c) 2017 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=unzip
18 version=60
19 pkgversion=6.0
20 release=1
22 # Set 'outdir' for a nice and well-organized output directory
23 outdir="${outdir}/${arch}/compressors"
25 tarname=${program}${version}.tar.gz
27 # Remote source(s)
28 fetch=http://downloads.sourceforge.net/infozip/$tarname
30 description="
31 A utility for extracting ZIP files.
33 UnZip is an extraction utility for archives compressed in .zip format
34 (also called \"zipfiles\").  Although highly compatible both with
35 PKWARE's PKZIP and PKUNZIP utilities for MS-DOS and with Info-ZIP's own
36 Zip program, our primary objectives have been portability and non-MSDOS
37 functionality.
40 homepage=http://www.info-zip.org/UnZip.html
41 license="Custom, Info-Zip"
43 # Source documentation
44 docs="BUGS LICENSE README ToDo WHERE"
45 docsdir="${docdir}/${program}-${pkgversion}"
47 # Source directory for this software
48 srcdir=${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 patches from the Fedora project, thanks!
62     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-bzip2-configure.patch"
63     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-exec-shield.patch"
64     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-close.patch"
65     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-attribs-overflow.patch"
66     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-configure.patch"
67     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-manpage-fix.patch"
68     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-fix-recmatch.patch"
69     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-symlink.patch"
70     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-caseinsensitive.patch"
71     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-format-secure.patch"
72     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-valgrind.patch"
73     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-x-option.patch"
74     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-overflow.patch"
75     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-cve-2014-8139.patch"
76     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-cve-2014-8140.patch"
77     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-cve-2014-8141.patch"
78     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-overflow-long-fsize.patch"
79     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-heap-overflow-infloop.patch"
80     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-alt-iconv-utf8.patch"
81     patch -p1 < "${worktree}/patches/unzip/unzip-6.0-alt-iconv-utf8-print.patch"
82     patch -p1 < "${worktree}/patches/unzip/0001-Fix-CVE-2016-9844-rhbz-1404283.patch"
84     make -f unix/Makefile \
85       CF_NOOPT="-I. -DUNIX -DNOMEMCPY -DIZ_HAVE_UXUIDGID -DNO_LCHMOD" \
86       LFLAGS2="$QILDFLAGS -static" generic_gcc
88     make -f unix/Makefile \
89       prefix="${destdir}/usr" \
90       MANDIR="${destdir}/${mandir}/man1" \
91       INSTALL="cp -p" \
92       install
94     # Reinclude zipgrep fixing its ownerships
95     rm -f "${destdir}/usr/bin/zipgrep"
96     cat unix/zipgrep > "${destdir}/usr/bin/zipgrep"
97     chmod 755 "${destdir}/usr/bin/zipgrep"
99     # Compress and link man pages (if needed)
100     if test -d "${destdir}/$mandir"
101     then
102         (
103             cd "${destdir}/$mandir"
104             find . -type f -exec lzip -9 '{}' +
105             find . -type l | while read -r file
106             do
107                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
108                 rm -- "$file"
109             done
110         )
111     fi
113     # Copy documentation
114     mkdir -p "${destdir}${docsdir}"
116     for file in $docs
117     do
118         cp -p $file "${destdir}${docsdir}"
119     done