~ubuntu-archive/ubuntu-archive-scripts/trunk

26 by Ubuntu Archive
add more archive report jobs
1
#! /bin/sh
2
set -e
3
90 by Colin Watson
archive-reports: avoid having a duplicate cleanup function
4
LOCK=
5
mtimes=
6
cleanup () {
7
	[ "$mtimes" ] && rm -rf "$mtimes"
8
	[ "$LOCK" ] && rm -f "$LOCK"
9
}
10
trap cleanup EXIT HUP INT QUIT TERM
11
119 by Colin Watson
archive-reports: be quiet about lockfile errors when stdout is not a terminal
12
if [ -t 1 ]; then
13
	REDIR=
14
else
15
	REDIR='>/dev/null 2>&1'
16
fi
17
91 by Colin Watson
archive-reports: ordering fix
18
LOCK="$HOME/.archive-reports.lock"
119 by Colin Watson
archive-reports: be quiet about lockfile errors when stdout is not a terminal
19
if ! eval lockfile -r1 "$LOCK" $REDIR; then
103 by Colin Watson
archive-reports: don't remove lock file on lock acquisition failure
20
	trap - EXIT HUP INT QUIT TERM
88 by Colin Watson
archive-reports: add locking
21
	exit 1
22
fi
23
26 by Ubuntu Archive
add more archive report jobs
24
MIRROR="$HOME/mirror/ubuntu"
29 by Ubuntu Archive
archive-reports: run *-mismatches when germinate output changes
25
GERMINATE="$HOME/mirror/ubuntu-germinate"
26
OUT="$HOME/public_html"
315 by Steve Langasek
impish -> jammy
27
DEVEL=jammy
320.1.1 by Brian Murray
Hirsute is EoL
28
PROPOSED_MIGRATION_SERIES="trusty xenial bionic focal impish jammy"
29 by Ubuntu Archive
archive-reports: run *-mismatches when germinate output changes
29
65 by Colin Watson
archive-reports: refactor to allow us to update chdist directories much more efficiently and accurately
30
mtimes="$(mktemp -d)"
31
32
collect_mtimes () {
33
	stat -c '%n %Y' \
34
		"$MIRROR"/dists/*/Release \
35
		"$GERMINATE/germinate.output" \
97 by Colin Watson
archive-reports, extra-germinate: write out extra germinate files by series rather than suite, to match expectations of component-mismatches
36
		"$HOME/extra-germinate/germinate.output" \
141 by Colin Watson
archive-reports: Sync dry-run ubuntu-rtm archive from dogfood, and run chdist updates for it.
37
		>"$mtimes/$1" 2>/dev/null || true
65 by Colin Watson
archive-reports: refactor to allow us to update chdist directories much more efficiently and accurately
38
}
39
29 by Ubuntu Archive
archive-reports: run *-mismatches when germinate output changes
40
mtime () {
67 by Colin Watson
archive-reports: mtime should not use grep -q
41
	(grep "^$2 " "$mtimes/$1" || echo "$2 0") | cut -d' ' -f2
65 by Colin Watson
archive-reports: refactor to allow us to update chdist directories much more efficiently and accurately
42
}
43
44
mtime_changed () {
66 by Colin Watson
archive-reports: fix mtime_changed syntax
45
	[ "$(mtime old "$1")" != "$(mtime new "$1")" ]
65 by Colin Watson
archive-reports: refactor to allow us to update chdist directories much more efficiently and accurately
46
}
47
48
release_changed () {
265 by Colin Watson
Stop running reports on ubuntu-rtm or the stable phone overlay.
49
	mtime_changed "$MIRROR/dists/$1/Release"
65 by Colin Watson
archive-reports: refactor to allow us to update chdist directories much more efficiently and accurately
50
}
51
52
germinate_changed () {
97 by Colin Watson
archive-reports, extra-germinate: write out extra germinate files by series rather than suite, to match expectations of component-mismatches
53
	mtime_changed "$GERMINATE/germinate.output" || \
54
		mtime_changed "$HOME/extra-germinate/germinate.output"
29 by Ubuntu Archive
archive-reports: run *-mismatches when germinate output changes
55
}
56
141 by Colin Watson
archive-reports: Sync dry-run ubuntu-rtm archive from dogfood, and run chdist updates for it.
57
is_devel () {
58
	case $suite in
265 by Colin Watson
Stop running reports on ubuntu-rtm or the stable phone overlay.
59
	    $DEVEL-proposed)
141 by Colin Watson
archive-reports: Sync dry-run ubuntu-rtm archive from dogfood, and run chdist updates for it.
60
		return 0
61
		;;
62
	    *)
63
		return 1
64
		;;
65
	esac
66
}
67
165 by Colin Watson
archive-reports: run proposed-migration if any tests are in progress, even if the suites in question haven't changed
68
pm_pending_tests () {
69
	local excuses
265 by Colin Watson
Stop running reports on ubuntu-rtm or the stable phone overlay.
70
	excuses="$HOME/public_html/proposed-migration/$1/update_excuses.html"
257 by Adam Conrad
archive-reports: Avoid chicken-and-egg problem of attempting to grep excuses before we have excuses to grep.
71
	[ ! -f "$excuses" ] || grep -q "Test in progress" "$excuses"
165 by Colin Watson
archive-reports: run proposed-migration if any tests are in progress, even if the suites in question haven't changed
72
}
73
29 by Ubuntu Archive
archive-reports: run *-mismatches when germinate output changes
74
background () {
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
75
	local var="$1"
76
	shift
29 by Ubuntu Archive
archive-reports: run *-mismatches when germinate output changes
77
	"$@" &
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
78
	eval "$var=\"\${$var:+\$$var }\$!\""
29 by Ubuntu Archive
archive-reports: run *-mismatches when germinate output changes
79
}
80
33 by Ubuntu Archive
archive-reports: ensure that chdist update is complete before starting run-britney
81
background_wait () {
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
82
	local var="$1"
83
	for pid in $(eval "echo \$$var"); do
33 by Ubuntu Archive
archive-reports: ensure that chdist update is complete before starting run-britney
84
		wait "$pid"
85
	done
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
86
	eval "$var="
33 by Ubuntu Archive
archive-reports: ensure that chdist update is complete before starting run-britney
87
}
88
65 by Colin Watson
archive-reports: refactor to allow us to update chdist directories much more efficiently and accurately
89
collect_mtimes old
26 by Ubuntu Archive
add more archive report jobs
90
151 by Colin Watson
archive-reports: Ensure that $MIRROR and $MIRROR_RTM exist before trying to rsync into their subdirectories.
91
mkdir -p "$MIRROR"
112 by Colin Watson
archive-reports: quieten rsync
92
rsync -aq \
26 by Ubuntu Archive
add more archive report jobs
93
	--exclude dapper\* --exclude edgy\* --exclude feisty\* \
102 by Colin Watson
hardy and oneiric are EOL
94
	--exclude gutsy\* --exclude hardy\* --exclude intrepid\* \
189 by Colin Watson
archive-reports: lucid and utopic are EOL
95
	--exclude jaunty\* --exclude karmic\* --exclude lucid\* \
96
	--exclude maverick\* --exclude natty\* --exclude oneiric\* \
314 by Steve Langasek
Drop references to obsolete series (precise, disco)
97
	--exclude precise\* --exclude quantal\* --exclude raring\* \
98
	--exclude saucy\* --exclude utopic\* --exclude wily\* \
234 by Adam Conrad
cosmic -> disco; drop artful
99
	--exclude yakkety\* --exclude zesty\* --exclude artful\* \
304 by Andy Whitcroft
archive-reports: disco and eoan are both long gone
100
	--exclude cosmic\* --exclude disco\* --exclude eoan\* \
26 by Ubuntu Archive
add more archive report jobs
101
	--include Packages\* --include Sources\* --include Release\* \
102
	--include udeb.list --include \*\*/installer-\*/current \
111 by Colin Watson
archive-reports: repeat "saucy" less often
103
	--include "**/$DEVEL/Contents-*" \
190 by Colin Watson
archive-reports: use rsync --delete-excluded where appropriate
104
	--include \*/ --exclude \* --delete --delete-excluded \
105
	--prune-empty-dirs \
26 by Ubuntu Archive
add more archive report jobs
106
	ftpmaster.internal::ubuntu-dists/ "$MIRROR/dists/"
107
65 by Colin Watson
archive-reports: refactor to allow us to update chdist directories much more efficiently and accurately
108
collect_mtimes new
109
111 by Colin Watson
archive-reports: repeat "saucy" less often
110
# The $DEVEL-proposed chdist configuration is used by proposed-migration;
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
111
# it's important to get that done as soon as possible, so we do it first.
112
chdist_pids=
113
chdists=0
114
for dist in "$HOME/.chdist"/*; do
115
	[ -d "$dist" ] || continue
116
	suite="${dist##*/}"
