Merge lp:~cjwatson/meta-lp-deps/fix-target-detection-harder into lp:meta-lp-deps

Proposed by Colin Watson
Status: Merged
Merged at revision: 123
Proposed branch: lp:~cjwatson/meta-lp-deps/fix-target-detection-harder
Merge into: lp:meta-lp-deps
Diff against target: 83 lines (+59/-1)
3 files modified
debian/changelog (+7/-0)
debian/detect-target.py (+51/-0)
debian/rules (+1/-1)
To merge this branch: bzr merge lp:~cjwatson/meta-lp-deps/fix-target-detection-harder
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Review via email: mp+72166@code.launchpad.net

Description of the change

My version 0.97 of meta-lp-deps, whose purpose was to fix versioned dependencies in the CAT repositories (and succeeded), broke versioned dependencies in the Launchpad PPA, because recipe builds modify debian/changelog in a confusing way: they modify the version number but not the target distribution, which I didn't expect. This branch fixes target detection so that it works for both recipe builds and the CAT repository, and hopefully is robust and easy for Launchpad developers to modify in the future.

Sorry for the disruption!

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) :
review: Approve (code)
125. By Colin Watson

rename distribution to distroseries, as suggested by StevenK

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-08-17 09:49:12 +0000
3+++ debian/changelog 2011-08-19 11:33:24 +0000
4@@ -1,3 +1,10 @@
5+launchpad-dependencies (0.98) natty; urgency=low
6+
7+ * Fix target detection so that it works correctly for both Launchpad PPA
8+ recipe builds and IS uploads to the CAT repository.
9+
10+ -- Colin Watson <cjwatson@ubuntu.com> Fri, 19 Aug 2011 11:48:40 +0100
11+
12 launchpad-dependencies (0.97) natty; urgency=low
13
14 * IS uploads of this package to the CAT repository apparently drop the
15
16=== added file 'debian/detect-target.py'
17--- debian/detect-target.py 1970-01-01 00:00:00 +0000
18+++ debian/detect-target.py 2011-08-19 11:33:24 +0000
19@@ -0,0 +1,51 @@
20+#! /usr/bin/python
21+
22+"""
23+Detect target distribution series
24+
25+Detect which distribution series we're being built for so that we can emit
26+appropriately versioned dependencies. This is tricky because our different
27+build environments express this in different ways. Recipe builds for the
28+Launchpad PPA have a changelog header line that looks like this:
29+
30+ launchpad-dependencies (0.97~lucid1) natty; urgency=low
31+
32+While builds by the Canonical admin team look like this:
33+
34+ launchpad-dependencies (0.97~0.IS.10.04) lucid-cat; urgency=low
35+
36+Therefore, we test the version first, and then the target distribution. If
37+we find neither, assume that we're building for the most current series we
38+support.
39+"""
40+
41+import sys
42+import subprocess
43+
44+targets = ('lucid', 'maverick', 'natty', 'oneiric')
45+
46+def changelog_field(field):
47+ parser = subprocess.Popen(['dpkg-parsechangelog'], stdout=subprocess.PIPE)
48+ for line in parser.stdout:
49+ if line.lower().startswith('%s:' % field):
50+ return line.split(':', 1)[1].strip()
51+ return ''
52+
53+def main():
54+ version = changelog_field('version')
55+ for target in targets:
56+ if target in version:
57+ print target
58+ return 0
59+
60+ distroseries = changelog_field('distribution')
61+ for target in targets:
62+ if distroseries.startswith(target):
63+ print target
64+ return 0
65+
66+ print targets[-1]
67+ return 0
68+
69+if __name__ == '__main__':
70+ sys.exit(main())
71
72=== modified file 'debian/rules'
73--- debian/rules 2011-08-17 09:48:42 +0000
74+++ debian/rules 2011-08-19 11:33:24 +0000
75@@ -4,7 +4,7 @@
76 # Uncomment this to turn on verbose mode.
77 #export DH_VERBOSE=1
78
79-target := $(shell dpkg-parsechangelog | awk '/^Distribution:/ { print $2 }')
80+target := $(shell debian/detect-target.py)
81
82 ifneq (,$(findstring lucid,$(target)))
83 apt_utils_version := 0.7.25.3ubuntu9.6+mvo1

Subscribers

People subscribed via source and target branches