Merge lp:~jelmer/bzr-builder/pristine-tar-upstream into lp:bzr-builder

Proposed by Jelmer Vernooij
Status: Merged
Approved by: James Westby
Approved revision: 140
Merged at revision: 132
Proposed branch: lp:~jelmer/bzr-builder/pristine-tar-upstream
Merge into: lp:bzr-builder
Prerequisite: lp:~jelmer/bzr-builder/deprecation-warnings
Diff against target: 554 lines (+265/-43)
3 files modified
cmds.py (+113/-33)
tests/__init__.py (+18/-1)
tests/test_blackbox.py (+134/-9)
To merge this branch: bzr merge lp:~jelmer/bzr-builder/pristine-tar-upstream
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+63494@code.launchpad.net

Description of the change

Support creating .orig.tar.gz / .orig.tar.bz2 files from the base branch for non-native packages. bzr-builder will look for a upstream-<VERSION> to export, where VERSION is the upstream version part extracted from the current changelog entry's version string.

Pristine tar delta information set by bzr-builddeb will be used to reconstruct the orig tarball, if present.

This adds a --allow-fallback-to-native option which makes bzr-builder force non-native packages to be native if it can not find a upstream-<VERSION> tag in the base branch. This option gives behaviour compatible with that of current bzr-builder.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Hi,

Thanks for doing this!

81 - version = base_branch.deb_version
82 - if "-" in version:
83 - version = version[:version.rindex("-")]
84 - package_basedir = "%s-%s" % (package_name, version)
85 + package_basedir = "%s-%s" % (package_name, package_version.upstream_version)

This does actually change behaviour if the version has an epoch, is that ok?

148 +def reconstruct_pristine_tar(dest, delta, dest_filename):

I guessed that these were going to come from the code you split out in bzr-builddeb.
Was that the intention?

Thanks,

James

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

On Mon, 2011-06-06 at 16:19 +0000, James Westby wrote:
> Thanks for doing this!
My pleasure :) This should means that at least these things are out of
the way when there's some developer time available to work on the
Launchpad side of build-from-branch-into-ppa/primary.

> 81 - version = base_branch.deb_version
> 82 - if "-" in version:
> 83 - version = version[:version.rindex("-")]
> 84 - package_basedir = "%s-%s" % (package_name, version)
> 85 + package_basedir = "%s-%s" % (package_name, package_version.upstream_version)
>
> This does actually change behaviour if the version has an epoch, is that ok?
Yep, that's fine - though that's a good catch, I hadn't considered it
earlier.

> 148 +def reconstruct_pristine_tar(dest, delta, dest_filename):
>
> I guessed that these were going to come from the code you split out in bzr-builddeb.
> Was that the intention?
That was my original intention but it turned out to be a really trivial
function in the end and it could even be made shorter by using the
_run_command utility function in bzr-builder.

Cheers,

Jelmer

Revision history for this message
James Westby (james-w) wrote :

On Mon, 06 Jun 2011 16:57:29 -0000, Jelmer Vernooij <email address hidden> wrote:
> > 148 +def reconstruct_pristine_tar(dest, delta, dest_filename):
> >
> > I guessed that these were going to come from the code you split out in bzr-builddeb.
> > Was that the intention?
> That was my original intention but it turned out to be a really trivial
> function in the end and it could even be made shorter by using the
> _run_command utility function in bzr-builder.

Should we move _run_command to bzr-builddeb and make it smaller there
and re-use it here?

Are there drawbacks to depending on bzr-builddeb?

Thanks,

James

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

On Mon, 2011-06-06 at 19:37 +0000, James Westby wrote:
> On Mon, 06 Jun 2011 16:57:29 -0000, Jelmer Vernooij <email address hidden> wrote:
> > > 148 +def reconstruct_pristine_tar(dest, delta, dest_filename):
> > >
> > > I guessed that these were going to come from the code you split out in bzr-builddeb.
> > > Was that the intention?
> > That was my original intention but it turned out to be a really trivial
> > function in the end and it could even be made shorter by using the
> > _run_command utility function in bzr-builder.
> Should we move _run_command to bzr-builddeb and make it smaller there
> and re-use it here?
I think it'd be reasonable to have _run_command in bzr-builddeb too.

