mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-18 12:21:28 +00:00
Merge branch 'ccache-support' of git+ssh://git.launchpad.net/~3v1n0/ubuntu-dev-tools
MR: https://code.launchpad.net/~3v1n0/ubuntu-dev-tools/+git/ubuntu-dev-tools/+merge/401817 Signed-off-by: Mattia Rizzolo <mattia@debian.org>
This commit is contained in:
commit
52032eb081
@ -87,6 +87,21 @@ aufs) mounts.
|
|||||||
Specify a \fBSCHROOT_TYPE\fR. Supported values are "\fBdirectory\fR"
|
Specify a \fBSCHROOT_TYPE\fR. Supported values are "\fBdirectory\fR"
|
||||||
(default if \fB\-\-vg\fR not specified), "\fBlvm-snapshot\fR" (default
|
(default if \fB\-\-vg\fR not specified), "\fBlvm-snapshot\fR" (default
|
||||||
if \fB\-\-vg\fR specified), "\fBbtrfs-snapshot\fR", and "\fBfile\fR".
|
if \fB\-\-vg\fR specified), "\fBbtrfs-snapshot\fR", and "\fBfile\fR".
|
||||||
|
.TP
|
||||||
|
.B \-\-ccache
|
||||||
|
Enable usage of \fBccache\fR by default. See \fBccache\fR (1) for
|
||||||
|
more details.
|
||||||
|
.TP
|
||||||
|
.B \-\-ccache-dir=\fIPATH
|
||||||
|
Use \fBPATH\fR as schroot ccache directory. This directory can be
|
||||||
|
safely shared by multiple schroots, but they will all use the same
|
||||||
|
\fBCCACHE_MAXSIZE\fR.
|
||||||
|
Defaults to /var/cache/ccache-sbuild.
|
||||||
|
See \fBccache\fR (1) for more details.
|
||||||
|
.TP
|
||||||
|
.B \-\-ccache-size=\fISIZE
|
||||||
|
Sets \fBSIZE\fR as the schroot \fBCCACHE_DIR\fR max-size used by ccache.
|
||||||
|
See \fBccache\fR (1) for more details.
|
||||||
|
|
||||||
.SH ENVIRONMENT VARIABLES
|
.SH ENVIRONMENT VARIABLES
|
||||||
.TP
|
.TP
|
||||||
@ -148,6 +163,18 @@ Use \fBSOURCE_CHROOTS_TGZ\fR as home of schroot source tarballs.
|
|||||||
.B CHROOT_SNAPSHOT_DIR
|
.B CHROOT_SNAPSHOT_DIR
|
||||||
Use \fBCHROOT_SNAPSHOT_DIR\fR as home of mounted btrfs snapshots.
|
Use \fBCHROOT_SNAPSHOT_DIR\fR as home of mounted btrfs snapshots.
|
||||||
(default \fB/var/lib/schroot/snapshots\fR)
|
(default \fB/var/lib/schroot/snapshots\fR)
|
||||||
|
.TP
|
||||||
|
.B CCACHE
|
||||||
|
Enable \fBccache\fR (1) by default.
|
||||||
|
(defaults to \fB0\fR)
|
||||||
|
.TP
|
||||||
|
.B CCACHE_DIR
|
||||||
|
Use \fBCCACHE_DIR\fR as the \fBccache\fR (1) directory.
|
||||||
|
(default \fB/var/cache/ccache-sbuild\fR)
|
||||||
|
.TP
|
||||||
|
.B CCACHE_SIZE
|
||||||
|
Use \fBCCACHE_SIZE\fR as the \fBccache\fR (1) max-size.
|
||||||
|
(defaults to \fB4G\fR)
|
||||||
|
|
||||||
|
|
||||||
.SH FILES
|
.SH FILES
|
||||||
|
109
mk-sbuild
109
mk-sbuild
@ -40,6 +40,8 @@ SOURCE_CHROOTS_DIR="/var/lib/schroot/chroots"
|
|||||||
SOURCE_CHROOTS_TGZ="/var/lib/schroot/tarballs"
|
SOURCE_CHROOTS_TGZ="/var/lib/schroot/tarballs"
|
||||||
CHROOT_SNAPSHOT_DIR="/var/lib/schroot/snapshots"
|
CHROOT_SNAPSHOT_DIR="/var/lib/schroot/snapshots"
|
||||||
SCHROOT_PROFILE="sbuild"
|
SCHROOT_PROFILE="sbuild"
|
||||||
|
CCACHE_DIR="/var/cache/ccache-sbuild"
|
||||||
|
CCACHE_SIZE="4G"
|
||||||
|
|
||||||
function usage()
|
function usage()
|
||||||
{
|
{
|
||||||
@ -64,6 +66,11 @@ function usage()
|
|||||||
echo " --debootstrap-no-check-gpg Disables checking gpg signatures of retrieved Release files"
|
echo " --debootstrap-no-check-gpg Disables checking gpg signatures of retrieved Release files"
|
||||||
echo " --skip-eatmydata Don't install and use eatmydata"
|
echo " --skip-eatmydata Don't install and use eatmydata"
|
||||||
echo " --eatmydata Install and use eatmydata (default)"
|
echo " --eatmydata Install and use eatmydata (default)"
|
||||||
|
echo " --ccache Install configure and use ccache as default"
|
||||||
|
echo " --ccache-dir=PATH Sets the CCACHE_DIR to PATH"
|
||||||
|
echo " (can be shared between all schroots, defaults to ${CCACHE_DIR})"
|
||||||
|
echo " --ccache-size=SIZE Sets the ccache max-size to SIZE"
|
||||||
|
echo " (shared by each CCACHE_DIR, defaults to ${CCACHE_SIZE})"
|
||||||
echo " --distro=DISTRO Install specific distro:"
|
echo " --distro=DISTRO Install specific distro:"
|
||||||
echo " 'ubuntu' or 'debian' "
|
echo " 'ubuntu' or 'debian' "
|
||||||
echo " (defaults to determining from release name)"
|
echo " (defaults to determining from release name)"
|
||||||
@ -91,6 +98,11 @@ function usage()
|
|||||||
echo " DEBOOTSTRAP_KEYRING GPG keyring (same as --debootstrap-keyring)"
|
echo " DEBOOTSTRAP_KEYRING GPG keyring (same as --debootstrap-keyring)"
|
||||||
echo " DEBOOTSTRAP_NO_CHECK_GPG Disable GPG verification (same as --debootstrap-no-check-gpg)"
|
echo " DEBOOTSTRAP_NO_CHECK_GPG Disable GPG verification (same as --debootstrap-no-check-gpg)"
|
||||||
echo " EATMYDATA Enable or disable eatmydata usage, see --eatmydata and --skip-eatmydata"
|
echo " EATMYDATA Enable or disable eatmydata usage, see --eatmydata and --skip-eatmydata"
|
||||||
|
echo " CCACHE Enable --ccache"
|
||||||
|
echo " CCACHE_DIR Path for ccache (can be shared between all schroots, "
|
||||||
|
echo " same as --ccache-dir, default ${CCACHE_DIR})"
|
||||||
|
echo " CCACHE_SIZE Sets the ccache max-size (shared by each CCACHE_DIR, "
|
||||||
|
echo " same as --ccache-size, default ${CCACHE_SIZE})"
|
||||||
echo " TEMPLATE_SOURCES A template for sources.list"
|
echo " TEMPLATE_SOURCES A template for sources.list"
|
||||||
echo " TEMPLATE_SCHROOTCONF A template for schroot.conf stanza"
|
echo " TEMPLATE_SCHROOTCONF A template for schroot.conf stanza"
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
@ -103,19 +115,48 @@ function usage()
|
|||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
OPTS=`getopt -o 'h' --long "help,debug,skip-updates,skip-security,skip-proposed,skip-eatmydata,arch:,name:,source-template:,debootstrap-mirror:,debootstrap-include:,debootstrap-exclude:,debootstrap-opts:,debootstrap-proxy:,debootstrap-no-check-gpg,debootstrap-keyring:,personality:,distro:,vg:,type:,target:" -- "$@"`
|
supported_options=(
|
||||||
|
help
|
||||||
|
debug
|
||||||
|
skip-updates
|
||||||
|
skip-security
|
||||||
|
skip-proposed
|
||||||
|
skip-eatmydata
|
||||||
|
ccache
|
||||||
|
arch:
|
||||||
|
name:
|
||||||
|
source-template:
|
||||||
|
debootstrap-mirror:
|
||||||
|
debootstrap-include:
|
||||||
|
debootstrap-exclude:
|
||||||
|
debootstrap-opts:
|
||||||
|
debootstrap-proxy:
|
||||||
|
debootstrap-no-check-gpg
|
||||||
|
debootstrap-keyring:
|
||||||
|
personality:
|
||||||
|
distro:
|
||||||
|
vg:
|
||||||
|
type:
|
||||||
|
target:
|
||||||
|
ccache-dir:
|
||||||
|
ccache-size:
|
||||||
|
)
|
||||||
|
OPTS=$(getopt -o 'h' --long "$(IFS=, && echo "${supported_options[*]}")" -- "$@")
|
||||||
eval set -- "$OPTS"
|
eval set -- "$OPTS"
|
||||||
|
|
||||||
VG=""
|
VG=""
|
||||||
DISTRO=""
|
DISTRO=""
|
||||||
|
COMMAND_PREFIX=""
|
||||||
name=""
|
name=""
|
||||||
proxy="_unset_"
|
proxy="_unset_"
|
||||||
DEBOOTSTRAP_NO_CHECK_GPG=0
|
DEBOOTSTRAP_NO_CHECK_GPG=0
|
||||||
EATMYDATA=1
|
EATMYDATA=1
|
||||||
|
CCACHE=0
|
||||||
|
|
||||||
while :; do
|
while :; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--debug)
|
--debug)
|
||||||
|
DEBUG=1
|
||||||
set -x
|
set -x
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
@ -191,6 +232,10 @@ while :; do
|
|||||||
EATMYDATA=0
|
EATMYDATA=0
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--ccache)
|
||||||
|
CCACHE=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--distro)
|
--distro)
|
||||||
DISTRO="$2"
|
DISTRO="$2"
|
||||||
shift 2
|
shift 2
|
||||||
@ -207,6 +252,14 @@ while :; do
|
|||||||
TARGET_ARCH="$2"
|
TARGET_ARCH="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
--ccache-dir)
|
||||||
|
CCACHE_DIR="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--ccache-size)
|
||||||
|
CCACHE_SIZE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
@ -403,6 +456,51 @@ if [ $EATMYDATA -eq 1 ]; then
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $CCACHE -eq 1 ]; then
|
||||||
|
if [ -z "$CCACHE_DIR" ] || [[ "$(dirname "$CCACHE_DIR")" == '/' ]]; then
|
||||||
|
echo "Invalid ccache dir: ${CCACHE_DIR}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# We can safely use a global cache path, in such case changing size applies
|
||||||
|
# to all the schroots
|
||||||
|
setup_script="$CCACHE_DIR"/mk-sbuild-setup
|
||||||
|
if [ -d "$CCACHE_DIR" ]; then
|
||||||
|
echo "Reusing $CCACHE_DIR as CCACHE_DIR, will be configured to use max-size=${CCACHE_SIZE}"
|
||||||
|
rm -f "$setup_script"
|
||||||
|
else
|
||||||
|
echo "Configuring $CCACHE_DIR as CCACHE_DIR with max-size=${CCACHE_SIZE}"
|
||||||
|
sudo install --group=sbuild --mode=2775 -d "$CCACHE_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$setup_script" ]; then
|
||||||
|
cat <<END | sudo tee "$setup_script" 1>/dev/null
|
||||||
|
#!/bin/sh
|
||||||
|
export CCACHE_DIR="$CCACHE_DIR"
|
||||||
|
export CCACHE_MAXSIZE="${CCACHE_SIZE}"
|
||||||
|
export CCACHE_UMASK=002
|
||||||
|
export CCACHE_COMPRESS=1
|
||||||
|
unset CCACHE_HARDLINK
|
||||||
|
export CCACHE_NOHARDLINK=1
|
||||||
|
export PATH="/usr/lib/ccache:\$PATH"
|
||||||
|
exec "\$@"
|
||||||
|
END
|
||||||
|
sudo chmod a+rx "$setup_script"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! sudo grep -qs "$CCACHE_DIR" /etc/schroot/sbuild/fstab; then
|
||||||
|
# This acts on host configuration, but there is no other way to handle
|
||||||
|
# this, however it won't affect anything
|
||||||
|
cat <<END | sudo tee -a /etc/schroot/sbuild/fstab 1>/dev/null
|
||||||
|
${CCACHE_DIR} ${CCACHE_DIR} none rw,bind 0 0
|
||||||
|
END
|
||||||
|
fi
|
||||||
|
|
||||||
|
DEBOOTSTRAP_INCLUDE="${DEBOOTSTRAP_INCLUDE:+$DEBOOTSTRAP_INCLUDE,}ccache"
|
||||||
|
BUILD_PKGS="$BUILD_PKGS ccache"
|
||||||
|
COMMAND_PREFIX="${COMMAND_PREFIX:+$COMMAND_PREFIX,}$setup_script"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$SCHROOT_TYPE" ]; then
|
if [ -z "$SCHROOT_TYPE" ]; then
|
||||||
# To build the LV, we need to know which volume group to use
|
# To build the LV, we need to know which volume group to use
|
||||||
if [ -n "$VG" ]; then
|
if [ -n "$VG" ]; then
|
||||||
@ -786,6 +884,11 @@ root-groups=$ADMIN_GROUPS
|
|||||||
type=SCHROOT_TYPE
|
type=SCHROOT_TYPE
|
||||||
profile=$SCHROOT_PROFILE
|
profile=$SCHROOT_PROFILE
|
||||||
EOM
|
EOM
|
||||||
|
if [ -n "$COMMAND_PREFIX" ]; then
|
||||||
|
cat >> "$TEMP_SCHROOTCONF" <<EOM
|
||||||
|
command-prefix=${COMMAND_PREFIX}
|
||||||
|
EOM
|
||||||
|
fi
|
||||||
case "$SCHROOT_TYPE" in
|
case "$SCHROOT_TYPE" in
|
||||||
"lvm-snapshot")
|
"lvm-snapshot")
|
||||||
cat >> "$TEMP_SCHROOTCONF" <<EOM
|
cat >> "$TEMP_SCHROOTCONF" <<EOM
|
||||||
@ -843,7 +946,9 @@ sudo chmod a+x "$MNT"/usr/sbin/policy-rc.d
|
|||||||
# Create image finalization script
|
# Create image finalization script
|
||||||
sudo bash -c "cat >> $MNT/finish.sh" <<EOM
|
sudo bash -c "cat >> $MNT/finish.sh" <<EOM
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#set -x
|
if [ "$DEBUG" = 1 ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
set -e
|
set -e
|
||||||
if [ -n "$proxy" ]; then
|
if [ -n "$proxy" ]; then
|
||||||
mkdir -p /etc/apt/apt.conf.d/
|
mkdir -p /etc/apt/apt.conf.d/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user