source: trunk/debathena/scripts/build-server/autolivebuilder @ 24356

Revision 24356, 4.4 KB checked in by broder, 15 years ago (diff)
Upgrade a chroot before attempting to do a build in it.
  • Property svn:executable set to *
RevLine 
[24352]1#!/bin/bash
[23981]2
3# This script is intended to be run from a cron job by a local account
4# on the Debathena build server--i.e. debuild@debuild.mit.edu. The
5# account should have
6#
7# * A GPG secret key to sign the checksums for the live CDs.
8#
9# * A file named $HOME/autolivebuilder.config specifying shell
10#   variable assignments for:
11#   - error_addr: An email address to send errors to
12#   - release: The Ubuntu release to base the live CDs off of
13#   - release_version: The version number of that release
14#   - arch: Which architecture to use for the live CD
15#   - mirror: Which Ubuntu mirror to use
16#   - gpg_opts: A bash array of options to pass to gpg. This should
17#     include which keys to sign the checksums files with
[24020]18#   - live_dir: The directory to put the live CDs into
[23981]19
20# Send all output to a logfile.
21mkdir -p "$HOME/autolivebuilder-logs"
22logfile=$HOME/autolivebuilder-logs/$(date '+%Y-%m-%d-%H').log
23exec </dev/null >>$logfile 2>&1
24
25# Set default configuration values
26mirror='ubuntu.media.mit.edu'
27
28# Read configuration; if it's not complete, do nothing.
29config=$HOME/autolivebuilder.config
30. $config
31if (! [ -n "$error_addr" ]) || \
32    (! [ -n "release" ]) || \
33    (! [ -n "$release_version" ]) || \
34    (! [ -n "$arch" ]) || \
[24020]35    (! [ -n "${gpg_opts[*]}" ]) || \
36    (! [ -n "$live_dir" ]); then
[23981]37    echo "Incomplete $config; doing nothing."
38    exit
39fi
40
41suppress=$HOME/autolivebuilder.suppress
42if [ -e "$suppress" ]; then
43    echo "$suppress exists; not running."
44    exit
45fi
46
47# Make sure runs of this script do not overlap.
[23984]48runfile=$HOME/autolivebuilder.running
[23981]49if [ -e "$runfile" ]; then
50  # A previous invocation appears to still be running.
51  pid=$(cat "$runfile")
52  if ! kill -0 "$pid" 2>/dev/null; then
53    # Okay, it's not really running.  Perhaps the machine has
54    # rebooted.  Wait for manual intervention before running again.
[23989]55    echo "Stale runfile."
[23981]56  else
57    echo "$runfile exists; not running."
58  fi
59  exit
60fi
61echo $$ > $runfile
62
63# Put here cleanup that should always happen
64clean_up () {
65    err=$?
66
67    set +e
68
69    touch "$suppress"
[24354]70    rm "$runfile"
[23989]71    /usr/sbin/sendmail -t <<EOF
[23981]72From: Autolivebuilder <$error_addr>
73To: Autolivebuilder <$error_addr>
74Subject: Autolivebuilder failure
75
76Autolivebuilder has experienced a failure.
77
78Please see $logfile on $(hostname) for more details.
79
80Autolivebuilder will stop running until $suppress is removed.
81EOF
82
83    if [ -n "$session" ]; then
84        schroot -ec "$session"
85    fi
86
87    exit $err
88}
89
90trap clean_up ERR
91set -e
92
[24353]93cd $HOME/live
[23981]94
[23986]95if ! [ -d debathena-live ]; then
96    echo "E: The Debathena Live CD builder is not checked out."
97    echo "E: Run 'git clone file:///mit/debathena/git/debathena-live.git' in"
[24353]98    echo "E: $HOME/live"
[23986]99    false
[23981]100fi
101pushd debathena-live
102  # This will break if we ever add an epoch. So don't do that.
103  version="$(dpkg-parsechangelog | sed -ne 's/^Version: //p')"
104  debuild -us -uc -b
105popd
106
107iso="ubuntu-${release_version}-desktop-${arch}.iso"
108wget -N "http://${mirror}/ubuntu-releases/${release_version}/$iso"
109
110wget -N "http://${mirror}/ubuntu-releases/${release_version}/SHA1SUMS"
111wget -N "http://${mirror}/ubuntu-releases/${release_version}/SHA1SUMS.gpg"
112
113gpg --verify SHA1SUMS.gpg SHA1SUMS
114grep "$iso" SHA1SUMS | sha1sum -c
115
116session="$(schroot -bc "${release}-${arch}-sbuild")"
117
[24356]118schroot -rc "$session" -u root -- sh -c 'apt-get update && apt-get -y dist-upgrade && apt-get -y autoremove'
[23981]119schroot -rc "$session" -u root -- dpkg -i "debathena-livecd-tools_${version}_all.deb" || :
120schroot -rc "$session" -u root -- apt-get install -y -f
121
122date="$(date "+%Y%m%d")"
123da_iso="ubuntu-${release_version}-debathena-${date}-${arch}.iso"
[23991]124da_dvd_iso="ubuntu-${release_version}-debathena-${date}-${arch}-dvd.iso"
[23981]125
126schroot -rc "$session" -u root -- debathena-livecd-convert "$iso" "$da_iso"
127schroot -rc "$session" -u root -- debathena-livecd-convert --dvd "$iso" "$da_dvd_iso"
128
[24020]129cp "$da_iso" "$da_dvd_iso" "${live_dir}"
130sha1sum "$da_iso" >"${live_dir}/${da_iso}.sha1sum"
131sha512sum "$da_iso" >"${live_dir}/${da_iso}.sha512sum"
132sha1sum "$da_dvd_iso" >"${live_dir}/${da_dvd_iso}.sha1sum"
133sha512sum "$da_dvd_iso" >"${live_dir}/${da_dvd_iso}.sha512sum"
[23981]134
[24020]135gpg --batch --yes "${gpg_opts[@]}" -a -b "${live_dir}/${da_iso}.sha1sum"
136gpg --batch --yes "${gpg_opts[@]}" -a -b "${live_dir}/${da_iso}.sha512sum"
137gpg --batch --yes "${gpg_opts[@]}" -a -b "${live_dir}/${da_dvd_iso}.sha1sum"
138gpg --batch --yes "${gpg_opts[@]}" -a -b "${live_dir}/${da_dvd_iso}.sha512sum"
[23982]139
140kdestroy
141rm -f "$runfile"
Note: See TracBrowser for help on using the repository browser.