launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04681
[Merge] lp:~cjwatson/meta-lp-deps/fix-target-detection-harder into lp:meta-lp-deps
Colin Watson has proposed merging lp:~cjwatson/meta-lp-deps/fix-target-detection-harder into lp:meta-lp-deps.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/meta-lp-deps/fix-target-detection-harder/+merge/72166
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!
--
https://code.launchpad.net/~cjwatson/meta-lp-deps/fix-target-detection-harder/+merge/72166
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/meta-lp-deps/fix-target-detection-harder into lp:meta-lp-deps.
=== modified file 'debian/changelog'
--- debian/changelog 2011-08-17 09:49:12 +0000
+++ debian/changelog 2011-08-19 10:52:27 +0000
@@ -1,3 +1,10 @@
+launchpad-dependencies (0.98) natty; urgency=low
+
+ * Fix target detection so that it works correctly for both Launchpad PPA
+ recipe builds and IS uploads to the CAT repository.
+
+ -- Colin Watson <cjwatson@xxxxxxxxxx> Fri, 19 Aug 2011 11:48:40 +0100
+
launchpad-dependencies (0.97) natty; urgency=low
* IS uploads of this package to the CAT repository apparently drop the
=== added file 'debian/detect-target.py'
--- debian/detect-target.py 1970-01-01 00:00:00 +0000
+++ debian/detect-target.py 2011-08-19 10:52:27 +0000
@@ -0,0 +1,51 @@
+#! /usr/bin/python
+
+"""
+Detect target distribution series
+
+Detect which distribution series we're being built for so that we can emit
+appropriately versioned dependencies. This is tricky because our different
+build environments express this in different ways. Recipe builds for the
+Launchpad PPA have a changelog header line that looks like this:
+
+ launchpad-dependencies (0.97~lucid1) natty; urgency=low
+
+While builds by the Canonical admin team look like this:
+
+ launchpad-dependencies (0.97~0.IS.10.04) lucid-cat; urgency=low
+
+Therefore, we test the version first, and then the target distribution. If
+we find neither, assume that we're building for the most current series we
+support.
+"""
+
+import sys
+import subprocess
+
+targets = ('lucid', 'maverick', 'natty', 'oneiric')
+
+def changelog_field(field):
+ parser = subprocess.Popen(['dpkg-parsechangelog'], stdout=subprocess.PIPE)
+ for line in parser.stdout:
+ if line.lower().startswith('%s:' % field):
+ return line.split(':', 1)[1].strip()
+ return ''
+
+def main():
+ version = changelog_field('version')
+ for target in targets:
+ if target in version:
+ print target
+ return 0
+
+ distribution = changelog_field('distribution')
+ for target in targets:
+ if distribution.startswith(target):
+ print target
+ return 0
+
+ print targets[-1]
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
=== modified file 'debian/rules'
--- debian/rules 2011-08-17 09:48:42 +0000
+++ debian/rules 2011-08-19 10:52:27 +0000
@@ -4,7 +4,7 @@
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
-target := $(shell dpkg-parsechangelog | awk '/^Distribution:/ { print $2 }')
+target := $(shell debian/detect-target.py)
ifneq (,$(findstring lucid,$(target)))
apt_utils_version := 0.7.25.3ubuntu9.6+mvo1
Follow ups