Merge lp:~mvo/pkgme/not-native-by-default into lp:pkgme

Proposed by Michael Vogt
Status: Merged
Approved by: James Westby
Approved revision: 126
Merged at revision: 123
Proposed branch: lp:~mvo/pkgme/not-native-by-default
Merge into: lp:pkgme
Diff against target: 135 lines (+74/-3)
5 files modified
pkgme/debuild.py (+32/-0)
pkgme/package_files.py (+1/-1)
pkgme/tests/test_debuild.py (+38/-0)
pkgme/tests/test_package_files.py (+1/-1)
pkgme/tests/test_script.py (+2/-1)
To merge this branch: bzr merge lp:~mvo/pkgme/not-native-by-default
Reviewer Review Type Date Requested Status
James Westby Approve
Michael Vogt Pending
Jonathan Lange Pending
Review via email: mp+116052@code.launchpad.net

This proposal supersedes a proposal from 2012-07-19.

Commit message

Build 3.0 (quilt) packages with an orig.tar.gz.

Description of the change

This branch make pkgme create non-native branches by default.

The reason I suggest this is:
- Its conceptually cleaner to split the package into the orig and the debian part. Now that is not very relevant.
- If the packaging needs tweaking or updating this way the packager just needs to update and upload debian changes instead of the entire package. For large packages this is a significant win. This will not be relevant anymore when pkgme is perfect.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote : Posted in a previous version of this proposal

<mvo> james_w: cool, so test+docstring+better place and we are good to go?
<james_w> mvo, I think so

I will work on this tomorrow morning.

review: Needs Fixing
Revision history for this message
Michael Vogt (mvo) wrote : Posted in a previous version of this proposal

I added a docstring and a (functional) test now. I also switched from source format 1.0 back to 3.0, but quilt this time. Please have a look at let me know what you think.

Revision history for this message
Jonathan Lange (jml) wrote : Posted in a previous version of this proposal

Code looks great, and thanks to your update I understand why we want to do this. Thank you!

review: Approve
Revision history for this message
Michael Vogt (mvo) wrote : Posted in a previous version of this proposal

After merging this broke the world^Wpkgme-service I modified it so that now build_orig_tar_gz() run as part of build_source_package() which is ok I think. Alternatively I can change pkgme-service if that is a preferable way to fix this problem.

review: Needs Resubmitting
lp:~mvo/pkgme/not-native-by-default updated
126. By Michael Vogt

merge trunk

Revision history for this message
Michael Vogt (mvo) wrote :

