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
=== modified file '__init__.py'
--- __init__.py 2011-10-01 00:18:46 +0000
+++ __init__.py 2011-10-03 10:55:35 +0000
@@ -37,6 +37,7 @@
37commands = {37commands = {
38 "bd_do": [],38 "bd_do": [],
39 "builddeb": ["bd"],39 "builddeb": ["bd"],
40 "get_orig_source": [],
40 "dep3_patch": [],41 "dep3_patch": [],
41 "dh_make": ["dh_make"],42 "dh_make": ["dh_make"],
42 "import_dsc": [],43 "import_dsc": [],
4344
=== modified file 'cmds.py'
--- cmds.py 2011-09-29 10:11:07 +0000
+++ cmds.py 2011-10-03 10:55:35 +0000
@@ -73,6 +73,9 @@
73 PackageVersionNotPresent,73 PackageVersionNotPresent,
74 StrictBuildFailed,74 StrictBuildFailed,
75 )75 )
76from bzrlib.plugins.builddeb.util import (
77 get_parent_dir,
78 )
76from bzrlib.plugins.builddeb.hooks import run_hook79from bzrlib.plugins.builddeb.hooks import run_hook
77from bzrlib.plugins.builddeb.import_dsc import (80from bzrlib.plugins.builddeb.import_dsc import (
78 DistributionBranch,81 DistributionBranch,
@@ -463,6 +466,30 @@
463 tree.unlock()466 tree.unlock()
464467
465468
469class cmd_get_orig_source(Command):
470 """Gets the upstream tar file for the packaging branch."""
471
472 def run(self):
473 tree = WorkingTree.open_containing('.')[0]
474 config = debuild_config(tree, tree)
475
476 (changelog, larstiq) = find_changelog(tree, True)
477 orig_dir = config.orig_dir
478 if orig_dir is None:
479 orig_dir = default_orig_dir
480
481 upstream_provider = UpstreamProvider(changelog.package,
482 changelog.version.upstream_version, orig_dir,
483 [PristineTarSource(tree, tree.branch),
484 AptSource(),
485 GetOrigSourceSource(tree, larstiq),
486 UScanSource(tree, larstiq) ])
487
488 result = upstream_provider.provide(orig_dir)
489 for tar, component in result:
490 note("Tar now in " + tar)
491
492
466class cmd_merge_upstream(Command):493class cmd_merge_upstream(Command):
467 """Merges a new upstream version into the current branch.494 """Merges a new upstream version into the current branch.
468495
469496
=== modified file 'debian/changelog'
--- debian/changelog 2011-10-01 20:41:14 +0000
+++ debian/changelog 2011-10-03 10:55:35 +0000
@@ -3,6 +3,10 @@
3 [ Jelmer Vernooij ]3 [ Jelmer Vernooij ]
4 * Support .tar.xz Debian files rather than .tar.lzma.4 * Support .tar.xz Debian files rather than .tar.lzma.
55
6 [ Jonathan Riddell ]
7 * Add get-tar command which will get the upstream tar file.
8 LP: #862188
9
6 [ Martin Packman ]10 [ Martin Packman ]
7 * Support non-ascii characters in changelog entry when determining11 * Support non-ascii characters in changelog entry when determining
8 commit message. LP: #85366412 commit message. LP: #853664
913
=== modified file 'tests/blackbox/__init__.py'
--- tests/blackbox/__init__.py 2011-05-08 10:40:32 +0000
+++ tests/blackbox/__init__.py 2011-10-03 10:55:35 +0000
@@ -24,6 +24,7 @@
24 'test_builddeb',24 'test_builddeb',
25 'test_dep3',25 'test_dep3',
26 'test_do',26 'test_do',
27 'test_get_tar',
27 'test_import_dsc',28 'test_import_dsc',
28 'test_import_upstream',29 'test_import_upstream',
29 'test_mark_uploaded',30 'test_mark_uploaded',
3031
=== added file 'tests/blackbox/test_get_tar.py'
--- tests/blackbox/test_get_tar.py 1970-01-01 00:00:00 +0000
+++ tests/blackbox/test_get_tar.py 2011-10-03 10:55:35 +0000
@@ -0,0 +1,106 @@
1# test_get_tar.py -- Blackbox tests for get-orig-source.
2# Copyright 2011 Canonical Ltd
3#
4# This file is part of bzr-builddeb.
5#
6# bzr-builddeb is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# bzr-builddeb is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with bzr-builddeb; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19#
20
21import os
22import tarfile
23
24try:
25 from debian.changelog import (Changelog,
26 Version,
27 )
28except ImportError:
29 # Prior to 0.1.15 the debian module was called debian_bundle
30 from debian_bundle.changelog import (Changelog,
31 Version,
32 )
33
34
35from bzrlib.plugins.builddeb.tests import BuilddebTestCase
36
37
38class TestGetOrigSource(BuilddebTestCase):
39
40 def make_changelog(self, version=None):
41 if version is None:
42 version = self.package_version
43 c = Changelog()
44 c.new_block()
45 c.version = Version(version)
46 c.package = self.package_name
47 c.distributions = 'unstable'
48 c.urgency = 'low'
49 c.author = 'James Westby <jw+debian@jameswestby.net>'
50 c.date = 'The, 3 Aug 2006 19:16:22 +0100'
51 c.add_change('')
52 c.add_change(' * test build')
53 c.add_change('')
54 return c
55
56 def make_unpacked_source(self):
57 """
58 Create an unpacked source tree in a branch. Return the working
59 tree
60 """
61 tree = self.make_branch_and_tree('.')
62 cl_file = 'debian/changelog'
63 source_files = ['README', 'debian/'] + [cl_file]
64 self.build_tree(source_files)
65 c = self.make_changelog()
66 self.write_changelog(c, cl_file)
67 tree.add(source_files)
68 return tree
69
70 def make_source_with_upstream(self):
71 """Create a source tree in a branch with an upstream tag."""
72 tree = self.make_branch_and_tree('.')
73 source_files = ['README']
74 self.build_tree(source_files)
75 tree.add(source_files)
76 tree.commit("one", rev_id='revid1')
77 tree.branch.tags.set_tag("upstream-0.1", tree.branch.last_revision())
78
79 cl_file = 'debian/changelog'
80 source_files = ['debian/'] + [cl_file]
81 self.build_tree(source_files)
82 c = self.make_changelog()
83 self.write_changelog(c, cl_file)
84 tree.add(source_files)
85 tree.commit("two", rev_id='revid2')
86 return tree
87
88 def test_get_orig_source_registered(self):
89 self.run_bzr("get-orig-source --help")
90
91 def test_get_orig_source_error_no_changelog(self):
92 self.run_bzr_error(
93 ['Could not find changelog at "debian/changelog" or "changelog".'],
94 "get-orig-source")
95
96 def test_get_orig_source_error_no_tar(self):
97 self.make_unpacked_source()
98 self.run_bzr_error(
99 ['Unable to find the needed upstream tarball for package test, '\
100 'version 0.1.'],
101 "get-orig-source")
102
103 def test_get_orig_source(self):
104 tree = self.make_source_with_upstream()
105 self.run_bzr(['get-orig-source'])
106 self.assertPathExists('../test_0.1.orig.tar.gz')

Subscribers

People subscribed via source and target branches