Merge lp:~jr/bzr-builddeb/862188-get-tar into lp:bzr-builddeb

Proposed by Jonathan Riddell
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 624
Merged at revision: 621
Proposed branch: lp:~jr/bzr-builddeb/862188-get-tar
Merge into: lp:bzr-builddeb
Diff against target: 194 lines (+139/-0)
5 files modified
__init__.py (+1/-0)
cmds.py (+27/-0)
debian/changelog (+4/-0)
tests/blackbox/__init__.py (+1/-0)
tests/blackbox/test_get_tar.py (+106/-0)
To merge this branch: bzr merge lp:~jr/bzr-builddeb/862188-get-tar
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+77571@code.launchpad.net

Description of the change

Add get-tar command, helps workflow for those of us who like to build packages on their native system (not pbuilder etc)

https://bugs.launchpad.net/bzr-builddeb/+bug/862188

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Thanks for adding this.

give_instruction doesn't appear to be used.

This should have tests, as well as an entry in debian/changelog.

UpstreamProvider.provide() can raise exceptions - in particular, it could raise an exception if the current version is not available, in which case a sane error message should be printed rather than a backtrace.

It would be nice if it could print where exactly it has generated a file.

The call to generate build_source_dir seems pointless as get_parent_dir will return the dirname.

review: Needs Fixing
lp:~jr/bzr-builddeb/862188-get-tar updated
615. By Jonathan Riddell

remove pointless variables

616. By Jonathan Riddell

add changelog

617. By Jonathan Riddell

print location of tar

618. By Jonathan Riddell

use orig_dir rather than build_dir to get tar

619. By Jonathan Riddell

add blackbox tests for get-tar

Revision history for this message
Jonathan Riddell (jr) wrote :

all done

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Thanks! Some more minor comments:

Please use four-space indentation in new files - I realize some of the existing bzr-builddeb tests still use two-space indentation, but we should slowly get rid of that rather than add more files with two-space indentation.

When would provide() return an empty list? Also, I think the other entries in the list should also be displayed, not just the first one.

get-tar seems fairly generic for something that is a bzr subcommand - it could mean a lot of things, e.g. be confused with "bzr export foo.tar.gz". What about something like get-orig-source, deb-orig-source ?

 + "get_tar": ["bd"],

This register "bd" as an alias for get_tar, but it is also already registered for "bzr builddeb".

Revision history for this message
Jelmer Vernooij (jelmer) :
review: Needs Fixing
Revision history for this message
Jonathan Riddell (jr) wrote :

all done

lp:~jr/bzr-builddeb/862188-get-tar updated
620. By Jonathan Riddell

reindent to 4 spaces

621. By Jonathan Riddell

merge in trunk

622. By Jonathan Riddell

print result for all tars

623. By Jonathan Riddell

don't alias bd for get-tar

624. By Jonathan Riddell

rename to get-orig-source

Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

