Skip to content

Commit

Permalink
Support eatmydata (automatically enabled if host + distribution needs…
Browse files Browse the repository at this point in the history
… match) + ccache

eatmydata support gets enabled by default if it's installed on
the host system and when building for a recent Debian/Ubuntu
version (Debian/jessie + Ubuntu/vivid or newer). Usage can be
forced via USE_EATMYDATA=true and disabled via
USE_EATMYDATA=false.

ccache support can be enabled via USE_CCACHE=true

Thanks to Franco (nextime) Lanza for the initial patch in
#125
  • Loading branch information
Michael Prokop committed Aug 28, 2015
1 parent d243f8f commit 220f87e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Depends: build-essential,
cowbuilder,
devscripts,
dpkg-dev,
eatmydata,
fakeroot,
file,
git-buildpackage,
Expand Down
11 changes: 11 additions & 0 deletions examples/debian_glue
Original file line number Diff line number Diff line change
Expand Up @@ -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
48 changes: 48 additions & 0 deletions scripts/build-and-provide-package
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ***"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 220f87e

Please sign in to comment.