117
	suite="${suite%-*}"
141 by Colin Watson
archive-reports: Sync dry-run ubuntu-rtm archive from dogfood, and run chdist updates for it.
118
	if is_devel "$suite" && release_changed "$suite"; then
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
119
		background chdist_pids chdist apt-get "${dist##*/}" update >/dev/null
120
		chdists=$(($chdists + 1))
121
	fi
191 by Colin Watson
archive-reports: bump to seven chdists at once, to account for s390x
122
	if [ "$chdists" = 7 ]; then
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
123
		background_wait chdist_pids
124
		chdists=0
125
	fi
126
done
127
background_wait chdist_pids
128
265 by Colin Watson
Stop running reports on ubuntu-rtm or the stable phone overlay.
129
if mtime_changed "$MIRROR/.*/Release"; then
140 by Colin Watson
Only call run-apt-mirror-snapshot if any Release file has changed.
130
	background pids run-apt-mirror-snapshot
131
fi
139 by Colin Watson
Run apt-mirror-snapshot on each archive pulse.
132
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
133
pids=
164 by Colin Watson
archive-reports: slightly refactor how proposed-migration is run to make it easier to extend
134
run_proposed_migration () {
135
	DISTRIBUTION=ubuntu SERIES="$1" run-proposed-migration
136
}
302 by Steve Langasek
fix branch up-to-dateness check for git instead of bzr
137
138
check_git_uptodate() {
139
	cd "$1"
140
	git fetch origin -q
305 by Iain Lane
archive-reports: Use a method to get the current git branch which works on old 16.04 git
141
	branch=$(git symbolic-ref --short -q HEAD)
302 by Steve Langasek
fix branch up-to-dateness check for git instead of bzr
142
	[ -z "$(git diff origin/$branch..$branch)" ]
143
}
144
164 by Colin Watson
archive-reports: slightly refactor how proposed-migration is run to make it easier to extend
145
for series in $PROPOSED_MIGRATION_SERIES; do
165 by Colin Watson
archive-reports: run proposed-migration if any tests are in progress, even if the suites in question haven't changed
146
	if release_changed "$series" || release_changed "$series-proposed" || \
