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

Proposed by Michael Vogt
Status: Superseded
Proposed branch: lp:~mvo/pkgme/not-native-by-default
Merge into: lp:pkgme
Diff against target: 155 lines (+75/-4)
6 files modified
pkgme/bin/main.py (+5/-1)
pkgme/debuild.py (+28/-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
Michael Vogt (community) Needs Resubmitting
Jonathan Lange Approve
Review via email: mp+115805@code.launchpad.net

This proposal has been superseded by a proposal from 2012-07-20.

Commit message

Make non-native packages by default.

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.

This is a modified version of the previous version that avoids breaking pkgme-service by making build_orig_tar_gz part of build_source_package.

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

<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 :

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 :

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 :

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

Unmerged revisions

Preview Diff

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

Subscribers

People subscribed via source and target branches

to all changes: