Merge lp:~jelmer/bzr-builddeb/get-packaged-orig-source into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Approved by: James Westby
Approved revision: 651
Merged at revision: 653
Proposed branch: lp:~jelmer/bzr-builddeb/get-packaged-orig-source
Merge into: lp:bzr-builddeb
Diff against target: 238 lines (+80/-50)
5 files modified
cmds.py (+4/-4)
debian/NEWS (+12/-0)
debian/changelog (+4/-1)
tests/blackbox/test_get_tar.py (+0/-3)
upstream/__init__.py (+60/-42)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/get-packaged-orig-source
Reviewer Review Type Date Requested Status
James Westby Approve
Martin Packman (community) code Approve
Review via email: mp+83980@code.launchpad.net

Description of the change

Deprecate the use of 'debian/rules get-orig-source' to retrieve the upstream tarball for the currently packaged upstream source, as this conflicts with the behaviour for get-orig-source mandated by debian policy (section 4.9).

Instead, support a new debian/rules target 'get-packaged-orig-source'. bzr-builddeb will now warn when it retrieves the upstream source using 'debian/rules get-orig-source'. I'm not entirely happy about the name of the new rule, better suggestions welcome. :-)

We should probably also rename the 'bzr get-orig-source' command while we're changing the rules name to prevent any confusion - we haven't done a release with the current name yet, so I think renaming it is reasonable enough.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Refactoring looks good, removal of the duplication of gather_orig_files is nice.