Re-merged trunk now.

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 'pkgme/debuild.py'
2--- pkgme/debuild.py 2012-07-20 13:12:24 +0000
3+++ pkgme/debuild.py 2012-07-20 19:25:25 +0000
4@@ -1,6 +1,8 @@
5 import os
6 import re
7
8+from debian.changelog import Changelog
9+
10 from pkgme.run_script import run_subprocess
11
12
13@@ -14,9 +16,39 @@
14
15
16 def build_source_package(directory, sign=True):
17+ """Build a source package using debuild"""
18+ build_orig_tar_gz(directory)
19 cmd = ['debuild', '--no-lintian', '-S']
20 if not sign:
21 cmd.extend(['-uc', '-us'])
22 output = run_subprocess(cmd, cwd=directory)
23 changes_file = find_changes_file(output)
24 return os.path.abspath(os.path.join(directory, changes_file))
25+
26+
27+def build_orig_tar_gz(target_dir):
28+ """Build a pkgname_version.orig.tar.gz from the target_dir.
29+
30+ This is usually run as part of build_source_package and does
31+ rarely need to be run on its own.
32+
33+ Note that this will expect a debian/ directory in the target_dir
34+ to gather pkgname/version but it will (of course) exclude debian/
35+ from the resulting .orig.tar.gz
36+ """
37+ changelog = Changelog(
38+ open(os.path.join(target_dir, "debian", "changelog")))
39+ pkgname = changelog.get_package()
40+ version = changelog.get_version()
41+ target_file = os.path.join(
42+ target_dir, "..", "%s_%s.orig.tar.gz" % (pkgname, version))
43+ cmd = ["tar",
44+ "-c",
45+ "-z",
46+ "--exclude", "debian",
47+ "--transform", "s,.,%s-%s," % (pkgname, version),
48+ "-f", target_file,
49+ ".",
50+ ]
51+ run_subprocess(cmd, cwd=target_dir)
52+ return target_file
53
54=== modified file 'pkgme/package_files.py'
55--- pkgme/package_files.py 2012-07-20 13:12:24 +0000
56+++ pkgme/package_files.py 2012-07-20 19:25:25 +0000
57@@ -249,7 +249,7 @@
58 filename = "source/format"
59
60 def get_contents(self):
61- return "1.0\n"
62+ return "3.0 (quilt)\n"
63
64
65 default_package_file_group.add_file_cls(SourceFormat)
66
67=== added file 'pkgme/tests/test_debuild.py'
68--- pkgme/tests/test_debuild.py 1970-01-01 00:00:00 +0000
69+++ pkgme/tests/test_debuild.py 2012-07-20 19:25:25 +0000
70@@ -0,0 +1,38 @@
71+import os
72+import tarfile
73+
74+from testtools import TestCase
75+
76+from pkgme.debuild import build_orig_tar_gz
77+from pkgme.testing import (
78+ TempdirFixture,
79+ )
80+
81+class DebuildTestCase(TestCase):
82+
83+ def test_build_orig_tar_gz(self):
84+ tempdir = self.useFixture(TempdirFixture())
85+ pkgdir = os.path.join(tempdir.path, "testpkg")
86+ # setup fake env
87+ os.makedirs(os.path.join(pkgdir, "debian"))
88+ changelog_path = os.path.join(pkgdir, "debian", "changelog")
89+ with open(changelog_path, "w") as f:
90+ f.write("""
91+testpkg (0.1) unstable; urgency=low
92+
93+ * some changes
94+
95+ -- Some Guy <foo@example.com> Thu, 19 Apr 2012 10:53:30 +0200
96+""")
97+ with open(os.path.join(pkgdir, "canary"), "w") as f:
98+ f.write("pieep")
99+ # build it
100+ result_path = build_orig_tar_gz(pkgdir)
101+ # verify
102+ self.assertEqual(
103+ "testpkg_0.1.orig.tar.gz", os.path.basename(result_path))
104+ with tarfile.open(result_path) as f:
105+ self.assertEqual(
106+ ["testpkg-0.1", "testpkg-0.1/canary"],
107+ [m.name for m in f.getmembers()])
108+
109
110=== modified file 'pkgme/tests/test_package_files.py'
111--- pkgme/tests/test_package_files.py 2012-07-20 13:12:24 +0000
112+++ pkgme/tests/test_package_files.py 2012-07-20 19:25:25 +0000
113@@ -444,7 +444,7 @@
114
115 def test_contents(self):
116 package_file = self.get_object()
117- self.assertEqual("1.0\n", package_file.get_contents())
118+ self.assertEqual("3.0 (quilt)\n", package_file.get_contents())
119
120 def test_overwrite(self):
121 package_file = self.get_object()
122
123=== modified file 'pkgme/tests/test_script.py'
124--- pkgme/tests/test_script.py 2012-07-20 13:12:24 +0000
125+++ pkgme/tests/test_script.py 2012-07-20 19:25:25 +0000
126@@ -73,7 +73,8 @@
127 self.create_marker_file(tempdir, prefix="foo")
128 self.run_script(tempdir.abspath('foo'))
129 self.assertThat(tempdir.path, DirContains(
130- ["foo_0.0.0.tar.gz",
131+ ["foo_0.0.0.orig.tar.gz",
132+ "foo_0.0.0.debian.tar.gz",
133 "foo_0.0.0.dsc",
134 "foo_0.0.0_source.build",
135 "foo_0.0.0_source.changes",

Subscribers

People subscribed via source and target branches

to all changes: