2010-11-14 14:13:48 -01:00
|
|
|
# Common handy shell script functions
|
|
|
|
|
2012-07-06 00:30:17 +00:00
|
|
|
l=/var/run/reboot-lock
|
|
|
|
|
|
|
|
reboot_lock () {
|
|
|
|
exec 3<$l
|
|
|
|
if ! flock --shared -w 0 3; then
|
|
|
|
echo 2>&1 "Cannot acquire reboot lock."
|
|
|
|
#exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
reboot_unlock () {
|
|
|
|
flock --shared -u 3
|
|
|
|
}
|
|
|
|
|
2010-11-14 14:13:48 -01:00
|
|
|
now () {
|
|
|
|
date -u +%F:%H:%M:%S
|
|
|
|
}
|
|
|
|
|
2012-07-06 00:30:17 +00:00
|
|
|
build_description () {
|
|
|
|
case $1 in
|
2013-04-30 18:54:11 +00:00
|
|
|
NI)
|
|
|
|
DESC="Netinst CD";;
|
2015-04-20 11:41:47 +00:00
|
|
|
MACNI)
|
|
|
|
DESC="Mac Netinst CD";;
|
2012-07-06 00:30:17 +00:00
|
|
|
CD)
|
|
|
|
DESC="Full CD";;
|
|
|
|
DVD)
|
|
|
|
DESC="Full DVD";;
|
|
|
|
BD)
|
|
|
|
DESC="Blu-ray";;
|
|
|
|
DLBD)
|
|
|
|
DESC="Dual-layer Blu-ray";;
|
2015-04-20 11:41:47 +00:00
|
|
|
KDECD)
|
2012-07-06 00:30:17 +00:00
|
|
|
DESC="KDE CD";;
|
2015-04-20 11:41:47 +00:00
|
|
|
GNOMECD)
|
|
|
|
DESC="GNOME CD";;
|
2012-07-06 00:30:17 +00:00
|
|
|
LIGHTCD)
|
|
|
|
DESC="XFCE/lxde CD";;
|
2013-01-20 00:03:24 -01:00
|
|
|
XFCECD)
|
|
|
|
DESC="XFCE CD";;
|
|
|
|
LXDECD)
|
|
|
|
DESC="lxde CD";;
|
2012-07-06 00:30:17 +00:00
|
|
|
*)
|
|
|
|
DESC="UNKNOWN";;
|
|
|
|
esac
|
|
|
|
echo "$DESC"
|
|
|
|
}
|
|
|
|
|
2010-11-14 14:13:48 -01:00
|
|
|
calc_time () {
|
|
|
|
echo $1 $2 | awk '
|
|
|
|
{
|
|
|
|
split($1, start, ":")
|
|
|
|
start_time = (3600*start[2]) + (60*start[3]) + start[4]
|
|
|
|
split($2, end, ":")
|
|
|
|
end_time = (3600*end[2]) + (60*end[3]) + end[4]
|
|
|
|
# Cope with going to a new day; do not worry about more than 1 day!
|
|
|
|
if (start[1] != end[1]) { end_time += 86400 }
|
|
|
|
time_taken = end_time - start_time
|
|
|
|
hours = int(time_taken / 3600)
|
|
|
|
time_taken -= (hours * 3600)
|
|
|
|
minutes = int(time_taken / 60)
|
|
|
|
time_taken -= (minutes * 60)
|
|
|
|
seconds = time_taken
|
|
|
|
printf("%dh%2.2dm%2.2ds\n", hours, minutes, seconds)
|
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
build_started () {
|
|
|
|
export BUILDNAME=$1
|
|
|
|
BUILDS_RUNNING="$BUILDS_RUNNING $BUILDNAME"
|
|
|
|
export ${BUILDNAME}START=`now`
|
|
|
|
}
|
|
|
|
|
|
|
|
build_finished () {
|
|
|
|
ARCH="$1"
|
|
|
|
BUILDNAME="$2"
|
|
|
|
BUILDNAMESTART="${BUILDNAME}START"
|
|
|
|
start=${!BUILDNAMESTART}
|
|
|
|
|
|
|
|
. $PUBDIRJIG/$ARCH/$BUILDNAME-trace
|
|
|
|
|
|
|
|
time_spent=`calc_time $start $end`
|
|
|
|
echo " $ARCH $BUILDNAME build started at $start, ended at $end (took $time_spent), error $error"
|
|
|
|
if [ $error -ne 0 ] ; then
|
2012-07-06 00:30:17 +00:00
|
|
|
arch_error="$arch_error "$BUILDNAME"FAIL/$error/$end/$logfile"
|
2017-06-06 12:10:48 +00:00
|
|
|
fi
|
|
|
|
case $BUILDNAME in
|
|
|
|
*FIRMWARE*)
|
|
|
|
cp log/$logfile $PUBDIRJIG-firmware/$ARCH/$BUILDNAME.log
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
cp log/$logfile $PUBDIRJIG/$ARCH/$BUILDNAME.log
|
|
|
|
;;
|
|
|
|
esac
|
2010-11-14 14:13:48 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
catch_parallel_builds () {
|
|
|
|
# Catch parallel builds here
|
|
|
|
while [ "$BUILDS_RUNNING"x != ""x ] ; do
|
|
|
|
BUILDS_STILL_RUNNING=""
|
|
|
|
for BUILDNAME in $BUILDS_RUNNING; do
|
|
|
|
if [ -e $PUBDIRJIG/$arch/$BUILDNAME-trace ] ; then
|
|
|
|
build_finished $arch $BUILDNAME
|
|
|
|
else
|
|
|
|
BUILDS_STILL_RUNNING="$BUILDS_STILL_RUNNING $BUILDNAME"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
BUILDS_RUNNING=$BUILDS_STILL_RUNNING
|
|
|
|
if [ "$BUILDS_RUNNING"x != ""x ] ; then
|
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ "$arch_error"x = ""x ] ; then
|
|
|
|
arch_error="none"
|
|
|
|
fi
|
|
|
|
arch_end=`now`
|
|
|
|
arch_time=`calc_time $arch_start $arch_end`
|
2015-04-20 11:41:47 +00:00
|
|
|
echo "$arch build started at $arch_start, ended at $arch_end (took $arch_time), error(s) $arch_error"
|
|
|
|
}
|
|
|
|
|
2019-02-19 17:05:47 -01:00
|
|
|
# Slightly complicated setup
|
|
|
|
# iso-* dirs have checksums for ISO files only
|
|
|
|
# bt-* dirs have checksums for ISO and torrrent files only
|
|
|
|
# jigdo-* dirs have checksums for ISO and jigdo files only
|
|
|
|
#
|
|
|
|
# Uses the imagesums tool from debian-cd to grab pre-calculated ISO
|
|
|
|
# checksums from the jigdo files where possible, to save a lot of time
|
2015-04-20 11:41:47 +00:00
|
|
|
generate_checksums_for_arch () {
|
|
|
|
ARCH=$1
|
|
|
|
JIGDO_DIR=$2
|
|
|
|
ISO_DIR=$(echo $JIGDO_DIR | sed 's,jigdo-,iso-,g')
|
2019-02-19 17:05:47 -01:00
|
|
|
BT_DIR=$(echo $JIGDO_DIR | sed 's,jigdo-,bt-,g')
|
2015-04-20 11:41:47 +00:00
|
|
|
|
2019-02-19 17:05:47 -01:00
|
|
|
# Do the torrents first, if they exist
|
|
|
|
if [ -e $BT_DIR ]; then
|
|
|
|
$TOPDIR/debian-cd/tools/imagesums $BT_DIR $EXTENSION > /dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Now do the jigdos, if they exist
|
|
|
|
if [ -e $JIGDO_DIR ]; then
|
|
|
|
$TOPDIR/debian-cd/tools/imagesums $JIGDO_DIR $EXTENSION > /dev/null
|
|
|
|
# And grep out the .iso checksums from there to the iso directory
|
|
|
|
for file in $JIGDO_DIR/*SUMS*${EXTENSION}; do
|
|
|
|
out=$ISO_DIR/$(basename $file)
|
|
|
|
grep \\.iso $file > $out
|
|
|
|
done
|
|
|
|
if [ -e $BT_DIR ]; then
|
|
|
|
# Ditto for the bt directory
|
|
|
|
for file in $JIGDO_DIR/*SUMS*${EXTENSION}; do
|
|
|
|
out=$BT_DIR/$(basename $file)
|
|
|
|
grep \\.iso $file >> $out
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# No jigdos, so do the ISOs by hand
|
|
|
|
$TOPDIR/debian-cd/tools/imagesums $ISO_DIR $EXTENSION > /dev/null
|
|
|
|
if [ -e $BT_DIR ]; then
|
|
|
|
for file in $ISO_DIR/*SUMS*${EXTENSION}; do
|
|
|
|
out=$BT_DIR/$(basename $file)
|
|
|
|
grep \\.iso $file >> $out
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
2015-04-20 11:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
catch_live_builds () {
|
2017-06-06 12:10:48 +00:00
|
|
|
# Catch parallel build types here
|
|
|
|
|
|
|
|
if [ "$NOLIVE"x = ""x ] && [ "$NOOPENSTACK"x = ""x ] ; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2015-04-20 11:41:47 +00:00
|
|
|
while [ ! -f $PUBDIRLIVETRACE ] || [ ! -f $PUBDIROSTRACE ] ; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
. $PUBDIROSTRACE
|
|
|
|
time_spent=`calc_time $start $end`
|
|
|
|
echo "openstack build started at $start, ended at $end (took $time_spent), error $error"
|
|
|
|
|
|
|
|
. $PUBDIRLIVETRACE
|
|
|
|
time_spent=`calc_time $start $end`
|
|
|
|
echo "live builds started at $start, ended at $end (took $time_spent), error $error"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
arch_has_firmware () {
|
|
|
|
arch=$1
|
|
|
|
for arch1 in $ARCHES_FIRMWARE; do
|
|
|
|
if [ "$arch" = "$arch1" ] ; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 1
|
2010-11-14 14:13:48 -01:00
|
|
|
}
|
2017-06-06 12:10:48 +00:00
|
|
|
|
|
|
|
get_archive_serial () {
|
|
|
|
trace_file="$MIRROR/project/trace/ftp-master.debian.org"
|
|
|
|
if [ -f "$trace_file" ]; then
|
|
|
|
awk '/^Archive serial: / {print $3}' "$trace_file"
|
|
|
|
else
|
|
|
|
echo 'unknown'
|
|
|
|
fi
|
|
|
|
}
|
2019-02-19 17:05:47 -01:00
|
|
|
|
|
|
|
rsync_to_pettersson () {
|
|
|
|
LOCAL=$1
|
|
|
|
REMOTE=$2
|
|
|
|
OPTIONS="$3"
|
|
|
|
rsync -az --delete $OPTIONS $LOCAL sync-to-pettersson:$REMOTE
|
|
|
|
}
|
|
|
|
|
|
|
|
publish_on_pettersson () {
|
|
|
|
TARGETS="$@"
|
|
|
|
echo "$TARGETS" | ssh publish-on-pettersson ./bin/receive_from_casulana
|
|
|
|
}
|
|
|
|
|