2.7.9 has been uploaded so the changelog entry should be in 2.7.10.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '__init__.py'
2--- __init__.py 2011-10-01 00:18:46 +0000
3+++ __init__.py 2011-10-03 10:55:35 +0000
4@@ -37,6 +37,7 @@
5 commands = {
6 "bd_do": [],
7 "builddeb": ["bd"],
8+ "get_orig_source": [],
9 "dep3_patch": [],
10 "dh_make": ["dh_make"],
11 "import_dsc": [],
12
13=== modified file 'cmds.py'
14--- cmds.py 2011-09-29 10:11:07 +0000
15+++ cmds.py 2011-10-03 10:55:35 +0000
16@@ -73,6 +73,9 @@
17 PackageVersionNotPresent,
18 StrictBuildFailed,
19 )
20+from bzrlib.plugins.builddeb.util import (
21+ get_parent_dir,
22+ )
23 from bzrlib.plugins.builddeb.hooks import run_hook
24 from bzrlib.plugins.builddeb.import_dsc import (
25 DistributionBranch,
26@@ -463,6 +466,30 @@
27 tree.unlock()
28
29
30+class cmd_get_orig_source(Command):
31+ """Gets the upstream tar file for the packaging branch."""
32+
33+ def run(self):
34+ tree = WorkingTree.open_containing('.')[0]
35+ config = debuild_config(tree, tree)
36+
37+ (changelog, larstiq) = find_changelog(tree, True)
38+ orig_dir = config.orig_dir
39+ if orig_dir is None:
40+ orig_dir = default_orig_dir
41+
42+ upstream_provider = UpstreamProvider(changelog.package,
43+ changelog.version.upstream_version, orig_dir,
44+ [PristineTarSource(tree, tree.branch),
45+ AptSource(),
46+ GetOrigSourceSource(tree, larstiq),
47+ UScanSource(tree, larstiq) ])
48+
49+ result = upstream_provider.provide(orig_dir)
50+ for tar, component in result:
51+ note("Tar now in " + tar)
52+
53+
54 class cmd_merge_upstream(Command):
55 """Merges a new upstream version into the current branch.
56
57
58=== modified file 'debian/changelog'
59--- debian/changelog 2011-10-01 20:41:14 +0000
60+++ debian/changelog 2011-10-03 10:55:35 +0000
61@@ -3,6 +3,10 @@
62 [ Jelmer Vernooij ]
63 * Support .tar.xz Debian files rather than .tar.lzma.
64
65+ [ Jonathan Riddell ]
66+ * Add get-tar command which will get the upstream tar file.
67+ LP: #862188
68+
69 [ Martin Packman ]
70 * Support non-ascii characters in changelog entry when determining
71 commit message. LP: #853664
72
73=== modified file 'tests/blackbox/__init__.py'
74--- tests/blackbox/__init__.py 2011-05-08 10:40:32 +0000
75+++ tests/blackbox/__init__.py 2011-10-03 10:55:35 +0000
76@@ -24,6 +24,7 @@
77 'test_builddeb',
78 'test_dep3',
79 'test_do',
80+ 'test_get_tar',
81 'test_import_dsc',
82 'test_import_upstream',
83 'test_mark_uploaded',
84
85=== added file 'tests/blackbox/test_get_tar.py'
86--- tests/blackbox/test_get_tar.py 1970-01-01 00:00:00 +0000
87+++ tests/blackbox/test_get_tar.py 2011-10-03 10:55:35 +0000
88@@ -0,0 +1,106 @@
89+# test_get_tar.py -- Blackbox tests for get-orig-source.
90+# Copyright 2011 Canonical Ltd
91+#
92+# This file is part of bzr-builddeb.
93+#
94+# bzr-builddeb is free software; you can redistribute it and/or modify
95+# it under the terms of the GNU General Public License as published by
96+# the Free Software Foundation; either version 2 of the License, or
97+# (at your option) any later version.
98+#
99+# bzr-builddeb is distributed in the hope that it will be useful,
100+# but WITHOUT ANY WARRANTY; without even the implied warranty of
101+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
102+# GNU General Public License for more details.
103+#
104+# You should have received a copy of the GNU General Public License
105+# along with bzr-builddeb; if not, write to the Free Software
106+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
107+#
108+
109+import os
110+import tarfile
111+
112+try:
113+ from debian.changelog import (Changelog,
114+ Version,
115+ )
116+except ImportError:
117+ # Prior to 0.1.15 the debian module was called debian_bundle
118+ from debian_bundle.changelog import (Changelog,
119+ Version,
120+ )
121+
122+
123+from bzrlib.plugins.builddeb.tests import BuilddebTestCase
124+
125+
126+class TestGetOrigSource(BuilddebTestCase):
127+
128+ def make_changelog(self, version=None):
129+ if version is None:
130+ version = self.package_version
131+ c = Changelog()
132+ c.new_block()
133+ c.version = Version(version)
134+ c.package = self.package_name
135+ c.distributions = 'unstable'
136+ c.urgency = 'low'
137+ c.author = 'James Westby <jw+debian@jameswestby.net>'
138+ c.date = 'The, 3 Aug 2006 19:16:22 +0100'
139+ c.add_change('')
140+ c.add_change(' * test build')
141+ c.add_change('')
142+ return c
143+
144+ def make_unpacked_source(self):
145+ """
146+ Create an unpacked source tree in a branch. Return the working
147+ tree
148+ """
149+ tree = self.make_branch_and_tree('.')
150+ cl_file = 'debian/changelog'
151+ source_files = ['README', 'debian/'] + [cl_file]
152+ self.build_tree(source_files)
153+ c = self.make_changelog()
154+ self.write_changelog(c, cl_file)
155+ tree.add(source_files)
156+ return tree
157+
158+ def make_source_with_upstream(self):
159+ """Create a source tree in a branch with an upstream tag."""
160+ tree = self.make_branch_and_tree('.')
161+ source_files = ['README']
162+ self.build_tree(source_files)
163+ tree.add(source_files)
164+ tree.commit("one", rev_id='revid1')
165+ tree.branch.tags.set_tag("upstream-0.1", tree.branch.last_revision())
166+
167+ cl_file = 'debian/changelog'
168+ source_files = ['debian/'] + [cl_file]
169+ self.build_tree(source_files)
170+ c = self.make_changelog()
171+ self.write_changelog(c, cl_file)
172+ tree.add(source_files)
173+ tree.commit("two", rev_id='revid2')
174+ return tree
175+
176+ def test_get_orig_source_registered(self):
177+ self.run_bzr("get-orig-source --help")
178+
179+ def test_get_orig_source_error_no_changelog(self):
180+ self.run_bzr_error(
181+ ['Could not find changelog at "debian/changelog" or "changelog".'],
182+ "get-orig-source")
183+
184+ def test_get_orig_source_error_no_tar(self):
185+ self.make_unpacked_source()
186+ self.run_bzr_error(
187+ ['Unable to find the needed upstream tarball for package test, '\
188+ 'version 0.1.'],
189+ "get-orig-source")
190+
191+ def test_get_orig_source(self):
192+ tree = self.make_source_with_upstream()
193+ self.run_bzr(['get-orig-source'])
194+ self.assertPathExists('../test_0.1.orig.tar.gz')

Subscribers

People subscribed via source and target branches