Skip to content

Commit

Permalink
Distribute p7zip and libz via our BB tarball bundling
Browse files Browse the repository at this point in the history
This provides a number of benefits:

* Significantly reduces the amount of work in win-extras, which I've
always thought was an annoying wart in our build system.

* Provides a consistent 7z executable on all platforms, which can be
picked up by Pkg/BinaryProvider for consistent
unzipping/untarring/ungzipping on all platforms. Note that on Windows,
7z is a repackaged binary from sourceforge and is the "full" 7z, whereas
on all other platforms it is a p7zip build of the standalone 7za
executable with all relevant patches applied. There are some format
capability differences, but for the important things it should be fine.
  • Loading branch information
staticfloat committed Sep 17, 2019
1 parent 879fef4 commit bbf7310
Show file tree
Hide file tree
Showing 68 changed files with 540 additions and 36 deletions.
3 changes: 1 addition & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ Julia's build process uses the following external tools:
- [PATCHELF](https://nixos.org/patchelf.html)
- [OBJCONV](https://www.agner.org/optimize/#objconv)

Julia bundles the following external programs and libraries on some platforms:
Julia bundles the following external programs and libraries:

- [7-Zip](https://www.7-zip.org/license.txt)
- [ZLIB](https://zlib.net/zlib_license.html)
- [LIBEXPAT](http://expat.cvs.sourceforge.net/viewvc/expat/expat/README)

On some platforms, distributions of Julia contain SSL certificate authority certificates,
released under the [Mozilla Public License](https://en.wikipedia.org/wiki/Mozilla_Public_License).
4 changes: 3 additions & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ USE_SYSTEM_LIBSSH2:=0
USE_SYSTEM_CURL:=0
USE_SYSTEM_LIBGIT2:=0
USE_SYSTEM_PATCHELF:=0
USE_SYSTEM_ZLIB:=0
USE_SYSTEM_P7ZIP:=0

# Link to the LLVM shared library
USE_LLVM_SHLIB := 1
Expand Down Expand Up @@ -1005,7 +1007,7 @@ USE_BINARYBUILDER ?= 0
endif

# This is the set of projects that BinaryBuilder dependencies are hooked up for.
BB_PROJECTS := OPENBLAS LLVM SUITESPARSE OPENLIBM GMP MBEDTLS LIBSSH2 MPFR CURL LIBGIT2 PCRE LIBUV LIBUNWIND DSFMT OBJCONV
BB_PROJECTS := OPENBLAS LLVM SUITESPARSE OPENLIBM GMP MBEDTLS LIBSSH2 MPFR CURL LIBGIT2 PCRE LIBUV LIBUNWIND DSFMT OBJCONV ZLIB P7ZIP
define SET_BB_DEFAULT
# First, check to see if BB is disabled on a global setting
ifeq ($$(USE_BINARYBUILDER),0)
Expand Down
40 changes: 8 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ ifeq ($(BUNDLE_DEBUG_LIBS),1)
else
@$(MAKE) $(QUIET_MAKE) release
endif
@for subdir in $(bindir) $(datarootdir)/julia/stdlib/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir); do \
@for subdir in $(bindir) $(datarootdir)/julia/stdlib/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir) $(libexecdir); do \
mkdir -p $(DESTDIR)$$subdir; \
done

Expand All @@ -293,6 +293,9 @@ endif
-$(INSTALL_M) $(build_bindir)/libopenlibm.dll.a $(DESTDIR)$(libdir)/
else

# Install `7z` into libexec/
$(INSTALL_M) $(build_bindir)/7z $(DESTDIR)$(libexecdir)/

# Copy over .dSYM directories directly for Darwin
ifneq ($(DARWIN_FRAMEWORK),1)
ifeq ($(OS),Darwin)
Expand Down Expand Up @@ -454,8 +457,6 @@ ifeq ($(OS), Darwin)
endif

ifeq ($(OS), WINNT)
[ ! -d $(JULIAHOME)/dist-extras ] || ( cd $(JULIAHOME)/dist-extras && \
cp 7z.exe 7z.dll libexpat-1.dll zlib1.dll $(BUILDROOT)/julia-$(JULIA_COMMIT)/bin )
cd $(BUILDROOT)/julia-$(JULIA_COMMIT)/bin && rm -f llvm* llc.exe lli.exe opt.exe LTO.dll bugpoint.exe macho-dump.exe

# create file listing for uninstall. note: must have Windows path separators and line endings.
Expand All @@ -465,7 +466,7 @@ ifeq ($(OS), WINNT)
cd $(BUILDROOT) && $(call spawn,$(JULIAHOME)/dist-extras/nsis/makensis.exe) -NOCD -DVersion=$(JULIA_VERSION) -DArch=$(ARCH) -DCommit=$(JULIA_COMMIT) -DJULIAHOME="$(call cygpath_w,$(JULIAHOME))" $(call cygpath_w,$(JULIAHOME)/contrib/windows/build-installer.nsi) | iconv -f latin1

# compress nsis installer and combine with 7zip self-extracting header
cd $(BUILDROOT) && $(JULIAHOME)/dist-extras/7z a -mx=9 "julia-install-$(JULIA_COMMIT)-$(ARCH).7z" julia-installer.exe
cd $(BUILDROOT) && $(JULIAHOME)/usr/bin/7z a -mx=9 "julia-install-$(JULIA_COMMIT)-$(ARCH).7z" julia-installer.exe
cd $(BUILDROOT) && cat $(JULIAHOME)/contrib/windows/7zS.sfx $(JULIAHOME)/contrib/windows/7zSFX-config.txt "julia-install-$(JULIA_COMMIT)-$(ARCH).7z" > "$(JULIA_BINARYDIST_FILENAME).exe"
chmod a+x "$(BUILDROOT)/$(JULIA_BINARYDIST_FILENAME).exe"
-rm -f $(BUILDROOT)/julia-install-$(JULIA_COMMIT)-$(ARCH).7z
Expand Down Expand Up @@ -585,37 +586,12 @@ test-%: check-whitespace $(JULIA_BUILD_MODE)
# download target for some hardcoded windows dependencies
.PHONY: win-extras wine_path
win-extras:
[ -d $(JULIAHOME)/dist-extras ] || mkdir $(JULIAHOME)/dist-extras
ifneq ($(BUILD_OS),WINNT)
ifeq (,$(findstring CYGWIN,$(BUILD_OS)))
cp /usr/lib/p7zip/7z /usr/lib/p7zip/7z.so $(JULIAHOME)/dist-extras
endif
endif
ifneq (,$(filter $(ARCH), i386 i486 i586 i686))
cd $(JULIAHOME)/dist-extras && \
$(JLDOWNLOAD) https://sourceforge.net/projects/sevenzip/files/7-Zip/19.00/7z1900.exe && \
$(JLCHECKSUM) 7z1900.exe && \
7z x -y 7z1900.exe 7z.exe 7z.dll && \
../contrib/windows/winrpm.sh http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Leap_42.2 \
"mingw32-libexpat1 mingw32-zlib1" && \
cp usr/i686-w64-mingw32/sys-root/mingw/bin/*.dll .
else ifeq ($(ARCH),x86_64)
cd $(JULIAHOME)/dist-extras && \
$(JLDOWNLOAD) https://downloads.sourceforge.net/project/sevenzip/7-Zip/19.00/7z1900-x64.exe && \
$(JLCHECKSUM) 7z1900-x64.exe && \
7z x -y 7z1900-x64.exe 7z.exe 7z.dll && \
../contrib/windows/winrpm.sh http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_Leap_42.2 \
"mingw64-libexpat1 mingw64-zlib1" && \
cp usr/x86_64-w64-mingw32/sys-root/mingw/bin/*.dll .
else
$(error no win-extras target for ARCH=$(ARCH))
endif
@$(MAKE) -C $(BUILDROOT)/deps install-p7zip
mkdir -p $(JULIAHOME)/dist-extras
cd $(JULIAHOME)/dist-extras && \
$(JLDOWNLOAD) https://sourceforge.net/projects/nsis/files/NSIS%203/3.04/nsis-3.04-setup.exe && \
$(JLCHECKSUM) nsis-3.04-setup.exe && \
chmod a+x 7z.exe && \
chmod a+x 7z.dll && \
$(call spawn,./7z.exe) x -y -onsis nsis-3.04-setup.exe && \
$(call spawn,$(JULIAHOME)/usr/bin/7z.exe) x -y -onsis nsis-3.04-setup.exe && \
chmod a+x ./nsis/makensis.exe

# various statistics about the build that may interest the user
Expand Down
2 changes: 1 addition & 1 deletion contrib/refresh_bb_tarballs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
TRIPLETS="i686-linux-gnu x86_64-linux-gnu aarch64-linux-gnu arm-linux-gnueabihf powerpc64le-linux-gnu i686-linux-musl x86_64-linux-musl aarch64-linux-musl arm-linux-musleabihf x86_64-apple-darwin14 x86_64-unknown-freebsd11.1 i686-w64-mingw32 x86_64-w64-mingw32"

# These are the projects currently using BinaryBuilder; both GCC-expanded and non-GCC-expanded:
BB_PROJECTS="gmp mbedtls libssh2 mpfr curl libgit2 pcre libuv unwind osxunwind dsfmt objconv"
BB_PROJECTS="gmp mbedtls libssh2 mpfr curl libgit2 pcre libuv unwind osxunwind dsfmt objconv p7zip zlib"
BB_GCC_EXPANDED_PROJECTS="llvm openblas suitesparse openlibm"

# If we've been given a project name, filter down to that one:
Expand Down
11 changes: 11 additions & 0 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ ifeq ($(USE_SYSTEM_UTF8PROC), 0)
DEP_LIBS += utf8proc
endif

ifeq ($(USE_SYSTEM_LIBZ), 0)
DEP_LIBS += libz
endif

ifeq ($(USE_SYSTEM_P7ZIP), 0)
DEP_LIBS += p7zip
endif


# Only compile standalone LAPACK if we are not using OpenBLAS.
# OpenBLAS otherwise compiles LAPACK as part of its build.
# This is useful where one wants to use the vendor BLAS, but
Expand Down Expand Up @@ -191,3 +200,5 @@ include $(SRCDIR)/libssh2.mk
include $(SRCDIR)/curl.mk
include $(SRCDIR)/libgit2.mk
include $(SRCDIR)/libwhich.mk
include $(SRCDIR)/zlib.mk
include $(SRCDIR)/p7zip.mk
4 changes: 4 additions & 0 deletions deps/Versions.make
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ LIBUV_VER = 1.29.1
LIBUV_BB_REL = 0
OBJCONV_VER = 2.49.0
OBJCONV_BB_REL = 0
ZLIB_VER = 1.2.11
ZLIB_BB_REL = 3
P7ZIP_VER = 16.2.0
P7ZIP_BB_REL = 1

# Specify the version of the Mozilla CA Certificate Store to obtain.
# The versions of cacert.pem are identified by the date (YYYY-MM-DD) of their changes.
Expand Down
1 change: 1 addition & 0 deletions deps/checksums/Zlib.v1.2.11-3.aarch64-linux-gnu.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
489c5ebbca174fdbfae86846e270e112
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
da1bac181754711c50909492127f855c9acc2928951ce95310a6d32c03bb731d82fe2f0f97ae482c0da319b09d74b91aa143bd90b992489d386beee492d30e6f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e132449b6a56b91aa6db9e9b1c386517
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7faf95166293b65f0c348417520b590b89cffcce6f2be19684398c9d313393a8405aeabbde0855e770a06a858c8684f298ec0123b60c75ff187dbf735be871b1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d570463290c9ad88b480a88d593ec430
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d66c7b423723ecef0cd281ba143fb8a67b8730d30db25df8f9f1e4dc7e615bd0ea590b04e89c94fb6d5be9cc5017e537b03e3888d5a5f327d7e35694992669ed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11f531921e5311f55d98b7088ab1914a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ab871eaa4eb1f54d5ecf6675e8bef11976fe7fe2eb93a5ad3c918fa401f7fd1562ca09b592a86c4919627f9cf10650b40fb80d706a43d3e212c39985e819b862
1 change: 1 addition & 0 deletions deps/checksums/Zlib.v1.2.11-3.i686-linux-gnu.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
83e87e8f40bf6ed602bcc47574cb25d6
1 change: 1 addition & 0 deletions deps/checksums/Zlib.v1.2.11-3.i686-linux-gnu.tar.gz/sha512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
801c1795ddadd8c6fd340a0854c3245e68cabb39225a75b747f674e466b70fa44afbdb9db01f45f165b56e62f9869dfd28072c4b8530f9c4eaa664baddb8b813
1 change: 1 addition & 0 deletions deps/checksums/Zlib.v1.2.11-3.i686-linux-musl.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bdc858aa86b135f1bb25466a1d725a1f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c1c6585f4e5a042de0d7d0de6d46149a4befd861c9664abdb049220d882c5e894b7a63483598656c5b9564bfccf01063d8689bda230f251e0dd519ab82494392
1 change: 1 addition & 0 deletions deps/checksums/Zlib.v1.2.11-3.i686-w64-mingw32.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5c8b8ae739dfe3bb6e5c07908e760924
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4e3c336333413a1916a281a107ab8d252837a6e3b80cdcbc855c1ef2400576a80cbc66bf6f58ca45209926a1347db9854928e161006557239d080496089a0e15
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dcf64207e69f152de7ed27ff17990e92
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
505d2a54063325ea88cd14c85f6caaa18c4f2bfa91ea4dbf8f4b461cdfca4a75424d198b1d54ae4e45505fec7ae20128c054dcef8a263c852ed6e3d0eebf62fb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4bac35015bfc195e0a7e55baf40e8baa
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
60f959b1f77eeb5f8ed9e94e3ec300b0e23ea90feb67255956257aaddcb1b0ed65ed6d26deacb9b4b5337a757f5e4e2a7ef37d5534432975dbdcac36e63e33a9
1 change: 1 addition & 0 deletions deps/checksums/Zlib.v1.2.11-3.x86_64-linux-gnu.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5e584cf6cbeac6c4c3d9157fb9cf1c8a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2498c7dae82060c9c90dbd4e2d213ff49996d438abd1d47349ff5154fa1917cb082e10481e8eae61b047d29d014052b6fa7a647990eb16dc6a5111afd83bb155
1 change: 1 addition & 0 deletions deps/checksums/Zlib.v1.2.11-3.x86_64-linux-musl.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
61d1dafed4ea486f317e332e84059b68
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3761830c2c67b2e30c484dba487fb7a35d2a8eb0cd64da726f2a73bb2ab789215db02c292b43832d4ad4cd22165a9e63a11b3c9c7710188faf5c3b6a0ee9ec09
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3a88149d4bca1386d467e2317d483901
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
83d65ec48ed89dcdbc3fa3a70c3f859619ae980cdd457408fd4b9f01fbbecc6987a0156a2ab6dfe25c5a41a7b2a5647baa79a69d0b29ca50d0906270dd1effb6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f4ace8b649c3fc186421c5fd67503e39
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
04eefb7fe95725672db39e37a7b0c791456e0df6c58ac9e291bf9f02f50aac103e43879b1befe6ba3bf8ca11a1ff1ec4647ab40105594b17a0a5d67059b46670
1 change: 1 addition & 0 deletions deps/checksums/p7zip-16.2.0.tar.bz2/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a0128d661cfe7cc8c121e73519c54fbf
1 change: 1 addition & 0 deletions deps/checksums/p7zip-16.2.0.tar.bz2/sha512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d2c4d53817f96bb4c7683f42045198d4cd509cfc9c3e2cb85c8d9dc4ab6dfa7496449edeac4e300ecf986a9cbbc90bd8f8feef8156895d94617c04e507add55f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
97011a65a2d0fafd74e81bc3445654dc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9de77aab797e8c9a1785e121a1a33d0f007f58529b2107b181a22f1032f836e374a937214c0cabf72bb1f8ca32b70b71e3e1a12d895b301cdfe35ac3ba1fcb10
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
90d4ebc185099fd1425607bc18118df2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aa2d6c285076de80e1f0b91860bdee7dfba7074f8abd5a95b8a9d66a8419b2a0ed5f835daeb3dc2a23c5ba33edb451710cc4aa8998005fc40536a5950c65d635
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3e170698971fbe88c72933f1b5040588
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5a1026a5540a40ec6b5b7cbf1660cca7b6b8b50693b7737ced333e137e7a881c7eb0f1d0f4b3f82d92c07b7fec754375caabd1399196bde731bc9505cd1c5ada
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
da71ac0e0a16b11fca6953b8dbaf921c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7655a1501ea4fea55165945da394f8aad366b453d2da00f585eeebfb9cc2e421545f3bfabbc5eb7b9859d6470a9d652a0503f2bdbfcd72f94553e149b11ff92d
1 change: 1 addition & 0 deletions deps/checksums/p7zip.v16.2.0-1.i686-linux-gnu.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
951385b34aba01cdcef4e07e66942951
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2d655e6d3d5d26bed81817bfbcece8084bfcbf4fc5e491c6ebec72490ccca4db72cc1f962a3ef5ceab5c5abe2cc4e9b9e9524d25c158ed8af32b6aff4b722d00
1 change: 1 addition & 0 deletions deps/checksums/p7zip.v16.2.0-1.i686-linux-musl.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4e005a19cef586bc407953a0d03caf6d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6c55576e1f3907435fea1aa6db0c124dee155ab1dac6cdf72ebe1ad4380bcd585d0a8d755b86621a498c63a95523dbf56053076c3f7398e6c0411db0fc1099be
1 change: 1 addition & 0 deletions deps/checksums/p7zip.v16.2.0-1.i686-w64-mingw32.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a193ac18bf72645e8132c0303d285aab
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eb82dd1b1cbacd76b2440a73b3c2a3167d5c8e88afddd27e0912f4d43d21040112a130f32efbe8af978dda5f698310e5253091c2b144b50384117e362d711256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
33ee9c368767a7dc4ecc176b107a1344
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2f801688be550705f10061e1be92c53a4388c90138159763ab63835730fb794cea54928dd3da72d203fcfc047ecf4c6b10644f914c849436058013e24381126d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dbcfff4fd3ee79040fcee45ad70e8115
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
66ca063b9b7ffb1e36db3fb71de7ef0a0b22782dabafa1b7f6ba89dd7931bcb4491920cf77970c3ebc2f14741ce21c3c28e7c8ae57ad14d6c2dc54676f853177
1 change: 1 addition & 0 deletions deps/checksums/p7zip.v16.2.0-1.x86_64-linux-gnu.tar.gz/md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e4ba040e655fc4a82a16e41620171233
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fdc322926de636060699daf87dd69003e092a10cc7125a0963a94fa588f0af9562dd5da2adcf6aa4fdf74e1c01ab46c25ff5e36c6f5665a1781a8b8240ac5624
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14875b7aa0e3d6a6c8773dce64abdcb2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9cbadcc3b52ec36c9885c04156ec6521d4959f5de78afc0ed867c308ad33994da4fa39ec63f455403587e8b21c6269f1c88c98980744628c4a37470693012e81
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6fff391800713934b3f008906349ddb2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
887feb7e197c7cdf3ec65a8fde1809c2c82500b6ddf8a114400ace9bbbd9cb22fc947d3397ae189b6c5d76b55fc4b98c39e02aec298edcdeca997115828af080
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1732e69ed7e9d5201637421c7dad93cd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8354d68e07e77d0f9679f5daa27a373013b6edefaafff070629ca260a001f1160850637563f16419f37a59fb397b3b273ca4293bc38a72371feff1ecd17c2fc1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
93d10d4dd040f14ae63417070d1346e8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a1e9c5a2963266a582192d0fe88c179f5239245f11c4df4427dda755ad77d31e1fcf045d7d3fe49141090f4ff8da13d9a2e8d8d317fe6460a5f3e9bdea29b883
61 changes: 61 additions & 0 deletions deps/p7zip.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## p7zip ##

ifneq ($(USE_BINARYBUILDER_P7ZIP),1)
# Force optimization for P7ZIP flags (Issue #11668)
$(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.bz2: | $(SRCCACHE)
$(JLDOWNLOAD) $@ https://downloads.sourceforge.net/project/p7zip/p7zip/16.02/p7zip_16.02_src_all.tar.bz2

$(BUILDDIR)/p7zip-$(P7ZIP_VER)/source-extracted: $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.bz2
$(JLCHECKSUM) $<
mkdir -p $(dir $@)
cd $(dir $@) && $(TAR) --strip-components 1 -jxf $<
echo $1 > $@

$(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-12-CVE-2016-9296.patch-applied: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/source-extracted
cd $(dir $@) && patch -p1 -f < $(SRCDIR)/patches/p7zip-12-CVE-2016-9296.patch
echo 1 > $@

$(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-13-CVE-2017-17969.patch-applied: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-12-CVE-2016-9296.patch-applied
cd $(dir $@) && patch -p1 -f < $(SRCDIR)/patches/p7zip-13-CVE-2017-17969.patch
echo 1 > $@

$(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-15-Enhanced-encryption-strength.patch-applied: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-13-CVE-2017-17969.patch-applied
cd $(dir $@) && patch -p4 -f < $(SRCDIR)/patches/p7zip-15-Enhanced-encryption-strength.patch
echo 1 > $@

$(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-configured: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-15-Enhanced-encryption-strength.patch-applied
$(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-compiled: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-configured
$(MAKE) -C $(dir $<) $(MAKE_COMMON) CC="$(CC)" CXX="$(CXX)" 7za
echo 1 > $@

define P7ZIP_INSTALL
mkdir -p $2/$$(build_bindir)
cp -a $1/bin/7za $2/$$(build_bindir)/7z
endef
$(eval $(call staged-install, \
p7zip,p7zip-$(P7ZIP_VER), \
P7ZIP_INSTALL,,,))

clean-p7zip:
-rm $(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-configured $(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-compiled
-rm $(build_bindir)/7za
-$(MAKE) -C $(BUILDDIR)/p7zip-$(P7ZIP_VER) clean

distclean-p7zip:
-rm -rf $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.bz2 $(SRCCACHE)/p7zip-$(P7ZIP_VER) $(BUILDDIR)/p7zip-$(P7ZIP_VER)


get-p7zip: $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.bz2
extract-p7zip: $(SRCCACHE)/p7zip-$(P7ZIP_VER)/source-extracted
configure-p7zip: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-configured
compile-p7zip: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-compiled
fastcheck-p7zip: check-p7zip
check-p7zip: compile-p7zip


else # USE_BINARYBUILDER_P7ZIP
P7ZIP_BB_URL_BASE := https://github.com/JuliaBinaryWrappers/p7zip_jll.jl/releases/download/p7zip-v$(P7ZIP_VER)+$(P7ZIP_BB_REL)
P7ZIP_BB_NAME := p7zip.v$(P7ZIP_VER)
$(eval $(call bb-install,p7zip,P7ZIP,false))

endif
23 changes: 23 additions & 0 deletions deps/patches/p7zip-12-CVE-2016-9296.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
From: Robert Luberda <[email protected]>
Date: Sat, 19 Nov 2016 08:48:08 +0100
Subject: Fix nullptr dereference (CVE-2016-9296)

Patch taken from https://sourceforge.net/p/p7zip/bugs/185/
---
CPP/7zip/Archive/7z/7zIn.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp
index b0c6b98..7c6dde2 100644
--- a/CPP/7zip/Archive/7z/7zIn.cpp
+++ b/CPP/7zip/Archive/7z/7zIn.cpp
@@ -1097,7 +1097,8 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
if (CrcCalc(data, unpackSize) != folders.FolderCRCs.Vals[i])
ThrowIncorrect();
}
- HeadersSize += folders.PackPositions[folders.NumPackStreams];
+ if (folders.PackPositions)
+ HeadersSize += folders.PackPositions[folders.NumPackStreams];
return S_OK;
}

35 changes: 35 additions & 0 deletions deps/patches/p7zip-13-CVE-2017-17969.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From: =?utf-8?q?Antoine_Beaupr=C3=A9?= <[email protected]>
Date: Fri, 2 Feb 2018 11:11:41 +0100
Subject: Heap-based buffer overflow in 7zip/Compress/ShrinkDecoder.cpp

Origin: vendor, https://sourceforge.net/p/p7zip/bugs/_discuss/thread/0920f369/27d7/attachment/CVE-2017-17969.patch
Forwarded: https://sourceforge.net/p/p7zip/bugs/_discuss/thread/0920f369/#27d7
Bug: https://sourceforge.net/p/p7zip/bugs/204/
Bug-Debian: https://bugs.debian.org/888297
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2017-17969
Reviewed-by: Salvatore Bonaccorso <[email protected]>
Last-Update: 2018-02-01
Applied-Upstream: 18.00-beta
---
CPP/7zip/Compress/ShrinkDecoder.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/CPP/7zip/Compress/ShrinkDecoder.cpp b/CPP/7zip/Compress/ShrinkDecoder.cpp
index 80b7e67..ca37764 100644
--- a/CPP/7zip/Compress/ShrinkDecoder.cpp
+++ b/CPP/7zip/Compress/ShrinkDecoder.cpp
@@ -121,8 +121,13 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *
{
_stack[i++] = _suffixes[cur];
cur = _parents[cur];
+ if (cur >= kNumItems || i >= kNumItems)
+ break;
}
-
+
+ if (cur >= kNumItems || i >= kNumItems)
+ break;
+
_stack[i++] = (Byte)cur;
lastChar2 = (Byte)cur;

Loading

0 comments on commit bbf7310

Please sign in to comment.