| 1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# Helper for image creation |
| 4 |
# |
| 5 |
|
| 6 |
# Pull in the core settings for all builds |
| 7 |
. settings.sh |
| 8 |
. weekly.sh |
| 9 |
. common.sh |
| 10 |
|
| 11 |
PUBDIRJIG=$1 |
| 12 |
RSYNC_TARGET=$2 |
| 13 |
ARCH=$3 |
| 14 |
|
| 15 |
HOSTNAME=`hostname -f` |
| 16 |
LOCK=~/iso_run.lock |
| 17 |
START=$(now) |
| 18 |
|
| 19 |
# Check to see if another sync is in progress |
| 20 |
if lockfile -! -l 43200 -r-1 "$LOCK"; then |
| 21 |
echo $HOSTNAME is not doing another iso_run, lock file $LOCK exists |
| 22 |
exit 1 |
| 23 |
fi |
| 24 |
trap "rm -f $LOCK > /dev/null 2>&1" exit |
| 25 |
|
| 26 |
COPY_START=$(now) |
| 27 |
|
| 28 |
# Poor man's rsync, but with some local optimisations |
| 29 |
copy_files() { |
| 30 |
SRC=$1 |
| 31 |
TARGET=$2 |
| 32 |
ARCHES=$3 |
| 33 |
|
| 34 |
echo "Copying files for $ARCHES from $SRC to $TARGET" |
| 35 |
|
| 36 |
DISKTYPES="cd dvd bd dlbd 16G" |
| 37 |
DIRTYPES="iso jigdo list" |
| 38 |
|
| 39 |
# Only make torrent files and dirs for release builds |
| 40 |
if [ "$RELEASE_BUILD"x != ""x ] ; then |
| 41 |
DIRTYPES="$DIRTYPES bt" |
| 42 |
fi |
| 43 |
|
| 44 |
CURRENT=`pwd` |
| 45 |
cd $SRC |
| 46 |
for ARCH in $ARCHES |
| 47 |
do |
| 48 |
for DISKTYPE in $DISKTYPES; do |
| 49 |
for DIRTYPE in $DIRTYPES; do |
| 50 |
if [ -d $ARCH/$DIRTYPE-$DISKTYPE ]; then |
| 51 |
mkdir -pv -m775 $TARGET/$ARCH.tmp/$DIRTYPE-$DISKTYPE |
| 52 |
fi |
| 53 |
done |
| 54 |
done |
| 55 |
|
| 56 |
# Copy the specific files across that we want in the |
| 57 |
# publishing dir |
| 58 |
cd $ARCH |
| 59 |
find . -name '*.jigdo' -o -name '*.template' \ |
| 60 |
-o -name '*.iso' \ |
| 61 |
-o -name '*.torrent' \ |
| 62 |
-o -name '*.list.gz' -o -name '*SUMS*' | \ |
| 63 |
xargs tar cf - | (cd $TARGET/$ARCH.tmp/ && tar xvf -) |
| 64 |
|
| 65 |
if [ "$RELEASE_BUILD"x = ""x ] ; then |
| 66 |
# Only populate the HEADER.html file for regular weekly |
| 67 |
# builds; we don't want it for releases |
| 68 |
HUM_DATE=`date -u` |
| 69 |
sed "s/ARCH/$ARCH/g;s/DATE/$HUM_DATE/g" ~/build.${CODENAME}/weekly.html \ |
| 70 |
> $TARGET/$ARCH.tmp/HEADER.html |
| 71 |
fi |
| 72 |
|
| 73 |
mkdir -pv $TARGET/$ARCH.tmp/log/$DATE |
| 74 |
echo "Copying logfiles from $PWD to $TARGET/$ARCH.tmp/log/$DATE:" |
| 75 |
cp -v $PWD/*.log $TARGET/$ARCH.tmp/log/$DATE |
| 76 |
ln -sfv $DATE $TARGET/$ARCH.tmp/log/success |
| 77 |
|
| 78 |
# Now clean up any directories without any real content |
| 79 |
# (i.e. empty dir, or just containing checksum files) |
| 80 |
for dir in $TARGET/$ARCH.tmp/*-* ; do |
| 81 |
num=`ls -l $dir | grep -v -e SUMS -e total | wc -l` |
| 82 |
if [ $num = 0 ] ; then |
| 83 |
echo "Removing empty dir $dir" |
| 84 |
rm -rvf $dir |
| 85 |
fi |
| 86 |
done |
| 87 |
|
| 88 |
cd .. |
| 89 |
|
| 90 |
done |
| 91 |
cd $CURRENT |
| 92 |
} |
| 93 |
|
| 94 |
copy_files $PUBDIRJIG $RSYNC_TARGET $ARCH |
| 95 |
|
| 96 |
echo "$START: Starting $ARCH sync from $PUBDIRJIG to $RSYNC_TARGET" |
| 97 |
if [ -e $RSYNC_TARGET/$ARCH ] ; then |
| 98 |
mv -f $RSYNC_TARGET/$ARCH $RSYNC_TARGET/$ARCH.old |
| 99 |
fi |
| 100 |
mv $RSYNC_TARGET/$ARCH.tmp $RSYNC_TARGET/$ARCH |
| 101 |
rm -rf $RSYNC_TARGET/$ARCH.old & |
| 102 |
|
| 103 |
# Update the trace file now to force a sync on free.hands.com after each arch |
| 104 |
mkdir -p $RSYNC_TARGET/trace |
| 105 |
date -u > $RSYNC_TARGET/trace/cdimage.debian.org |
| 106 |
|
| 107 |
# Generate the HEADER.html files in the subdirectories |
| 108 |
~/build.${CODENAME}/generate_headers ~/build.${CODENAME}/HEADER.html.in $RSYNC_TARGET/$ARCH $ARCH |
| 109 |
|
| 110 |
END=$(now) |
| 111 |
echo "$ARCH synced across to $RSYNC_TARGET; started at $START, copying started at $COPY_START, ended at $END" |
| 112 |
|
| 113 |
case $(hostname) in |
| 114 |
pettersson*) |
| 115 |
ISO_OPTIONS='--exclude .iso-wanted' |
| 116 |
;; |
| 117 |
*) |
| 118 |
ISO_OPTIONS='--exclude *.iso' |
| 119 |
;; |
| 120 |
esac |
| 121 |
|
| 122 |
# Publish the image |
| 123 |
# If we're on casulana, this will push things to umu.se via rsync |
| 124 |
# over ssh; on pettersson* we use the same script but no ssh to make |
| 125 |
# things as similar as possible |
| 126 |
SYNC_START=$(now) |
| 127 |
PETOUT=${RSYNC_TARGET##${OUT_BASE}/} |
| 128 |
echo "$START: Starting $ARCH sync from $RSYNC_TARGET/$ARCH to umu:${PETOUT}/$ARCH" |
| 129 |
(cd $RSYNC_TARGET/$ARCH && find . -name '*.iso' > .iso-wanted) |
| 130 |
rsync_to_umu $RSYNC_TARGET/$ARCH/ ${PETOUT}/$ARCH/ "$ISO_OPTIONS" |
| 131 |
rsync_to_umu $RSYNC_TARGET/trace/ ${PETOUT}/trace/ |
| 132 |
publish_at_umu ${PETOUT}/$ARCH ${PETOUT}/trace |
| 133 |
SIZE=$(du -s -BM $ISO_OPTIONS $RSYNC_TARGET/$ARCH/ | awk '{gsub("M","",$1); print $1}') |
| 134 |
SYNC_END=$(now) |
| 135 |
TIME_TAKEN=$(calc_time $SYNC_START $SYNC_END) |
| 136 |
echo "$RSYNC_TARGET/$ARCH synced across to umu; started at $SYNC_START, ended at $SYNC_END; transferred $SIZE MB in $TIME_TAKEN" |
| 137 |
|
| 138 |
case $ARCH in |
| 139 |
amd64|arm64) trigger_openqa $PETOUT "$(debversion)" ${DATE_BUILD/-/-w-} $ARCH ;; |
| 140 |
esac |
| 141 |
|
| 142 |
END=$(now) |
| 143 |
echo "$END: Finished" |