167 by Colin Watson
archive-reports: check for -updates changing when deciding whether to run proposed-migration
147
	   release_changed "$series-updates" || \
290.1.2 by Steve Langasek
Changes to hints files should also trigger a rerun of p-m, even if the archive is unchanged
148
	   pm_pending_tests "$series" || \
302 by Steve Langasek
fix branch up-to-dateness check for git instead of bzr
149
	   ! check_git_uptodate "$HOME/proposed-migration/data/${series}-proposed/Hints"
290.1.2 by Steve Langasek
Changes to hints files should also trigger a rerun of p-m, even if the archive is unchanged
150
	then
164 by Colin Watson
archive-reports: slightly refactor how proposed-migration is run to make it easier to extend
151
		background pids run_proposed_migration "$series"
152
	fi
153
done
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
154
113 by Colin Watson
archive-reports: run update-transitions a little earlier; it doesn't need chdist
155
if release_changed "$DEVEL-proposed"; then
156
	background pids update-transitions
157
fi
158
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
159
# Now update all the other chdist configurations, and wait for that to
160
# finish before doing anything else.
161
chdist_pids=
162
chdists=0
163
for dist in "$HOME/.chdist"/*; do
164
	[ -d "$dist" ] || continue
165
	suite="${dist##*/}"
166
	suite="${suite%-*}"
141 by Colin Watson
archive-reports: Sync dry-run ubuntu-rtm archive from dogfood, and run chdist updates for it.
167
	if ! is_devel "$suite" && release_changed "$suite"; then
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
168
		background chdist_pids chdist apt-get "${dist##*/}" update >/dev/null
169
		chdists=$(($chdists + 1))
170
	fi
191 by Colin Watson
archive-reports: bump to seven chdists at once, to account for s390x
171
	if [ "$chdists" = 7 ]; then
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
172
		background_wait chdist_pids
173
		chdists=0
174
	fi
175
done
176
background_wait chdist_pids
65 by Colin Watson
archive-reports: refactor to allow us to update chdist directories much more efficiently and accurately
177
111 by Colin Watson
archive-reports: repeat "saucy" less often
178
if release_changed "$DEVEL"; then
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
179
	background pids cron.NBS
71 by Colin Watson
archive-reports: actually, no need to update transition tracker when raring changes, but do still sync across raring indices
180
fi
60 by Ubuntu Archive
archive-reports: run proposed-migration whenever either the release or proposed pocket changes
181
111 by Colin Watson
archive-reports: repeat "saucy" less often
182
if release_changed "$DEVEL" || release_changed "$DEVEL-proposed"; then
93 by Colin Watson
archive-reports, extra-germinate: do an extra germinate run for -proposed
183
	# Do an extra germinate run so that we can run component-mismatches
184
	# against -proposed.  (We can't do this as part of LP archive
185
	# publishing because that would probably cause us to break our
186
	# 30-minute window.)
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
187
	background pids \
94 by Colin Watson
archive-reports: run extra-germinate with appropriate PYTHONPATH
188
		env PYTHONPATH="$HOME/ubuntu-archive-tools:$HOME/germinate" \
