diff --git a/debian/control b/debian/control index 2f585d6b..c47bf3ab 100644 --- a/debian/control +++ b/debian/control @@ -37,6 +37,7 @@ Depends: build-essential, cowbuilder, devscripts, dpkg-dev, + eatmydata, fakeroot, file, git-buildpackage, diff --git a/examples/debian_glue b/examples/debian_glue index 70e9ef5f..616a7908 100644 --- a/examples/debian_glue +++ b/examples/debian_glue @@ -94,3 +94,14 @@ # ADT_RUNNER="adt-virt-qemu /srv/adt-${distribution:-}-${architecture:-}.img" # Default: # ADT= + +# Control usage of eatmydata to speed up builds. If eatmydata is present on the +# host system and when building for a recent distribution (Debian/jessie + +# Ubuntu/vivid or newer) eatmydata is enabled automatically. +# To force its usage (skipping any host + distribution checks) set it to 'true'. +# To disable its usage set it to 'false'. +# USE_EATMYDATA=true + +# Enable ccache (compiler cache for fast recompilation of C/C++ code) +# to speed up builds. +# USE_CCACHE=true diff --git a/scripts/build-and-provide-package b/scripts/build-and-provide-package index 6adf20a8..6683afa7 100755 --- a/scripts/build-and-provide-package +++ b/scripts/build-and-provide-package @@ -270,6 +270,9 @@ cowbuilder_init() { echo "USENETWORK=yes" >> "$pbuilderrc" fi + use_eatmydata + use_ccache + # allow setting main pbuilder configuration file from outside, then append data # as needed without actually writing anything to user-provided $PBUILDER_CONFIG if [ -n "${PBUILDER_CONFIG:-}" ] ; then @@ -518,6 +521,48 @@ autopkg_run() { adt-run --changes $changes_file ${ADT_OPTIONS:-} --- $ADT_RUNNER || bailout $? } +use_ccache() { + if [ "${USE_CCACHE:-}" = 'true' ] ; then + echo "*** USE_CCACHE is set to true, enabling ccache support ***" + echo 'CCACHEDIR="/var/cache/pbuilder/ccache"' >> "$pbuilderrc" + fi +} + +enable_eatmydata() { + echo 'EXTRAPACKAGES="$EXTRAPACKAGES eatmydata"' >> "$pbuilderrc" + echo 'export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}libeatmydata.so"' >> "$pbuilderrc" +} + +use_eatmydata() { + if [ "${USE_EATMYDATA:-}" = 'false' ] ; then + echo "*** eatmydata is disabled via USE_EATMYDATA [$USE_EATMYDATA] ***" + return 0 + fi + + if [ "${USE_EATMYDATA:-}" = 'true' ] ; then + echo "*** eatmydata is enabled via USE_EATMYDATA [$USE_EATMYDATA], forcing usage (skipping host/distribution checks) ***" + enable_eatmydata + else + if ! dpkg-query --show --showformat='${Status}' eatmydata | grep -q '^install' ; then + echo "*** eatmydata missing on host system, not considering for usage (force via USE_EATMYDATA=true) ***" + else + echo "*** eatmydata is present on host system, now checking distribution support ***" + case "${COWBUILDER_DIST}" in + etch|lenny|squeeze|wheezy) + echo "*** Debian release $COWBUILDER_DIST doesn't provide eatmydata >=82-6, skipping eatmydata ***" + ;; + warty|hoary|breezy|dapper|edgy|feisty|gutsy|hardy|intrepid|jaunty|karmi|lucid|maverick|natty|oneiric|quantal|raring|saucy|utopic|precise|trusty) + echo "*** Ubuntu release $COWBUILDER_DIST doesn't provide eatmydata >=82-6, skipping eatmydata ***" + ;; + *) + echo "*** Distribution ${COWBUILDER_DIST} should provide recent eatmydata support, enabling eatmydata ***" + enable_eatmydata + ;; + esac + fi + fi +} + autopkgtest_results() { if [ -n "${SKIP_AUTOPKGTEST_RESULTS:-}" ] ; then echo "** Skipping autopkgtest_results as requested via SKIP_AUTOPKGTEST_RESULTS ***" @@ -602,6 +647,9 @@ EOF echo "USENETWORK=yes" >> "$pbuilderrc" fi + use_eatmydata + use_ccache + # allow setting main pbuilder configuration file from outside, then append data # as needed without actually writing anything to user-provided $PBUILDER_CONFIG if [ -n "${PBUILDER_CONFIG:-}" ] ; then