1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
#!/bin/sh
set -e
# Overridable environment variables for uploading.
RESTRICTED_SSH=
SSHKEY=
SSHKEY=${SSHKEY:+-i $SSHKEY}
if [ -z "$HOST" ]; then
HOST=people.debian.org
fi
if [ -z "$BASEDIR" ]; then
# Please don't change this. If you need it to be something else,
# override the variable.
BASEDIR=public_html/d-i/images
fi
if [ -z "$DIR" ]; then
DIR=$(date -u '+%Y%m%d-%H:%M')
fi
if [ "$HOST" = "local" ]; then
SYNC="rsync"
SYNC_BASEDIR="$BASEDIR"
HELPER=d-i-unpack-helper
else
CALL="ssh $SSHKEY $HOST"
SYNC="rsync"
SYNC_BASEDIR="$HOST:$BASEDIR"
# trade performance (using rsync) for security (restricted ssh keys)
HELPER="ssh $SSHKEY $HOST d-i-unpack-helper"
fi
if [ -z "$NUM_KEEP" ]; then
# Default to keeping 30 days of builds. Set to zero to keep all.
NUM_KEEP=30
fi
# Overridable environment variables for building.
if [ -z "$ROOTCMD" ]; then
ROOTCMD="fakeroot"
fi
# Internal environment variables to keep file attributes between targets
# when fakeroot is used.
# As we start with an empty file, we can use -i also on first invocation.
ROOTCMDOPTS=""
if [ "$ROOTCMD" = fakeroot ]; then
FRSAVE="$(mktemp -t d-i_daily-build.XXXXXX)"
trap 'rm -f $FRSAVE' 0 HUP INT QUIT TERM
ROOTCMDOPTS="-i $FRSAVE -s $FRSAVE"
fi
overview () {
LANG=C echo "$(dpkg --print-architecture) ($(date)) $(whoami)@$(hostname | cut -d . -f 1) $1" >> dest/overview.log
}
header () {
echo
echo $@
echo
}
build () {
unset LANG LC_ALL LANGUAGE || true
# Override $TARGETS with custom makefile targets.
if [ -z "$TARGETS" ]; then
TARGETS="$($ROOTCMD make all_list | grep '^build')"
fi
$ROOTCMD make reallyclean > /dev/null
mkdir dest
touch dest/overview.log
# Save file attributes within this loop if fakeroot is used
for t in $TARGETS; do
header BUILDING IMAGE FOR $t > dest/$t.log
if $ROOTCMD $ROOTCMDOPTS make $t >> dest/$t.log 2>&1; then
overview "$t success"
else
overview "$t failed"
echo "building $t failed, see log file dest/$t.log for details" >&2
fi
done
$ROOTCMD make stats > dest/stats.txt 2>&1 || true
make release > /dev/null
}
upload () {
(
header UPLOADING FILES
if [ -n "$RESTRICTED_SSH" ]; then
tar zcvf - -C dest/ . | $HELPER
else
$CALL mkdir -p $BASEDIR/${DIR}_RSYNC_IN_PROGRESS
$CALL test ! -d $BASEDIR/daily || $CALL cp -a $BASEDIR/daily/* $BASEDIR/${DIR}_RSYNC_IN_PROGRESS/
$SYNC --stats -rvl --safe-links --delete --rsh="ssh $SSHKEY" dest/ $SYNC_BASEDIR/${DIR}_RSYNC_IN_PROGRESS/
$CALL rm -rf $BASEDIR/$DIR
$CALL mv $BASEDIR/${DIR}_RSYNC_IN_PROGRESS $BASEDIR/$DIR
$CALL rm -rf $BASEDIR/daily
$CALL ln -sf $DIR $BASEDIR/daily
fi
) > dest/upload.log 2>&1
}
trim () {
(
header TRIMMING OLD BUILDS
if [ -n "$RESTRICTED_SSH" ]; then
echo "(trim not implemented for RESTRICTED_SSH mode)"
elif [ -n "$NUM_KEEP" ] && [ "$NUM_KEEP" != 0 ]; then
$CALL find $BASEDIR -maxdepth 1 | egrep '/[0-9][0-9][0-9][0-9]+-?[0-9][0-9]-?[0-9][0-9]-?[0-9]*:?[0-9]*$' | \
sort -n | ./util/trim-daily-builds "$NUM_KEEP" | \
$CALL xargs rm -rf
else
echo "(keeping all old builds)"
fi
) > dest/trim.log 2>&1
}
UPDATED=""
update () {
if [ ! "$UPDATED" ]; then
(cd ../debian && svn -q up || true)
svn -q up || true
UPDATED=1
fi
}
deps () {
temp=`LANG=C dpkg-checkbuilddeps -B ../debian/control 2>&1`
packages=`echo $temp | sed -e 's%dpkg-checkbuilddeps: Unmet build dependencies: %%'`
apt-get update
if [ "$packages" ]; then
DEBCONF_PRIORITY=critical apt-get -y install $packages
fi
DEBCONF_PRIORITY=critical apt-get -y upgrade
}
usage () {
echo These subcommands are available:
awk -F\) '/subcommand$/ { print " ", $1 }' $0
echo
}
if [ ! -d pkg-lists ]; then
echo "You must run this from the build directory"
exit 1
fi
case $1 in
build) # subcommand
update
build
;;
upload) # subcommand
upload
;;
trim) # subcommand
trim
;;
'') # no subcommand, for backwards compatability
update
build
upload
trim
;;
all) # subcommand
update
build
upload
trim
;;
update) # subcommand
update
;;
deps) # subcommand
deps
;;
*)
echo $1 is not a valid subcommand.
usage
exit 1
;;
esac
|