> Are there drawbacks to depending on bzr-builddeb?
I'm not sure - I never understood why they were separate in the first
place?

The main drawback I can think of is that it makes backporting
bzr-builder to lucid-cat more problematic, but that's a minor point.

On the plus side, it would mean that we can use more convenience code
from bzr-builddeb, which would be nice.

Cheers,

Jelmer

Revision history for this message
James Westby (james-w) wrote :

On Mon, 06 Jun 2011 19:46:25 -0000, Jelmer Vernooij <email address hidden> wrote:
> > Are there drawbacks to depending on bzr-builddeb?
> I'm not sure - I never understood why they were separate in the first
> place?
>
> The main drawback I can think of is that it makes backporting
> bzr-builder to lucid-cat more problematic, but that's a minor point.
>
> On the plus side, it would mean that we can use more convenience code
> from bzr-builddeb, which would be nice.

They were separate mainly as the core of bzr-builder code has nothing to
do with building packages, and they started out as two separate projects
in my mind.

I wouldn't be against merging the projects, and certainly I'm for
re-using code where possible.

Do you think they should be one project?

Thanks,

James

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

On Mon, 2011-06-06 at 20:31 +0000, James Westby wrote:
> On Mon, 06 Jun 2011 19:46:25 -0000, Jelmer Vernooij <email address hidden> wrote:
> > > Are there drawbacks to depending on bzr-builddeb?
> > I'm not sure - I never understood why they were separate in the first
> > place?
> >
> > The main drawback I can think of is that it makes backporting
> > bzr-builder to lucid-cat more problematic, but that's a minor point.
> >
> > On the plus side, it would mean that we can use more convenience code
> > from bzr-builddeb, which would be nice.
>
> They were separate mainly as the core of bzr-builder code has nothing to
> do with building packages, and they started out as two separate projects
> in my mind.
>
> I wouldn't be against merging the projects, and certainly I'm for
> re-using code where possible.
>
> Do you think they should be one project?
I think that distinction makes sense - I certainly think it would be
nice to keep the Debian-specific bits isolated.

Perhaps they can be separate projects, with bzr-builddeb as an optional
dependency for those bits ("bzr dailydeb") of bzr-builder that are
Debian-specific?

Especially now that deb-version is optional there is no reason that
things like "bzr build" couldn't be used for operations unrelated to
Debian packages.

Cheers,

Jelmer

Revision history for this message
James Westby (james-w) wrote :

On Mon, 06 Jun 2011 21:42:29 -0000, Jelmer Vernooij <email address hidden> wrote:
> I think that distinction makes sense - I certainly think it would be
> nice to keep the Debian-specific bits isolated.
>
> Perhaps they can be separate projects, with bzr-builddeb as an optional
> dependency for those bits ("bzr dailydeb") of bzr-builder that are
> Debian-specific?
>
> Especially now that deb-version is optional there is no reason that
> things like "bzr build" couldn't be used for operations unrelated to
> Debian packages.

That sounds like a good distinction to me.

Thanks,

James

Revision history for this message
James Westby (james-w) wrote :

This looks fine to me.

I'd like the longer term aim to be more code sharing where it makes
sense.

Thanks,

