Merge lp:~mvo/click/lp1219912-build-exclude into lp:click

Proposed by Michael Vogt
Status: Superseded
Proposed branch: lp:~mvo/click/lp1219912-build-exclude
Merge into: lp:click
Diff against target: 339 lines (+107/-109)
5 files modified
click/build.py (+48/-71)
click/commands/build.py (+5/-0)
click/commands/buildsource.py (+5/-0)
click/tests/test_build.py (+34/-34)
doc/manpage.rst (+15/-4)
To merge this branch: bzr merge lp:~mvo/click/lp1219912-build-exclude
Reviewer Review Type Date Requested Status
click hackers Pending
Review via email: mp+219503@code.launchpad.net

This proposal has been superseded by a proposal from 2014-05-15.

Description of the change

This branch adds a new "--ignore" option to click {build,buildsource} to fix #1219912.

To post a comment you must log in.
431. By Michael Vogt

merged lp:click/devel

432. By Michael Vogt

merged lp:click/devel

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'click/build.py'
2--- click/build.py 2014-05-05 13:10:19 +0000
3+++ click/build.py 2014-05-14 11:49:16 +0000
4@@ -83,6 +83,42 @@
5 class ClickBuilderBase:
6 def __init__(self):
7 self.file_map = {}
8+ # From @Dpkg::Source::Package::tar_ignore_default_pattern.
9+ # (more in ClickSourceBuilder)
10+ self._ignore_patterns = [
11+ "*.click",
12+ ".*.sw?",
13+ "*~",
14+ ",,*",
15+ ".[#~]*",
16+ ".arch-ids",
17+ ".arch-inventory",
18+ ".bzr",
19+ ".bzr-builddeb",
20+ ".bzr.backup",
21+ ".bzr.tags",
22+ ".bzrignore",
23+ ".cvsignore",
24+ ".git",
25+ ".gitattributes",
26+ ".gitignore",
27+ ".gitmodules",
28+ ".hg",
29+ ".hgignore",
30+ ".hgsigs",
31+ ".hgtags",
32+ ".shelf",
33+ ".svn",
34+ "CVS",
35+ "DEADJOE",
36+ "RCS",
37+ "_MTN",
38+ "_darcs",
39+ "{arch}",
40+ ]
41+
42+ def add_ignore_pattern(self, pattern):
43+ self._ignore_patterns.append(pattern)
44
45 def add_file(self, source_path, dest_path):
46 self.file_map[source_path] = dest_path
47@@ -132,39 +168,6 @@
48
49
50 class ClickBuilder(ClickBuilderBase):
51- # TODO: This should be configurable, or at least extensible.
52- _ignore_patterns = [
53- "*.click",
54- ".*.sw?",
55- "*~",
56- ",,*",
57- ".[#~]*",
58- ".arch-ids",
59- ".arch-inventory",
60- ".be",
61- ".bzr",
62- ".bzr-builddeb",
63- ".bzr.backup",
64- ".bzr.tags",
65- ".bzrignore",
66- ".cvsignore",
67- ".git",
68- ".gitattributes",
69- ".gitignore",
70- ".gitmodules",
71- ".hg",
72- ".hgignore",
73- ".hgsigs",
74- ".hgtags",
75- ".shelf",
76- ".svn",
77- "CVS",
78- "DEADJOE",
79- "RCS",
80- "_MTN",
81- "_darcs",
82- "{arch}",
83- ]
84
85 def list_files(self, root_path):
86 for dirpath, _, filenames in os.walk(root_path):
87@@ -295,44 +298,18 @@
88
89
90 class ClickSourceBuilder(ClickBuilderBase):
91- # From @Dpkg::Source::Package::tar_ignore_default_pattern.
92- # TODO: This should be configurable, or at least extensible.
93- _ignore_patterns = [
94- "*.a",
95- "*.click",
96- "*.la",
97- "*.o",
98- "*.so",
99- ".*.sw?",
100- "*~",
101- ",,*",
102- ".[#~]*",
103- ".arch-ids",
104- ".arch-inventory",
105- ".be",
106- ".bzr",
107- ".bzr-builddeb",
108- ".bzr.backup",
109- ".bzr.tags",
110- ".bzrignore",
111- ".cvsignore",
112- ".deps",
113- ".git",
114- ".gitattributes",
115- ".gitignore",
116- ".gitmodules",
117- ".hg",
118- ".hgignore",
119- ".hgsigs",
120- ".hgtags",
121- ".shelf",
122- ".svn",
123- "CVS",
124- "DEADJOE",
125- "RCS",
126- "_MTN",
127- "_darcs",
128- "{arch}",
129+
130+ def __init__(self):
131+ super(ClickSourceBuilder, self).__init__()
132+ # From @Dpkg::Source::Package::tar_ignore_default_pattern.
133+ # (more in ClickBuilderBase)
134+ self._ignore_patterns += [
135+ "*.a",
136+ ".be",
137+ ".deps",
138+ "*.la",
139+ "*.o",
140+ "*.so",
141 ]
142
143 def build(self, dest_dir, manifest_path=None):
144
145=== modified file 'click/commands/build.py'
146--- click/commands/build.py 2013-12-06 11:04:47 +0000
147+++ click/commands/build.py 2014-05-14 11:49:16 +0000
148@@ -29,6 +29,9 @@
149 parser.add_option(
150 "-m", "--manifest", metavar="PATH", default="manifest.json",
151 help="read package manifest from PATH (default: manifest.json)")
152+ parser.add_option(
153+ "-I", "--ignore", metavar="file-pattern", action='append',
154+ help="Ignore the given pattern when building the package")
155 options, args = parser.parse_args(argv)
156 if len(args) < 1:
157 parser.error("need directory")
158@@ -43,6 +46,8 @@
159 (directory, options.manifest))
160 builder = ClickBuilder()
161 builder.add_file(directory, "./")
162+ for ignore in options.ignore:
163+ builder.add_ignore_pattern(ignore)
164 try:
165 path = builder.build(".", manifest_path=options.manifest)
166 except ClickBuildError as e:
167
168=== modified file 'click/commands/buildsource.py'
169--- click/commands/buildsource.py 2013-12-06 11:04:47 +0000
170+++ click/commands/buildsource.py 2014-05-14 11:49:16 +0000
171@@ -29,6 +29,9 @@
172 parser.add_option(
173 "-m", "--manifest", metavar="PATH",
174 help="read package manifest from PATH")
175+ parser.add_option(
176+ "-I", "--ignore", metavar="file-pattern", action='append',
177+ help="Ignore the given pattern when building the package")
178 options, args = parser.parse_args(argv)
179 if len(args) < 1:
180 parser.error("need directory")
181@@ -43,6 +46,8 @@
182 (directory, options.manifest))
183 builder = ClickSourceBuilder()
184 builder.add_file(directory, "./")
185+ for ignore in options.ignore:
186+ builder.add_ignore_pattern(ignore)
187 try:
188 path = builder.build(".", manifest_path=options.manifest)
189 except ClickBuildError as e:
190
191=== modified file 'click/tests/test_build.py'
192--- click/tests/test_build.py 2014-05-05 13:10:19 +0000
193+++ click/tests/test_build.py 2014-05-14 11:49:16 +0000
194@@ -199,38 +199,45 @@
195 self.assertEqual(
196 "foo", os.readlink(os.path.join(extract_path, "bin", "bar")))
197
198+ def _make_scratch_dir(self, manifest_override={}):
199+ self.use_temp_dir()
200+ scratch = os.path.join(self.temp_dir, "scratch")
201+ manifest = {
202+ "name": "com.ubuntu.test",
203+ "version": "1.0",
204+ "maintainer": "Foo Bar <foo@example.org>",
205+ "title": "test title",
206+ "architecture": "all",
207+ "framework": "ubuntu-sdk-13.10",
208+ }
209+ manifest.update(manifest_override)
210+ with mkfile(os.path.join(scratch, "manifest.json")) as f:
211+ json.dump(manifest, f)
212+ self.builder.add_file(scratch, "/")
213+ return scratch
214+
215 def test_build_excludes_dot_click(self):
216- self.use_temp_dir()
217- scratch = os.path.join(self.temp_dir, "scratch")
218+ scratch = self._make_scratch_dir()
219 touch(os.path.join(scratch, ".click", "evil-file"))
220- with mkfile(os.path.join(scratch, "manifest.json")) as f:
221- json.dump({
222- "name": "com.ubuntu.test",
223- "version": "1.0",
224- "maintainer": "Foo Bar <foo@example.org>",
225- "title": "test title",
226- "architecture": "all",
227- "framework": "ubuntu-sdk-13.10",
228- }, f)
229+ path = self.builder.build(self.temp_dir)
230+ extract_path = os.path.join(self.temp_dir, "extract")
231+ subprocess.check_call(["dpkg-deb", "-x", path, extract_path])
232+ self.assertEqual([], os.listdir(extract_path))
233+
234+ def test_build_ignore_pattern(self):
235+ scratch = self._make_scratch_dir()
236+ touch(os.path.join(scratch, "build", "foo.o"))
237 self.builder.add_file(scratch, "/")
238+ self.builder.add_ignore_pattern("build")
239 path = self.builder.build(self.temp_dir)
240 extract_path = os.path.join(self.temp_dir, "extract")
241 subprocess.check_call(["dpkg-deb", "-x", path, extract_path])
242 self.assertEqual([], os.listdir(extract_path))
243
244 def test_build_multiple_architectures(self):
245- self.use_temp_dir()
246- scratch = os.path.join(self.temp_dir, "scratch")
247- with mkfile(os.path.join(scratch, "manifest.json")) as f:
248- json.dump({
249- "name": "com.ubuntu.test",
250- "version": "1.0",
251- "maintainer": "Foo Bar <foo@example.org>",
252- "title": "test title",
253+ scratch = self._make_scratch_dir(manifest_override={
254 "architecture": ["armhf", "i386"],
255- "framework": "ubuntu-sdk-13.10",
256- }, f)
257- self.builder.add_file(scratch, "/")
258+ })
259 path = os.path.join(self.temp_dir, "com.ubuntu.test_1.0_multi.click")
260 self.assertEqual(path, self.builder.build(self.temp_dir))
261 self.assertTrue(os.path.exists(path))
262@@ -245,21 +252,11 @@
263 del target_json["installed-size"]
264 self.assertEqual(source_json, target_json)
265
266- # FIXME: DRY violation with test_build_multiple_architectures etc
267 def test_build_multiple_frameworks(self):
268- self.use_temp_dir()
269- scratch = os.path.join(self.temp_dir, "scratch")
270- with mkfile(os.path.join(scratch, "manifest.json")) as f:
271- json.dump({
272- "name": "com.ubuntu.test",
273- "version": "1.0",
274- "maintainer": "Foo Bar <foo@example.org>",
275- "title": "test title",
276- "architecture": "all",
277+ scratch = self._make_scratch_dir(manifest_override={
278 "framework":
279 "ubuntu-sdk-14.04-basic, ubuntu-sdk-14.04-webapps",
280- }, f)
281- self.builder.add_file(scratch, "/")
282+ })
283 path = self.builder.build(self.temp_dir)
284 control_path = os.path.join(self.temp_dir, "control")
285 subprocess.check_call(["dpkg-deb", "-e", path, control_path])
286@@ -311,6 +308,8 @@
287 scratch = os.path.join(self.temp_dir, "scratch")
288 touch(os.path.join(scratch, "bin", "foo"))
289 touch(os.path.join(scratch, ".git", "config"))
290+ touch(os.path.join(scratch, "foo.so"))
291+ touch(os.path.join(scratch, "build", "meep.goah"))
292 with mkfile(os.path.join(scratch, "manifest.json")) as f:
293 json.dump({
294 "name": "com.ubuntu.test",
295@@ -323,6 +322,7 @@
296 # build() overrides this back to 0o644
297 os.fchmod(f.fileno(), 0o600)
298 self.builder.add_file(scratch, "./")
299+ self.builder.add_ignore_pattern("build")
300 path = os.path.join(self.temp_dir, "com.ubuntu.test_1.0.tar.gz")
301 self.assertEqual(path, self.builder.build(self.temp_dir))
302 self.assertTrue(os.path.exists(path))
303
304=== modified file 'doc/manpage.rst'
305--- doc/manpage.rst 2014-03-18 11:47:21 +0000
306+++ doc/manpage.rst 2014-05-14 11:49:16 +0000
307@@ -70,8 +70,14 @@
308
309 Options:
310
311--m PATH, --manifest=PATH Read package manifest from PATH
312- (default: ``manifest.json``).
313+-m PATH, --manifest=PATH Read package manifest from PATH
314+ (default: ``manifest.json``).
315+-I file-pattern, --ignore=file-pattern Ignore the given shell-pattern
316+ when building the package.
317+ The option may be repeated multiple
318+ times to list multiple patterns to
319+ exclude.
320+
321
322 click buildsource DIRECTORY
323 ---------------------------
324@@ -87,8 +93,13 @@
325
326 Options:
327
328--m PATH, --manifest=PATH Read package manifest from PATH
329- (default: ``manifest.json``).
330+-m PATH, --manifest=PATH Read package manifest from PATH
331+ (default: ``manifest.json``).
332+-I file-pattern, --ignore=file-pattern Ignore the given shell-pattern
333+ when building the package.
334+ The option may be repeated multiple
335+ times to list multiple patterns to
336+ exclude.
337
338 click chroot
339 ------------

Subscribers

People subscribed via source and target branches

to all changes: