openvpn-build dep cache support
PATCH 1/1 openvpn-build dep cache support
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The attached patch allows the openvpn-build system to create and use cache tarballs for dependencies, preventing them from being built every time (even when they haven't changed.) My VM build time went from ~12 to under 2 minutes with this feature.
- --
Josh Cepek
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)
iQGcBAEBAgAGBQJSGQrIAAoJENcx2Xpgb9RjHOEL/jRDeXyguibzmFYP+n+oduA3 ICjpGrUwhnzTtwp/8i01vfo2YVVwgi1eC8qJmcCs4SOJXkq1ExB5KSPuwRrB0s3E w9Fv6yYcvXbNWKbhJtvqgLFxgHPYzYZ1TJLOGO9H37V4viTYxaqdQsb2e1ZFL53S fvWXqQThWRwzxRzAQGcCmtt2CyFNJRoI4+Tp3UWezyZxMQlJLqNNb7A7dIiZLXSh pg8USPoW5knBG0JomwjUKFPGV19OamBwgAA4s60RstK6v0JP+EnaqPh/KpCGMPeZ Hvz63wdtZoCLQRDD0tY/iYhlJESKf1PMDQwBKGZmM+K9gQCc2tUYONwy8PJeKzUY saMKsF8me2hEhORzV40i0DdIrLeKscJoP1smJsBS2NYeqkBUcTohTXefo9upei3u MuOkGK6NwMZPki+VT2O/NVMOwcgMzOuJeRPCsBFSs5zD1ZDzG31bou2YvD7QgBy4 Egw9M/Y+1xWoXtzLoOalfeKUpV0g+ki8wsvhCL6s3A==
=ckGN
-----END PGP SIGNATURE-----
From 70aae9ead2c016da95977a744b0a246f7ee2f40e Mon Sep 17 00:00:00 2001
From: Josh Cepek <[email protected]...>
Date: Sat, 24 Aug 2013 11:34:48 -0500
Subject: [PATCH] Support a dep cache when using the generic/build script
This feature takes the openssl, lzo, and pkcs11-helper dependency builds and creates a "depcache" tarball for each dep.
To generate the depcache, set SAVE_DEP_CACHE to a non-empty string. To use the depcache, set USE_DEP_CACHE the same way instead. Without either, the current build-all-deps behavior is maintained.
--- generic/build | 111 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 84 insertions(+), 27 deletions(-)
generic/build +84 -27
@@ -115,6 +115,10 @@ create_layout() { fi mkdir -p "${IMAGEROOT}" || die "Cannot create '${IMAGEROOT}'" mkdir -p "${BUILDROOT}" || die "Cannot create '${BUILDROOT}'" + mkdir -p "${OPENVPN_ROOT}" || die "Cannot create '${OPENVPN_ROOT}'" + if [ -n "${USE_DEP_CACHE}${SAVE_DEP_CACHE}" ]; then + mkdir -p "${DEPCACHEDIR}" || die "Cannot create '${DEPCACHEDIR}'" + fi BUILDROOT="$(get_full_path "${BUILDROOT}")" SOURCESROOT="$(get_full_path "${SOURCESROOT}")"
@@ -165,38 +169,82 @@ extract() { done } +# Takes a short product name (eg: 'openssl') and extracts the depcache. +depcache_extract() { + local src="${DEPCACHEDIR}/${1}.tar.gz" + [ -f "${src}" ] \ + || die "Depcache for '${1}' not found at: '${src}'" + tar -xzf "${src}" -C "${OPENVPN_ROOT}" \ + || die "Cannot extract depcache '${1}'" + [ -z "${2}" ] && echo "Using a depcache tarball for '${1}" +} + +# Takes a short product name (eg: 'openssl') and creates a depcache tarball. +depcache_save() { + local dst="${DEPCACHEDIR}/${1}.tar.gz" + (cd "${INSTALL_ROOT}" && tar -czf "${dst}" .) \ + || die "Cannot save depcache for '${1}' to: '${dst}'" + rm -fr "${INSTALL_ROOT}" \ + || die "Cleanup failed for: '${INSTALL_ROOT}'" + depcache_extract "${1}" noecho +} + build_dep() { - echo "Build openssl" - cd "${BUILDROOT}/openssl"* || die "cd openssl" - - ./Configure --prefix="/${TARGET_ROOT}" --cross-compile-prefix=${CHOST:+${CHOST}-} \ - $(empty_ifelse "${DO_STATIC}" shared no-dso) \ - $(CHOST="${VIRTUAL_CHOST}" "${SCRIPTROOT}/gentoo.config-0.9.8") \ - ${CFLAGS} ${LDFLAGS} \ - no-multilib \ - no-capieng \ - --openssldir=/etc/ssl \ - --libdir=/lib \ - ${EXTRA_OPENSSL_CONFIG} \ - || die "Configure openssl" - [ -n "${BUILD_FOR_WINDOWS}" ] && perl util/mkdef.pl crypto ssl NT update - [ -z "${OPENSSL_SKIP_DEPEND}" ] && ${MAKE} depend - ${MAKE} install INSTALL_PREFIX="${OPENVPN_ROOT}" INSTALLTOP="/" MANDIR="/tmp" \ - || die "make openssl" - rm -fr "${OPENVPN_ROOT}/tmp" + if [ -z "${SAVE_DEP_CACHE}" ]; then + INSTALL_ROOT="${OPENVPN_ROOT}" + else + INSTALL_ROOT="${DEPCACHEDIR}/fakeroot" + mkdir -p "${INSTALL_ROOT}" \ + || die "Cannot create depcache install root at: ${INSTALL_ROOT}'" + fi - fixup_la + if [ -n "${USE_DEP_CACHE}" ]; then + depcache_extract openssl + else + echo "Build openssl" + cd "${BUILDROOT}/openssl"* || die "cd openssl" + + ./Configure --prefix="/${TARGET_ROOT}" --cross-compile-prefix=${CHOST:+${CHOST}-} \ + $(empty_ifelse "${DO_STATIC}" shared no-dso) \ + $(CHOST="${VIRTUAL_CHOST}" "${SCRIPTROOT}/gentoo.config-0.9.8") \ + ${CFLAGS} ${LDFLAGS} \ + no-multilib \ + no-capieng \ + --openssldir=/etc/ssl \ + --libdir=/lib \ + ${EXTRA_OPENSSL_CONFIG} \ + || die "Configure openssl" + [ -n "${BUILD_FOR_WINDOWS}" ] && perl util/mkdef.pl crypto ssl NT update + [ -z "${OPENSSL_SKIP_DEPEND}" ] && ${MAKE} depend + ${MAKE} install INSTALL_PREFIX="${INSTALL_ROOT}" INSTALLTOP="/" MANDIR="/tmp" \ + || die "make openssl" + rm -fr "${INSTALL_ROOT}/tmp" + fixup_la + + [ -n "${SAVE_DEP_CACHE}" ] && depcache_save openssl + fi - echo "Build lzo" - cd "${BUILDROOT}/lzo"* || die "cd lzo" - ./configure ${CONFIGOPTS} ${EXTRA_LZO_CONFIG} \ - $(empty_ifelse "${DO_STATIC}" --enable-shared --disable-shared) \ - || die "Configure lzo" - ${MAKE} ${MAKEOPTS} ${MAKE_AUTOCONF_INSTALL_TARGET} DESTDIR="${OPENVPN_ROOT}" || die "make lzo" - fixup_la + if [ -n "${USE_DEP_CACHE}" ]; then + depcache_extract lzo + else + echo "Build lzo" + cd "${BUILDROOT}/lzo"* || die "cd lzo" + ./configure ${CONFIGOPTS} ${EXTRA_LZO_CONFIG} \ + $(empty_ifelse "${DO_STATIC}" --enable-shared --disable-shared) \ + || die "Configure lzo" + ${MAKE} ${MAKEOPTS} ${MAKE_AUTOCONF_INSTALL_TARGET} DESTDIR="${INSTALL_ROOT}" \ + || die "make lzo" + + fixup_la + + [ -n "${SAVE_DEP_CACHE}" ] && depcache_save lzo + fi if [ -z "${DO_STATIC}" ]; then + if [ -n "${USE_DEP_CACHE}" ]; then + depcache_extract pkcs11-helper + else echo "Build pkcs11-helper" cd "${BUILDROOT}/pkcs11-helper"* || die "cd pkcs11-helper" ./configure ${CONFIGOPTS} ${EXTRA_PKCS11_HELPER_CONFIG} \
@@ -205,7 +253,11 @@ build_dep() { OPENSSL_CFLAGS="${OPENSSL_CRYPTO_CFLAGS}" \ OPENSSL_LIBS="${OPENSSL_CRYPTO_LIBS}" \ || die "Configure pkcs11-helper" - ${MAKE} ${MAKEOPTS} ${MAKE_AUTOCONF_INSTALL_TARGET} DESTDIR="${OPENVPN_ROOT}" || die "make pkcs11-helper" + ${MAKE} ${MAKEOPTS} ${MAKE_AUTOCONF_INSTALL_TARGET} DESTDIR="${INSTALL_ROOT}" \ + || die "make pkcs11-helper" + + [ -n "${SAVE_DEP_CACHE}" ] && depcache_save pkcs11-helper + fi fi echo "tap-windows"
@@ -332,6 +384,11 @@ IMAGEROOT="${IMAGEROOT:-${SCRIPTROOT}/image}" BUILDROOT="${BUILDROOT:-${SCRIPTROOT}/tmp}" SOURCESROOT="${SOURCESROOT:-${SCRIPTROOT}/sources}" PATCHDIR="${SCRIPTROOT}/patches" +DEPCACHEDIR="${SCRIPTROOT}/depcache" + +# Cannot both use a depcache and save one: +[ -n "${USE_DEP_CACHE}" ] && [ -n "${SAVE_DEP_CACHE}" ] \ + && die "You cannot both use and save a depcache in the same run" . "${SCRIPTROOT}/build.vars" || die "Cannot source build.vars"
Signature · 1 line
1.8.1.2
Quoted 7 lines
The attached patch allows the openvpn-build system to create and use cache tarballs for dependencies, preventing them from being built every time (even when they haven't changed.) My VM build time went from ~12 to under 2 minutes with this feature.
Hi Josh,
This is a very welcome change - build errors that happen at the end of the build are currently _very_ annoying. The patch merged fine and I'm currently running some tests on it. If all goes well I'll push it to master.
Signature · 5 lines
Samuli Seppänen Community Manager OpenVPN Technologies, Inc irc freenode net: mattock
Quoted 7 lines
The attached patch allows the openvpn-build system to create and use cache tarballs for dependencies, preventing them from being built every time (even when they haven't changed.) My VM build time went from ~12 to under 2 minutes with this feature.
Hi Josh,
First of all sorry for the long delay.
I tested your patch today and encountered a build failure when using the dependency cache. The following command seems properly to generate dependency cache packages to openvpn-build/generic/depcache:
SAVE_DEP_CACHE=1 ./build-complete --sign --sign-pkcs12=<pkcs12-file> --sign-pkcs12-pass=<pkcs12-pass> --sign-timestamp="<timestamp-server>"
However, when I try to use the dependency cache I get a build failure:
USE_DEP_CACHE=1 ./build-complete --sign --sign-pkcs12=<pkcs12-file> --sign-pkcs12-pass=<pkcs12-pass> --sign-timestamp="<timestamp-server>"
--- snip ---
libtool: link: i686-w64-mingw32-gcc -I/home/samuli/openvpn-build/windows-nsis/tmp/image-i686/openvpn/include -I/home/samuli/openvpn-build/windows-nsis/tmp/image-i686/openvpn/include -I/home/samuli/openvpn-build/windows-nsis/tmp/image-i686/openvpn/include -I/home/samuli/openvpn-build/windows-nsis/tmp/image-i686/openvpn/include -I/home/samuli/openvpn-build/windows-nsis/tmp/image-i686/openvpn/include -municode -UUNICODE -o .libs/openvpn.exe base64.o buffer.o clinat.o crypto.o crypto_openssl.o crypto_polarssl.o dhcp.o error.o event.o
fdmisc.o forward.o fragment.o gremlin.o helper.o httpdigest.o lladdr.o init.o interval.o list.o lzo.o manage.o mbuf.o misc.o platform.o
console.o mroute.o mss.o mstats.o mtcp.o mtu.o mudp.o multi.o ntlm.o
occ.o pkcs11.o pkcs11_openssl.o pkcs11_polarssl.o openvpn.o options.o otime.o packet_id.o perf.o pf.o ping.o plugin.o pool.o proto.o proxy.o
ps.o push.o reliable.o route.o schedule.o session_id.o shaper.o sig.o socket.o socks.o ssl.o ssl_openssl.o ssl_polarssl.o ssl_verify.o ssl_verify_openssl.o ssl_verify_polarssl.o status.o tun.o win32.o cryptoapi.o openvpn_win32_resources.o
../../src/compat/.libs/libcompat.a -L/home/samuli/openvpn-build/windows-nsis/tmp/image-i686/openvpn/lib /home/samuli/openvpn-build/windows-nsis/tmp/image-i686/openvpn/lib/liblzo2.dll.a /home/samuli/openvpn-build/windows-nsis/tmp/image-i686/openvpn/lib/libpkcs11-helper.dll.a -L/home/samuli/openvpn-build/windows-nsis/tmp/image-x86_64/openvpn/lib -lssl -lcrypto -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -L/home/samuli/openvpn-build/windows-nsis/tmp/image-i686/openvpn/lib crypto_openssl.o:crypto_openssl.c:(.text+0x160): undefined reference to `_EVP_CipherInit'
crypto_openssl.o:crypto_openssl.c:(.text+0x18f): undefined reference to `_EVP_CipherUpdate'
crypto_openssl.o:crypto_openssl.c:(.text+0x1dc): undefined reference to `_ERR_clear_error'
crypto_openssl.o:crypto_openssl.c:(.text+0x219): undefined reference to `_OBJ_nid2sn'
crypto_openssl.o:crypto_openssl.c:(.text+0x221): undefined reference to `_EVP_get_cipherbyname'
crypto_openssl.o:crypto_openssl.c:(.text+0x239): undefined reference to `_OBJ_nid2sn'
crypto_openssl.o:crypto_openssl.c:(.text+0x250): undefined reference to `_EVP_CIPHER_flags'
crypto_openssl.o:crypto_openssl.c:(.text+0x269): undefined reference to `_EVP_CIPHER_flags'
crypto_openssl.o:crypto_openssl.c:(.text+0x287): undefined reference to `_EVP_CIPHER_key_length'
--- snip ---
If I don't use the dependency cache the build completes succesfully. Am I using the cache functionality the way it's supposed to?
Signature · 5 lines
Samuli Seppänen Community Manager OpenVPN Technologies, Inc irc freenode net: mattock
PATCH v2 1/1 depcache support for openvpn-build
In reply to Josh Cepek-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The original patch supported the generic/build script only, and used a single depcache. As noted earlier in this thread, this is incompatible with build-complete that loops through both the 32 & 64-bit Windows builds as the cache would have stored only the last-built depcache.
The full v2 patch is attached and allows for uniquely named caches, which build-complete leverages to store each arch's depcache in a separate dir. Full description in the attached patch.
To use with build-complete, build the initial depcache..
./build-complete --build-depcache`
..and then pass --use-depcache to build-complete on future runs.
- --
Josh Cepek
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)
iQGcBAEBAgAGBQJSaEk9AAoJENcx2Xpgb9Rj7ioL/idvudtJQuBTMf08nj/Bwzfd M+mqOS2cck9vXVzqkTZtP3MYCPJA1jmtsUoHx3yadZkZne6BmNy1GoDWqnb9lsrK JjG5Bmo8NfajgCGrey/BqsCbm0h3zNmzhS/FR4fr5hdmZx4m3reMots1YF564dHB i/+2TNQxm3ekNjmfY7Nic+UiAKDh8ZTHGUbNBx7VEnxHkupi8khtW5qyQdr4FaCI Aq2EuXO3lFk9nbwdhKWoMlSeuWOrTLz0/2SF2siZxW0CZLpVtJie7BBZG56anHi3 8/UQlI/pjqGJkZ5zcna0XWONK4p2tw/hwAT5AX+84fqyQhafnP5PjR2zZoMjIctM 8xe9UGLRw4EDnGq9qb5qIFBZW7vUZAn1WeYDyMLmBR9f7Xx4wj/1OUZ48DIU4PCM 8O5MZz9OVW9lD97p/NvnLeZ1XHRFSPeOLKvE03X8LDgBSP5kvmQGEsDhMT3MFc8c KlM+p+UoKbTGO/9rz0gSgiyXik03OFJCPeQOfV68CQ==
=fsLC
-----END PGP SIGNATURE-----
From 99e5fdf0cf142d656b3734ef36d728018278474a Mon Sep 17 00:00:00 2001
From: Josh Cepek <[email protected]...>
Date: Sat, 24 Aug 2013 11:34:48 -0500
Subject: [PATCH] Support a dep cache for both generic/build and build-complete
This feature takes the openssl, lzo, and pkcs11-helper dependency builds and creates a "depcache" tarball for each dep making it available for use in future builds without recompiling them.
build-complete has a high-level feature that can build or use a depcache with further docs in the updated README.
For the generic depcache support, a named depcache can be passed on the command-line to save or use the depcache for that run.
Advanced use via env-vars is also supported for environments that wish to use it via the SAVE_DEP_CACHE, USE_DEP_CACHE, and DEPCACHE_SUFFIX; note that this applies to the generic/build script only.
--- generic/README | 10 ++++ generic/build | 129 ++++++++++++++++++++++++++++++++++---------- windows-nsis/README | 25 +++++++++ windows-nsis/build-complete | 20 ++++++- 4 files changed, 156 insertions(+), 28 deletions(-)
generic/README +10 -0
@@ -77,3 +77,13 @@ Environment PKCS11_HELPER_VERSION LZO_VERSION OPENVPN_VERSION + + (depcache specific env-vars shown below. + Note that CLI-options exist; see `./build --help` for details.) + + USE_DEP_CACHE + SAVE_DEP_CACHE + define these to a nonzero string to enable (only 1 per run). + DEPCACHE_SUFFIX + an optional suffix to name the depcache. allows for multiple + independent depcache dirs to be used on different runs.
generic/build +102 -27
174 lines not on this page · raw message
windows-nsis/README +25 -0
@@ -48,3 +48,28 @@ Usage --sign-pkcs12=signingkey.p12\ --sign-pkcs12-pass=yourpassphrase\ --sign-timestamp="http://timestamp.domain.com" + +Depcache feature + + Much of the build time is spent building dependencies, + and a depcache feature can re-use deps once they're + initially built. This can dramatically cut down on the + time required to run builds when only OpenVPN-components + were changed. + + Note that using a depcache blindly unpacks whatever the + resulting build was, including that version and any + specific configure options. + + To create the initial depcache, first run: + + ./build-complete --build-depcache + + which will create a Windows-specific depcache for both + 32 & 64 bit builds. Once the depcache is created, future + builds can re-use them like this: + + ./build-complete --use-depcache + + These options take no values and the depcache dirs are + stored under the ../generic/ dir.
windows-nsis/build-complete +19 -1
@@ -21,8 +21,13 @@ main() { CHOST=${arch}-w64-mingw32 \ ../generic/build \ --special-build="${SPECIAL_BUILD}" \ + ${WIN_USE_DEPCACHE:+--use-depcache=win-$arch} \ + ${WIN_SAVE_DEPCACHE:+--save-depcache=win-$arch} \ || die "build ${arch}" + # Loop here if building the depcache: + [ -n "${DO_ONLY_DEPS}" ] && continue + ROOT="${TMPDIR}/installer" \ ./build \ --installer-version="${INSTALLER_VERSION}" \
@@ -39,7 +44,11 @@ main() { done echo - echo "NOTICE: OpenVPN Installers are at '${OUTPUT_DIR}'" + if [ -z "${DO_ONLY_DEPS}" ]; then + echo "NOTICE: OpenVPN Installers are at '${OUTPUT_DIR}'" + else + echo "NOTICE: depcache prepared for future use" + fi exit 0 }
@@ -75,6 +84,13 @@ while [ -n "$1" ]; do --output-dir=*) OUTPUT_DIR="${v}" ;; + --use-depcache) + WIN_USE_DEPCACHE=1 + ;; + --build-depcache) + WIN_SAVE_DEPCACHE=1 + export DO_ONLY_DEPS=1 + ;; --help|*) cat <<__EOF__ Usage: $0
@@ -85,6 +101,8 @@ Usage: $0 --sign-pkcs12-pass=password PKCS#12 file password --sign-timestamp=url URL to be used for timestamp --output-dir=output output directory + --use-depcache use a pre-existing depcache + --build-depcache create depcache only (no program build) --help this __EOF__ exit 1
Signature · 1 line
1.8.1.2