review: Approve (code)
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmds.py'
2--- cmds.py 2011-11-26 15:01:25 +0000
3+++ cmds.py 2011-11-30 17:07:30 +0000
4@@ -88,7 +88,7 @@
5 )
6 from bzrlib.plugins.builddeb.upstream import (
7 AptSource,
8- GetOrigSourceSource,
9+ DebianRulesSource,
10 SelfSplitSource,
11 TarfileSource,
12 UScanSource,
13@@ -396,7 +396,7 @@
14 elif not native and config.upstream_branch is not None:
15 upstream_sources.append(LazyUpstreamBranchSource(config.upstream_branch))
16 upstream_sources.extend([
17- GetOrigSourceSource(tree, top_level),
18+ DebianRulesSource(tree, top_level),
19 UScanSource(tree, top_level),
20 ])
21 if build_type == BUILD_TYPE_SPLIT:
22@@ -479,7 +479,7 @@
23 changelog.version.upstream_version, orig_dir,
24 [PristineTarSource(tree, tree.branch),
25 AptSource(),
26- GetOrigSourceSource(tree, larstiq),
27+ DebianRulesSource(tree, larstiq),
28 UScanSource(tree, larstiq) ])
29
30 result = upstream_provider.provide(orig_dir)
31@@ -1084,7 +1084,7 @@
32 changelog.version.upstream_version, orig_dir,
33 [PristineTarSource(t, t.branch),
34 AptSource(),
35- GetOrigSourceSource(t, top_level),
36+ DebianRulesSource(t, top_level),
37 UScanSource(t, top_level) ])
38
39 distiller = MergeModeDistiller(t, upstream_provider,
40
41=== modified file 'debian/NEWS'
42--- debian/NEWS 2011-02-06 13:25:43 +0000
43+++ debian/NEWS 2011-11-30 17:07:30 +0000
44@@ -1,3 +1,15 @@
45+bzr-builddeb (2.7.10) precise; urgency=low
46+
47+ bzr-builddeb now warns when using the get-orig-source target in debian/rules
48+ to fetch the currently package upstream tarball. get-packaged-orig-source
49+ should be provided instead.
50+
51+ Debian policy (section 4.9) dictates that get-orig-source should fetch the
52+ latest upstream tarball rather than the upstream tarball for the upstream
53+ version that is currently packaged.
54+
55+ -- Jelmer Vernooij <jelmer@debian.org> Wed, 30 Nov 2011 17:13:49 +0100
56+
57 bzr-builddeb (2.5.1) unstable; urgency=low
58
59 The 'deb:' directory service has been renamed to 'apt:' to avoid confusion.
60
61=== modified file 'debian/changelog'
62--- debian/changelog 2011-11-29 14:39:05 +0000
63+++ debian/changelog 2011-11-30 17:07:30 +0000
64@@ -25,8 +25,11 @@
65 unless 'commit-message-from-changelog' is explicitly set to True. LP: #812749
66 * Support running dep3-patch against remote repositories, and with
67 open-ended revision ranges. LP: #893608
68+ * bzr-builddeb now prefers the 'get-packaged-orig-source' rule to
69+ retrieve the packaged upstream source, and warns about
70+ 'get-orig-source'. LP: #409862
71
72- -- Jelmer Vernooij <jelmer@debian.org> Sat, 26 Nov 2011 16:01:16 +0100
73+ -- Jelmer Vernooij <jelmer@debian.org> Wed, 30 Nov 2011 17:13:38 +0100
74
75 bzr-builddeb (2.7.9) unstable; urgency=low
76
77
78=== modified file 'tests/blackbox/test_get_tar.py'
79--- tests/blackbox/test_get_tar.py 2011-10-03 10:49:13 +0000
80+++ tests/blackbox/test_get_tar.py 2011-11-30 17:07:30 +0000
81@@ -18,9 +18,6 @@
82 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
83 #
84
85-import os
86-import tarfile
87-
88 try:
89 from debian.changelog import (Changelog,
90 Version,
91
92=== modified file 'upstream/__init__.py'
93--- upstream/__init__.py 2011-11-08 10:10:05 +0000
94+++ upstream/__init__.py 2011-11-30 17:07:30 +0000
95@@ -64,7 +64,7 @@
96
97
98 class UpstreamSource(object):
99- """A source for upstream versions (uscan, get-orig-source, etc)."""
100+ """A source for upstream versions (uscan, debian/rules, etc)."""
101
102 def get_latest_version(self, package, current_version):
103 """Check what the latest upstream version is.
104@@ -171,59 +171,77 @@
105 return True
106
107
108-class GetOrigSourceSource(UpstreamSource):
109- """Upstream source that uses the get-orig-source rule in debian/rules."""
110+class DebianRulesSource(UpstreamSource):
111+ """Upstream source that uses rules in debian/rules."""
112
113 def __init__(self, tree, top_level):
114 self.tree = tree
115 self.top_level = top_level
116
117- def _get_orig_source(self, source_dir, prefix, target_dir):
118- note("Trying to use get-orig-source to retrieve needed tarball.")
119- command = ["make", "-f", "debian/rules", "get-orig-source"]
120+ def _get_rule_source(self, source_dir, rule, make_vars=None):
121+ command = ["make", "-f", "debian/rules", rule]
122+ if make_vars is not None:
123+ command.append(["%s=%s" % item for item in make_vars.iteritems()])
124+
125 proc = subprocess.Popen(command, cwd=source_dir)
126 ret = proc.wait()
127 if ret != 0:
128- note("Trying to run get-orig-source rule failed")
129+ note("Trying to run %s rule failed" % rule)
130+ return False
131+ return True
132+
133+ def _get_current_source(self, source_dir, package, version, target_dir):
134+ rule = "get-packaged-orig-source"
135+ note("Trying to use %s to retrieve needed tarball." % rule)
136+ if not self._get_rule_source(source_dir, rule, {
137+ "ORIG_VERSION": version,
138+ "ORIG_PACKAGE": package}):
139+ rule = "get-orig-source"
140+ note("Trying to use %s to retrieve needed tarball (deprecated)." % rule)
141+ if not self._get_rule_source(source_dir, rule):
142+ return None
143+ filenames = gather_orig_files(package, version, source_dir)
144+ if not filenames:
145+ note("%s did not create file for %s version %s", rule, package, version)
146 return None
147- filenames = []
148- for filename in os.listdir(source_dir):
149- if not filename.startswith(prefix):
150- continue
151- fetched_tarball = os.path.join(source_dir, filename)
152- if os.path.exists(fetched_tarball):
153- repack_tarball(fetched_tarball, filename,
154- target_dir=target_dir)
155- filenames.append(os.path.join(target_dir, filename))
156- if filenames:
157- return filenames
158- note("get-orig-source did not create file with prefix %s", prefix)
159- return None
160+ if rule == "get-orig-source":
161+ warning("Using get-orig-source to retrieve the packaged orig tarball "
162+ "is deprecated (see debian policy section 4.9). Provide the "
163+ "'get-packaged-orig-source' target instead.")
164+ ret = []
165+ for filename in filenames:
166+ repack_tarball(
167+ filename, os.path.basename(filename), target_dir=target_dir)
168+ ret.append(os.path.join(target_dir, os.path.basename(filename)))
169+ return ret
170
171- def fetch_tarballs(self, package, version, target_dir, components=None):
172+ def _get_rules_id(self):
173 if self.top_level:
174 rules_name = 'rules'
175 else:
176 rules_name = 'debian/rules'
177- rules_id = self.tree.path2id(rules_name)
178- if rules_id is not None:
179- tmpdir = tempfile.mkdtemp(prefix="builddeb-get-orig-source-")
180- try:
181- base_export_dir = os.path.join(tmpdir, "export")
182- export_dir = base_export_dir
183- if self.top_level:
184- os.mkdir(export_dir)
185- export_dir = os.path.join(export_dir, "debian")
186- export(self.tree, export_dir, format="dir")
187- tarball_paths = self._get_orig_source(base_export_dir,
188- "%s_%s.orig" % (package, version), target_dir)
189- if tarball_paths is None:
190- raise PackageVersionNotPresent(package, version, self)
191- return tarball_paths
192- finally:
193- shutil.rmtree(tmpdir)
194- note("No debian/rules file to try and use for a get-orig-source rule")
195- raise PackageVersionNotPresent(package, version, self)
196+ return self.tree.path2id(rules_name)
197+
198+ def fetch_tarballs(self, package, version, target_dir, components=None):
199+ rules_id = self._get_rules_id()
200+ if rules_id is None:
201+ note("No debian/rules file to use to retrieve upstream tarball.")
202+ raise PackageVersionNotPresent(package, version, self)
203+ tmpdir = tempfile.mkdtemp(prefix="builddeb-get-source-")
204+ try:
205+ base_export_dir = os.path.join(tmpdir, "export")
206+ export_dir = base_export_dir
207+ if self.top_level:
208+ os.mkdir(export_dir)
209+ export_dir = os.path.join(export_dir, "debian")
210+ export(self.tree, export_dir, format="dir")
211+ tarball_paths = self._get_current_source(base_export_dir,
212+ package, version, target_dir)
213+ if tarball_paths is None:
214+ raise PackageVersionNotPresent(package, version, self)
215+ return tarball_paths
216+ finally:
217+ shutil.rmtree(tmpdir)
218
219
220 class UScanSource(UpstreamSource):
221@@ -418,7 +436,7 @@
222 retrieved.
223 - Else if uscan knows about that version it will be downloaded
224 and repacked as needed.
225- - Else a call will be made to get-orig-source to try and retrieve
226+ - Else a call will be made to debian/rules to try and retrieve
227 the tarball.
228
229 If the tarball can't be found at all then MissingUpstreamTarball
230@@ -561,7 +579,7 @@
231 warning("More than one release file for release %s of package %s"
232 "found on Launchpad. Using the first.", version, package)
233 hosted_file = release_files[0]
234- tmpdir = tempfile.mkdtemp(prefix="builddeb-get-orig-source-")
235+ tmpdir = tempfile.mkdtemp(prefix="builddeb-launchpad-source-")
236 try:
237 inf = hosted_file.open()
238 try:

Subscribers

People subscribed via source and target branches