James

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-06-01 18:48:43 +0000
3+++ cmds.py 2011-06-05 17:20:55 +0000
4@@ -15,6 +15,7 @@
5
6 """Subcommands provided by bzr-builder."""
7
8+from base64 import standard_b64decode
9 from StringIO import StringIO
10 import datetime
11 from email import utils
12@@ -22,6 +23,7 @@
13 import os
14 import pwd
15 import re
16+import signal
17 import socket
18 import shutil
19 import subprocess
20@@ -36,6 +38,7 @@
21
22 from bzrlib import (
23 errors,
24+ export as _mod_export,
25 lazy_regex,
26 trace,
27 transport as _mod_transport,
28@@ -193,16 +196,16 @@
29 return (maintainer, email)
30
31
32-def add_autobuild_changelog_entry(base_branch, basedir, distribution=None,
33- package=None, author_name=None, author_email=None,
34+def add_autobuild_changelog_entry(base_branch, basedir, package,
35+ distribution=None, author_name=None, author_email=None,
36 append_version=None):
37 """Add a new changelog entry for an autobuild.
38
39 :param base_branch: Recipe base branch
40 :param basedir: Base working directory
41+ :param package: package name
42 :param distribution: Optional distribution (defaults to last entry
43 distribution)
44- :param package: Optional package name (defaults to last entry package name)
45 :param author_name: Name of the build requester
46 :param author_email: Email of the build requester
47 :param append_version: Optional version suffix to add
48@@ -225,8 +228,6 @@
49 if len(cl._blocks) > 0:
50 if distribution is None:
51 distribution = cl._blocks[0].distributions.split()[0]
52- if package is None:
53- package = cl._blocks[0].package
54 else:
55 if file_found:
56 if len(contents.strip()) > 0:
57@@ -236,10 +237,6 @@
58 reason = "debian/changelog was empty"
59 else:
60 reason = "debian/changelog was not present"
61- if package is None:
62- raise errors.BzrCommandError("No previous changelog to "
63- "take the package name from, and --package not "
64- "specified: %s." % reason)
65 if distribution is None:
66 distribution = DEFAULT_UBUNTU_DISTRIBUTION
67 try:
68@@ -274,23 +271,21 @@
69 cl_f.close()
70
71
72-def calculate_package_dir(base_branch, package_name, working_basedir):
73+def calculate_package_dir(package_name, package_version, working_basedir):
74 """Calculate the directory name that should be used while debuilding.
75
76 :param base_branch: Recipe base branch
77+ :param package_version: Version of the package
78 :param package_name: Package name
79 :param working_basedir: Base directory
80 """
81- version = base_branch.deb_version
82- if "-" in version:
83- version = version[:version.rindex("-")]
84- package_basedir = "%s-%s" % (package_name, version)
85+ package_basedir = "%s-%s" % (package_name, package_version.upstream_version)
86 package_dir = os.path.join(working_basedir, package_basedir)
87 return package_dir
88
89
90 def _run_command(command, basedir, msg, error_msg,
91- not_installed_msg=None, env=None, success_exit_codes=None):
92+ not_installed_msg=None, env=None, success_exit_codes=None, indata=None):
93 """ Run a command in a subprocess.
94
95 :param command: list with command and parameters
96@@ -300,7 +295,10 @@
97 isn't available.
98 :param env: Optional environment to use rather than os.environ.
99 :param success_exit_codes: Exit codes to consider succesfull, defaults to [0].
100+ :param indata: Data to write to standard input
101 """
102+ def subprocess_setup():
103+ signal.signal(signal.SIGPIPE, signal.SIG_DFL)
104 trace.note(msg)
105 # Hide output if -q is in use.
106 quiet = trace.is_quiet()
107@@ -310,16 +308,17 @@
108 kwargs = {}
109 if env is not None:
110 kwargs["env"] = env
111+ trace.mutter("running: %r", command)
112 try:
113 proc = subprocess.Popen(command, cwd=basedir,
114- stdin=subprocess.PIPE, **kwargs)
115+ stdin=subprocess.PIPE, preexec_fn=subprocess_setup, **kwargs)
116 except OSError, e:
117 if e.errno != errno.ENOENT:
118 raise
119 if not_installed_msg is None:
120 raise
121 raise MissingDependency(msg=not_installed_msg)
122- output = proc.communicate()
123+ output = proc.communicate(indata)
124 if success_exit_codes is None:
125 success_exit_codes = [0]
126 if proc.returncode not in success_exit_codes:
127@@ -329,9 +328,13 @@
128 raise errors.BzrCommandError(error_msg)
129
130
131-def build_source_package(basedir):
132- command = ["/usr/bin/debuild", "--no-tgz-check", "-i", "-I", "-S",
133- "-uc", "-us"]
134+def build_source_package(basedir, tgz_check=True):
135+ command = ["/usr/bin/debuild"]
136+ if tgz_check:
137+ command.append("--tgz-check")
138+ else:
139+ command.append("--no-tgz-check")
140+ command.extend(["-i", "-I", "-S", "-uc", "-us"])
141 _run_command(command, basedir,
142 "Building the source package",
143 "Failed to build the source package",
144@@ -546,6 +549,59 @@
145 return control["Source"]
146
147
148+def reconstruct_pristine_tar(dest, delta, dest_filename):
149+ """Reconstruct a pristine tarball from a directory and a delta.
150+
151+ :param dest: Directory to pack
152+ :param delta: pristine-tar delta
153+ :param dest_filename: Destination filename
154+ """
155+ command = ["pristine-tar", "gentar", "-",
156+ os.path.abspath(dest_filename)]
157+ _run_command(command, dest,
158+ "Reconstructing pristine tarball",
159+ "Generating tar from delta failed",
160+ not_installed_msg="pristine-tar is not installed",
161+ indata=delta)
162+
163+
164+def extract_upstream_tarball(branch, package, version, dest_dir):
165+ """Extract the upstream tarball from a branch.
166+
167+ :param branch: Branch with the upstream pristine tar data
168+ :param package: Package name
169+ :param version: Package version
170+ :param dest_dir: Destination directory
171+ """
172+ tag_name = "upstream-%s" % version
173+ revid = branch.tags.lookup_tag(tag_name)
174+ tree = branch.repository.revision_tree(revid)
175+ rev = branch.repository.get_revision(revid)
176+ if 'deb-pristine-delta' in rev.properties:
177+ uuencoded = rev.properties['deb-pristine-delta']
178+ dest_filename = "%s_%s.orig.tar.gz" % (package, version)
179+ elif 'deb-pristine-delta-bz2' in rev.properties:
180+ uuencoded = rev.properties['deb-pristine-delta-bz2']
181+ dest_filename = "%s_%s.orig.tar.bz2" % (package, version)
182+ else:
183+ uuencoded = None
184+ if uuencoded is not None:
185+ delta = standard_b64decode(uuencoded)
186+ dest = os.path.join(dest_dir, "orig")
187+ try:
188+ _mod_export.export(tree, dest, format='dir')
189+ reconstruct_pristine_tar(dest, delta,
190+ os.path.join(dest_dir, dest_filename))
191+ finally:
192+ if os.path.exists(dest):
193+ shutil.rmtree(dest)
194+ else:
195+ # Default to .tar.gz
196+ dest_filename = "%s_%s.orig.tar.gz" % (package, version)
197+ _mod_export.export(tree, os.path.join(dest_dir, dest_filename),
198+ per_file_timestamps=True)
199+
200+
201 class cmd_dailydeb(cmd_build):
202 """Build a deb based on a 'recipe' or from a branch.
203
204@@ -583,6 +639,9 @@
205 "in debian/changelog."),
206 Option("safe", help="Error if the recipe would cause"
207 " arbitrary code execution."),
208+ Option("allow-fallback-to-native",
209+ help="Allow falling back to a native package if the upstream "
210+ "tarball can not be found."),
211 ]
212
213 takes_args = ["location", "working_basedir?"]
214@@ -590,7 +649,7 @@
215 def run(self, location, working_basedir=None, manifest=None,
216 if_changed_from=None, package=None, distribution=None,
217 dput=None, key_id=None, no_build=None, watch_ppa=False,
218- append_version=None, safe=False):
219+ append_version=None, safe=False, allow_fallback_to_native=False):
220
221 if dput is not None and key_id is None:
222 raise errors.BzrCommandError("You must specify --key-id if you "
223@@ -617,8 +676,12 @@
224 if not os.path.exists(working_basedir):
225 os.makedirs(working_basedir)
226 package_name = self._calculate_package_name(location, package)
227- working_directory = os.path.join(working_basedir,
228- "%s-%s" % (package_name, self._template_version))
229+ if self._template_version is None:
230+ working_directory = os.path.join(working_basedir,
231+ "%s-direct" % (package_name,))
232+ else:
233+ working_directory = os.path.join(working_basedir,
234+ "%s-%s" % (package_name, self._template_version))
235 try:
236 # we want to use a consistent package_dir always to support
237 # updates in place, but debuild etc want PACKAGE-UPSTREAMVERSION
238@@ -628,11 +691,13 @@
239 manifest_path = os.path.join(working_directory, "debian",
240 "bzr-builder.manifest")
241 build_tree(base_branch, working_directory)
242- if package is None:
243- control_path = os.path.join(working_directory, "debian", "control")
244- if not os.path.exists(control_path):
245- raise errors.BzrCommandError("Missing debian/control file to "
246- "read package name from.")
247+ control_path = os.path.join(working_directory, "debian", "control")
248+ if not os.path.exists(control_path):
249+ if package is None:
250+ raise errors.BzrCommandError("No control file to "
251+ "take the package name from, and --package not "
252+ "specified.")
253+ else:
254 package = debian_source_package_name(control_path)
255 write_manifest_to_transport(manifest_path, base_branch,
256 possible_transports)
257@@ -640,16 +705,20 @@
258 if autobuild:
259 # Add changelog also substitutes {debupstream}.
260 add_autobuild_changelog_entry(base_branch, working_directory,
261- distribution=distribution, package=package,
262+ package, distribution=distribution,
263 append_version=append_version)
264 else:
265 if append_version:
266 raise errors.BzrCommandError("--append-version only "
267 "supported for autobuild recipes (with a 'deb-version' "
268 "header)")
269- force_native_format(working_directory)
270- package_dir = calculate_package_dir(base_branch,
271- package_name, working_basedir)
272+ with open(os.path.join(working_directory, "debian", "changelog")) as cl_f:
273+ contents = cl_f.read()
274+ cl = changelog.Changelog(file=contents)
275+ package_name = cl.package
276+ package_version = cl.version
277+ package_dir = calculate_package_dir(package_name, package_version,
278+ working_basedir)
279 # working_directory -> package_dir: after this debian stuff works.
280 os.rename(working_directory, package_dir)
281 if no_build:
282@@ -657,8 +726,19 @@
283 write_manifest_to_transport(manifest, base_branch,
284 possible_transports)
285 return 0
286+ if package_version.debian_revision is not None:
287+ # Non-native package
288+ try:
289+ extract_upstream_tarball(base_branch.branch, package_name,
290+ package_version.upstream_version, working_basedir)
291+ except errors.NoSuchTag:
292+ if not allow_fallback_to_native:
293+ raise
294+ if allow_fallback_to_native:
295+ force_native_format(package_dir)
296 try:
297- build_source_package(package_dir)
298+ build_source_package(package_dir,
299+ tgz_check=not allow_fallback_to_native)
300 if key_id is not None:
301 sign_source_package(package_dir, key_id)
302 if dput is not None:
303
304=== modified file 'tests/__init__.py'
305--- tests/__init__.py 2009-10-23 00:14:10 +0000
306+++ tests/__init__.py 2011-06-05 17:20:55 +0000
307@@ -13,8 +13,25 @@
308 # You should have received a copy of the GNU General Public License along
309 # with this program. If not, see <http://www.gnu.org/licenses/>.
310
311+import os
312 from unittest import TestSuite
313-from bzrlib.tests import TestUtil
314+from bzrlib.tests import (
315+ Feature,
316+ TestUtil,
317+ )
318+
319+
320+class _PristineTarFeature(Feature):
321+
322+ def feature_name(self):
323+ return '/usr/bin/pristine-tar'
324+
325+ def _probe(self):
326+ return os.path.exists("/usr/bin/pristine-tar")
327+
328+
329+PristineTarFeature = _PristineTarFeature()
330+
331
332 def test_suite():
333 loader = TestUtil.TestLoader()
334
335=== modified file 'tests/test_blackbox.py'
336--- tests/test_blackbox.py 2011-06-05 17:20:55 +0000
337+++ tests/test_blackbox.py 2011-06-05 17:20:55 +0000
338@@ -13,15 +13,49 @@
339 # You should have received a copy of the GNU General Public License along
340 # with this program. If not, see <http://www.gnu.org/licenses/>.
341
342+from base64 import standard_b64encode
343 import os
344+import signal
345+import subprocess
346 from textwrap import dedent
347
348-from bzrlib import workingtree
349+from bzrlib import (
350+ export as _mod_export,
351+ osutils,
352+ workingtree,
353+ )
354+from bzrlib.branch import Branch
355 from bzrlib.tests import (
356 TestCaseWithTransport,
357 )
358
359
360+from bzrlib.plugins.builder.tests import PristineTarFeature
361+
362+
363+def make_pristine_tar_delta(dest, tarball_path):
364+ """Create a pristine-tar delta for a tarball.
365+
366+ :param dest: Directory to generate pristine tar delta for
367+ :param tarball_path: Path to the tarball
368+ :return: pristine-tarball
369+ """
370+ def subprocess_setup():
371+ signal.signal(signal.SIGPIPE, signal.SIG_DFL)
372+ # If tarball_path is relative, the cwd=dest parameter to Popen will make
373+ # pristine-tar faaaail. pristine-tar doesn't use the VFS either, so we
374+ # assume local paths.
375+ tarball_path = osutils.abspath(tarball_path)
376+ command = ["pristine-tar", "gendelta", tarball_path, "-"]
377+ proc = subprocess.Popen(command, stdout=subprocess.PIPE,
378+ cwd=dest, preexec_fn=subprocess_setup,
379+ stderr=subprocess.PIPE)
380+ (stdout, stderr) = proc.communicate()
381+ if proc.returncode != 0:
382+ raise Exception("Generating delta from tar failed: %s" % stderr)
383+ return stdout
384+
385+
386 class BlackboxBuilderTests(TestCaseWithTransport):
387
388 if not getattr(TestCaseWithTransport, "assertPathDoesNotExist", None):
389@@ -230,6 +264,40 @@
390 out, err = self.run_bzr("dailydeb -q test.recipe "
391 "--manifest manifest --if-changed-from bar")
392
393+ def make_upstream_version(self, version, contents,
394+ pristine_tar_format=None):
395+ upstream = self.make_branch_and_tree("upstream")
396+ self.build_tree_contents(contents)
397+ upstream.smart_add([upstream.basedir])
398+ revprops = {}
399+ if pristine_tar_format is not None:
400+ _mod_export.export(upstream, "export")
401+ if pristine_tar_format == "gz":
402+ tarfile_path = "export.tar.gz"
403+ _mod_export.export(upstream, tarfile_path, "tgz")
404+ revprops["deb-pristine-delta"] = standard_b64encode(
405+ make_pristine_tar_delta(
406+ "export", "export.tar.gz"))
407+ elif pristine_tar_format == "bz2":
408+ tarfile_path = "export.tar.bz2"
409+ _mod_export.export(upstream, tarfile_path, "tbz2")
410+ revprops["deb-pristine-delta-bz2"] = standard_b64encode(
411+ make_pristine_tar_delta(
412+ "export", "export.tar.bz2"))
413+ else:
414+ raise AssertionError("unknown pristine tar format %s" %
415+ pristine_tar_format)
416+ else:
417+ tarfile_path = "export.tar.gz"
418+ _mod_export.export(upstream, tarfile_path, "tgz")
419+ tarfile_sha1 = osutils.sha_file_by_name(tarfile_path)
420+ revid = upstream.commit("import upstream %s" % version,
421+ revprops=revprops)
422+ source = Branch.open("source")
423+ source.repository.fetch(upstream.branch.repository)
424+ source.tags.set_tag("upstream-%s" % version, revid)
425+ return tarfile_sha1
426+
427 def make_simple_package(self):
428 source = self.make_branch_and_tree("source")
429 self.build_tree(["source/a", "source/debian/"])
430@@ -254,7 +322,7 @@
431 "--manifest manifest --no-build working")
432 new_cl_contents = ("package (1) unstable; urgency=low\n\n"
433 " * Auto build.\n\n -- M. Maintainer <maint@maint.org> ")
434- f = open("working/test-1/debian/changelog")
435+ f = open("working/package-1/debian/changelog")
436 try:
437 actual_cl_contents = f.read()
438 finally:
439@@ -283,7 +351,8 @@
440 self.make_simple_package()
441 self.build_tree_contents([("test.recipe", "# bzr-builder format 0.1 "
442 "deb-version {debupstream}-2\nsource 1\n")])
443- out, err = self.run_bzr("dailydeb -q test.recipe working")
444+ out, err = self.run_bzr(
445+ "dailydeb --allow-fallback-to-native -q test.recipe working")
446 new_cl_contents = ("package (0.1-2) unstable; urgency=low\n\n"
447 " * Auto build.\n\n -- M. Maintainer <maint@maint.org> ")
448 f = open("working/test-{debupstream}-2/debian/changelog")
449@@ -342,12 +411,64 @@
450 source.commit("set source format")
451 return source
452
453+ def test_cmd_dailydeb_missing_orig_tarball(self):
454+ self.make_simple_quilt_package()
455+ self.build_tree_contents([("test.recipe", "# bzr-builder format 0.3 "
456+ "deb-version 1-1\nsource 1\n")])
457+ out, err = self.run_bzr(
458+ "dailydeb -q test.recipe working",
459+ retcode=3)
460+ self.assertEquals("", out)
461+ self.assertEquals('bzr: ERROR: No such tag: upstream-1\n', err)
462+
463+ def test_cmd_dailydeb_with_orig_tarball(self):
464+ self.make_simple_package()
465+ self.make_upstream_version("0.1", [("upstream/file", "content\n")])
466+ self.build_tree_contents([("test.recipe", "# bzr-builder format 0.3 "
467+ "deb-version 0.1-1\nsource\n")])
468+ out, err = self.run_bzr(
469+ "dailydeb -q test.recipe working",
470+ retcode=0)
471+ self.assertPathExists("working/package_0.1.orig.tar.gz")
472+ self.assertPathExists("working/package_0.1-1.diff.gz")
473+
474+ def test_cmd_dailydeb_with_pristine_orig_gz_tarball(self):
475+ self.requireFeature(PristineTarFeature)
476+ self.make_simple_package()
477+ pristine_tar_sha1 = self.make_upstream_version("0.1",
478+ [("upstream/file", "content\n")], pristine_tar_format="gz")
479+ self.build_tree_contents([("test.recipe", "# bzr-builder format 0.3 "
480+ "deb-version 0.1-1\nsource\n")])
481+ out, err = self.run_bzr("dailydeb -q test.recipe working",
482+ retcode=0)
483+ self.assertPathExists("working/package_0.1.orig.tar.gz")
484+ self.assertPathExists("working/package_0.1-1.diff.gz")
485+ self.assertEquals(
486+ osutils.sha_file_by_name("working/package_0.1.orig.tar.gz"),
487+ pristine_tar_sha1)
488+
489+ def test_cmd_dailydeb_with_pristine_orig_bz2_tarball(self):
490+ self.requireFeature(PristineTarFeature)
491+ self.make_simple_quilt_package()
492+ pristine_tar_sha1 = self.make_upstream_version("0.1",
493+ [("upstream/file", "content\n")], pristine_tar_format="bz2")
494+ self.build_tree_contents([("test.recipe", "# bzr-builder format 0.3 "
495+ "deb-version 0.1-1\nsource\n")])
496+ out, err = self.run_bzr("dailydeb -q test.recipe working",
497+ retcode=0)
498+ self.assertPathExists("working/package_0.1.orig.tar.bz2")
499+ self.assertPathExists("working/package_0.1-1.debian.tar.gz")
500+ self.assertEquals(
501+ osutils.sha_file_by_name("working/package_0.1.orig.tar.bz2"),
502+ pristine_tar_sha1)
503+
504 def test_cmd_dailydeb_force_native(self):
505 self.make_simple_quilt_package()
506 self.build_tree_contents([("test.recipe", "# bzr-builder format 0.3 "
507 "deb-version 1\nsource 2\n")])
508 out, err = self.run_bzr(
509- "dailydeb -q test.recipe working", retcode=0)
510+ "dailydeb --allow-fallback-to-native -q test.recipe working",
511+ retcode=0)
512 self.assertFileEqual("3.0 (native)\n",
513 "working/test-1/debian/source/format")
514
515@@ -361,7 +482,8 @@
516 source.add(["debian/patches", "debian/patches/series"])
517 source.commit("add patches")
518 out, err = self.run_bzr(
519- "dailydeb -q test.recipe working", retcode=0)
520+ "dailydeb --allow-fallback-to-native -q test.recipe working",
521+ retcode=0)
522 self.assertFileEqual("3.0 (native)\n",
523 "working/test-1/debian/source/format")
524 self.assertPathDoesNotExist("working/test-1/debian/patches")
525@@ -388,7 +510,8 @@
526 self.build_tree_contents([("test.recipe", "# bzr-builder format 0.3 "
527 "deb-version 1\nsource\n")])
528 out, err = self.run_bzr(
529- "dailydeb -q test.recipe working", retcode=0)
530+ "dailydeb --allow-fallback-to-native -q test.recipe working",
531+ retcode=0)
532 self.assertFileEqual("3.0 (native)\n",
533 "working/test-1/debian/source/format")
534 self.assertFileEqual("new-contents\n",
535@@ -415,8 +538,10 @@
536 source.commit("add patch")
537
538 self.build_tree_contents([("test.recipe", "# bzr-builder format 0.3 "
539- "deb-version 1\nsource 3\n")])
540- out, err = self.run_bzr("dailydeb -q test.recipe working", retcode=3)
541+ "deb-version 1-1\nsource 3\n")])
542+ out, err = self.run_bzr(
543+ "dailydeb --allow-fallback-to-native -q test.recipe working",
544+ retcode=3)
545 self.assertContainsRe(err, "bzr: ERROR: Failed to apply quilt patches")
546
547 def test_unknown_source_format(self):
548@@ -430,5 +555,5 @@
549 self.build_tree_contents([("test.recipe", "# bzr-builder format 0.3 "
550 "deb-version 1\nsource\n")])
551 out, err = self.run_bzr(
552- "dailydeb -q test.recipe working", retcode=3)
553+ "dailydeb --allow-fallback-to-native -q test.recipe working", retcode=3)
554 self.assertEquals(err, "bzr: ERROR: Unknown source format 2.0\n")

Subscribers

People subscribed via source and target branches