95 by Colin Watson
archive-reports: tell extra-germinate to process the "ubuntu" seed collection
189
		extra-germinate -o "$HOME/extra-germinate" ubuntu
93 by Colin Watson
archive-reports, extra-germinate: do an extra germinate run for -proposed
190
fi
191
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
192
background_wait pids
62 by Ubuntu Archive
archive-reports: run proposed-migration more in parallel with some other reports
193
112 by Colin Watson
archive-reports: quieten rsync
194
rsync -aq \
35 by Ubuntu Archive
archive-reports: stop mirroring ALL and ALL.sources from ubuntu-germinate
195
	--include germinate.output \
128 by Colin Watson
archive-reports: exclude .new files in germinate output
196
	--exclude _\* --exclude \*.new --include "*_${DEVEL}_*" \
190 by Colin Watson
archive-reports: use rsync --delete-excluded where appropriate
197
	--exclude \* --delete --delete-excluded \
29 by Ubuntu Archive
archive-reports: run *-mismatches when germinate output changes
198
	ftpmaster.internal::ubuntu-germinate/ "$GERMINATE/"
199
65 by Colin Watson
archive-reports: refactor to allow us to update chdist directories much more efficiently and accurately
200
collect_mtimes new
29 by Ubuntu Archive
archive-reports: run *-mismatches when germinate output changes
201
65 by Colin Watson
archive-reports: refactor to allow us to update chdist directories much more efficiently and accurately
202
if germinate_changed; then
267 by Colin Watson
Improve strategy for telling when germinate has finished.
203
	# Check for the marker line emitted by lp:ubuntu-archive-publishing
204
	# at the end of the run.  If we don't find this, then we've rsynced
205
	# partial output and should try again later.
206
	if fgrep -q 'Germination complete.' "$GERMINATE/germinate.output"; then
31 by Ubuntu Archive
archive-reports: run process-component-mismatches-diff
207
		component_mismatches () {
99 by Colin Watson
archive-reports: run component-mismatches over -proposed
208
			local name="$1"
209
			shift
209 by Colin Watson
Drop references to ubuntu-touch.bionic.
210
			component-mismatches \
99 by Colin Watson
archive-reports: run component-mismatches over -proposed
211
				-d "$OUT/$name.dot" -o "$OUT/$name.txt.new" \
137 by Colin Watson
archive-reports: Write HTML versions of *-mismatches.
212
				--html-output-file "$OUT/$name.html" \
138 by Colin Watson
archive-reports: Write CSV time series data from *-mismatches.
213
				--csv-file "$OUT/$name.csv" \
273.1.1 by Dimitri John Ledkov
Exclude community seed, from components-missmatches
214
				--exclude "community" \
99 by Colin Watson
archive-reports: run component-mismatches over -proposed
215
				"$@"
216
			if [ "$name" = component-mismatches ]; then
217
				process-component-mismatches-diff \
218
					"$OUT/$name.txt" "$OUT/$name.txt.new"
219
			fi
220
			mv "$OUT/$name.txt.new" "$OUT/$name.txt"
221
			dot -Tsvg -Gdpi=55 -o "$OUT/$name.svg" "$OUT/$name.dot"
31 by Ubuntu Archive
archive-reports: run process-component-mismatches-diff
222
		}
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
223
		background pids component_mismatches component-mismatches
224
		background pids component_mismatches component-mismatches-proposed \
111 by Colin Watson
archive-reports: repeat "saucy" less often
225
			-s "$DEVEL-proposed" \
99 by Colin Watson
archive-reports: run component-mismatches over -proposed
226
			--germinate-path "$HOME/extra-germinate"
137 by Colin Watson
archive-reports: Write HTML versions of *-mismatches.
227
		background pids priority-mismatches \
228
			-o "$OUT/priority-mismatches.txt" \
138 by Colin Watson
archive-reports: Write CSV time series data from *-mismatches.
229
			--html-output-file "$OUT/priority-mismatches.html" \
230
			--csv-file "$OUT/priority-mismatches.csv"
137 by Colin Watson
archive-reports: Write HTML versions of *-mismatches.
231
		background pids architecture-mismatches \
232
			-o "$OUT/architecture-mismatches.txt" \
138 by Colin Watson
archive-reports: Write CSV time series data from *-mismatches.
233
			--html-output-file "$OUT/architecture-mismatches.html" \
234
			--csv-file "$OUT/architecture-mismatches.csv"
33 by Ubuntu Archive
archive-reports: ensure that chdist update is complete before starting run-britney
235
110 by Colin Watson
archive-reports: reorder jobs to get proposed-migration started earlier
236
		background_wait pids
56 by Ubuntu Archive
fix whitespace
237
	fi
29 by Ubuntu Archive
archive-reports: run *-mismatches when germinate output changes
238
fi