# This is the source.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 DOWNLOAD="https://downloads.sourceforge.net/infozip/unzip${BPM_PKG_VERSION//.}.tar.gz" FILENAME="${DOWNLOAD##*/}" # 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() { wget "$DOWNLOAD" tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE" PATCHES=( "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-exec-shield.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-close.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-attribs-overflow.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-symlink.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-format-secure.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-valgrind.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-x-option.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-overflow.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-cve-2014-8139.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-cve-2014-8140.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-cve-2014-8141.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-overflow-long-fsize.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-heap-overflow-infloop.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-alt-iconv-utf8.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-alt-iconv-utf8-print.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/0001-Fix-CVE-2016-9844-rhbz-1404283.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-timestamp.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-cve-2018-1000035-heap-based-overflow.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-cve-2018-18384.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-${BPM_PKG_VERSION}-COVSCAN-fix-unterminated-string.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-zipbomb-part1.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-zipbomb-part2.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-zipbomb-part3.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-zipbomb-manpage.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-zipbomb-part4.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-zipbomb-part5.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-zipbomb-part6.patch" "https://src.fedoraproject.org/rpms/unzip/raw/rawhide/f/unzip-zipbomb-switch.patch" ) for p in "${PATCHES[@]}"; do cd "$BPM_WORKDIR" wget "$p" cd "$BPM_SOURCE" patch -p1 -i ../"${p##*/}" done } # 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' 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 }