Merge lp:~julian-edwards/launchpad/publish-copy-archives-bug-520520-cron-job into lp:launchpad

Proposed by Julian Edwards
Status: Merged
Merged at revision: not available
Proposed branch: lp:~julian-edwards/launchpad/publish-copy-archives-bug-520520-cron-job
Merge into: lp:launchpad
Diff against target: 88 lines (+84/-0)
1 file modified
cronscripts/publishing/cron.publish-copy-archives (+84/-0)
To merge this branch: bzr merge lp:~julian-edwards/launchpad/publish-copy-archives-bug-520520-cron-job
Reviewer Review Type Date Requested Status
Michael Nelson (community) code Approve
Review via email: mp+20119@code.launchpad.net

Commit message

Cron job bash script glue to publish 'copy' archives.

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

= Summary =
New bash cron script to publish COPY archives

== Proposed fix ==
This is some glue to pull in the various bits necessary to run the publisher.
It's largely a copy of the existing cron.publish-ftpmaster but with some un-
needed stuff removed.

Yeah, it's bash. It blows. No, there's no tests.

Revision history for this message
Michael Nelson (michael.nelson) wrote :

Hi Julian,

When I first looked at this, I was wondering why you don't define DISTRONAME earlier and then do:

ARCHIVEROOT=/srv/launchpad.net/DISTRONAME-archive/DISTRONAME

etc., but I see that it's the same in cron.publish-ftpmaster.

Also, another thing that's been inherited from the ftpmaster - the comment at the top about LPCONFIG coming from the environment so we can run it unaltered on dogfood, but then the check before copying indices that "$LPCONFIG" = "$PRODUCTION_CONFIG"... wouldn't we want to copy the indices on df?

I'm assuming this is what you've been testing like crazy on df yesterday...

15:00 < noodles> bigjools: this bash script - is it what you've been testing on df yesterday?
15:01 < bigjools> and today, yes

Great.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'cronscripts/publishing/cron.publish-copy-archives'
2--- cronscripts/publishing/cron.publish-copy-archives 1970-01-01 00:00:00 +0000
3+++ cronscripts/publishing/cron.publish-copy-archives 2010-02-25 12:10:37 +0000
4@@ -0,0 +1,84 @@
5+#!/bin/sh
6+#
7+# Copyright 2009 Canonical Ltd. This software is licensed under the
8+# GNU Affero General Public License version 3 (see the file LICENSE).
9+
10+# LPCONFIG will come from the environment so this script can run unaltered
11+# on dogfood.
12+if [ -z $LPCONFIG ]; then
13+ echo LPCONFIG must be set to run this script.
14+ exit 1
15+fi
16+
17+set -x
18+set -e
19+set -u
20+
21+#
22+# This script publishes the COPY (rebuild) archvies *only*.
23+#
24+
25+
26+# Informational -- this *MUST* match the database.
27+ARCHIVEROOT=/srv/launchpad.net/ubuntu-archive/ubuntu
28+DISTSROOT=$ARCHIVEROOT/dists
29+OVERRIDEROOT=$ARCHIVEROOT/../ubuntu-overrides
30+INDICES=$ARCHIVEROOT/indices
31+PRODUCTION_CONFIG=ftpmaster
32+
33+if [ "$LPCONFIG" = "$PRODUCTION_CONFIG" ]; then
34+ GNUPGHOME=/srv/launchpad.net/ubuntu-archive/gnupg-home
35+else
36+ echo GPG keys will come from ~/.gnupg
37+ # GNUPGHOME does not need to be set, keys can come from ~/.gnupg.
38+fi
39+
40+# Configuration options.
41+LAUNCHPADROOT=/srv/launchpad.net/codelines/current
42+LOCKFILE=/srv/launchpad.net/ubuntu-archive/cron.daily.lock
43+DISTRONAME=ubuntu
44+TOUCHLIST=$ARCHIVEROOT/project/trace/$(hostname --fqdn)
45+
46+# Manipulate the environment.
47+export GNUPGHOME
48+PATH=$PATH:$LAUNCHPADROOT/scripts:$LAUNCHPADROOT/cronscripts:$LAUNCHPADROOT/cronscripts/publishing:$LAUNCHPADROOT/scripts/ftpmaster-tools
49+
50+# Claim the lock.
51+if ! lockfile -r1 $LOCKFILE; then
52+ echo "Could not claim lock file."
53+ exit 1
54+fi
55+
56+# Lock claimed.
57+
58+cleanup () {
59+ echo "Cleaning up lockfile."
60+ rm -f $LOCKFILE
61+}
62+
63+trap cleanup EXIT
64+
65+# Process the accepted queue into the publishing records.
66+process-accepted.py --copy-archive -v -v -v $DISTRONAME
67+
68+# Publish the packages to disk.
69+publish-distro.py -v -v --copy-archive -d $DISTRONAME
70+
71+set +x
72+
73+echo Removing uncompressed Packages and Sources files
74+find ${DISTSROOT} \( -name "Packages" -o -name "Sources" \) -exec rm "{}" \;
75+
76+# Copy in the indices.
77+if [ "$LPCONFIG" = "$PRODUCTION_CONFIG" ]; then
78+ echo Copying the indices into place.
79+ rm -f $INDICES/override.*
80+ cp $OVERRIDEROOT/override.* $INDICES
81+fi
82+
83+# Touch everything you asked us to do.
84+if [ "$LPCONFIG" = "$PRODUCTION_CONFIG" ]; then
85+ for FILE in $TOUCHLIST; do
86+ touch "$FILE"
87+ done
88+fi