Files

64 lines
3.3 KiB
Bash

# This is the recipe.sh script. It is executed by BPM in a temporary directory when compiling a source package
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
# The prepare function is executed in the root of the temp directory
# This function is used for downloading files and putting them into the correct location
prepare() {
cd "$BPM_SOURCE"
sed -i "/MANDIR =/s#)/#)/share/#" unix/Makefile
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-exec-shield.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-close.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-attribs-overflow.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-symlink.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-format-secure.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-valgrind.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-x-option.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-overflow.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-cve-2014-8139.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-cve-2014-8140.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-cve-2014-8141.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-overflow-long-fsize.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-heap-overflow-infloop.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-alt-iconv-utf8.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-alt-iconv-utf8-print.patch
patch -p1 -i "$BPM_WORKDIR"/0001-Fix-CVE-2016-9844-rhbz-1404283.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-timestamp.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-cve-2018-1000035-heap-based-overflow.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-cve-2018-18384.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0-COVSCAN-fix-unterminated-string.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-zipbomb-part1.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-zipbomb-part2.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-zipbomb-part3.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-zipbomb-manpage.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-zipbomb-part4.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-zipbomb-part5.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-zipbomb-part6.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-zipbomb-part7.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-zipbomb-switch.patch
patch -p1 -i "$BPM_WORKDIR"/unzip-6.0_CVE-2021-4217.patch
patch -p1 -F3 -i "$BPM_WORKDIR"/28-cve-2022-0529-and-cve-2022-0530.patch
}
# The build function is executed in the source directory
# This function is used to compile the source code
build() {
# DEFINES, make, and install args from Debian
DEFINES='-DACORN_FTYPE_NFS -DWILD_STOP_AT_DIR -DLARGE_FILE_SUPPORT \
-DUNICODE_SUPPORT -DUNICODE_WCHAR -DUTF8_MAYBE_NATIVE -DNO_LCHMOD \
-DDATE_FORMAT=DF_YMD -DUSE_BZIP2 -DNOMEMCPY -DNO_WORKING_ISPRINT'
export CFLAGS="-std=gnu89"
make -f unix/Makefile prefix=/usr \
D_USE_BZ2=-DUSE_BZIP2 L_BZ2=-lbz2 \
LF2="$LDFLAGS" CF="$CFLAGS $CPPFLAGS -I. $DEFINES" \
unzips
}
# The package function is executed in the source directory
# This function is used to move the compiled files into the output directory
package() {
make -f unix/Makefile prefix="$BPM_OUTPUT"/usr MANDIR="$BPM_OUTPUT"/usr/share/man/man1 install
install -Dm644 LICENSE "$BPM_OUTPUT"/usr/share/licenses/unzip/LICENSE
}