Merge lp:~james-w/linaro-image-tools/obey-include-debs into lp:linaro-image-tools/11.11

Proposed by James Westby
Status: Merged
Merged at revision: 86
Proposed branch: lp:~james-w/linaro-image-tools/obey-include-debs
Merge into: lp:linaro-image-tools/11.11
Prerequisite: lp:~james-w/linaro-image-tools/make-package-content-optional
Diff against target: 114 lines (+53/-14)
4 files modified
hwpack/builder.py (+3/-1)
hwpack/packages.py (+17/-13)
hwpack/tests/test_builder.py (+25/-0)
hwpack/tests/test_packages.py (+8/-0)
To merge this branch: bzr merge lp:~james-w/linaro-image-tools/obey-include-debs
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+35359@code.launchpad.net

This proposal supersedes a proposal from 2010-09-14.

Description of the change

Hi,

Here's the followup branch that actually obeys the include-debs setting.

We pass the include-debs setting as the new download_content parameter
that just determines if we fetch the contents, or just the metadata.

We tested that passing content=None FetchedPackages to that method in the
last branch, so this is just about plumbing the right bits together.

Thanks,

James

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

I had a good idea to make this simpler.

Thanks,

James

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Looks fine to me.

review: Approve
155. By James Westby

Merged make-package-content-optional into obey-include-debs.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hwpack/builder.py'
--- hwpack/builder.py 2010-09-03 15:14:32 +0000
+++ hwpack/builder.py 2010-09-14 02:33:51 +0000
@@ -36,7 +36,9 @@
36 fetcher = PackageFetcher(36 fetcher = PackageFetcher(
37 sources.values(), architecture=architecture)37 sources.values(), architecture=architecture)
38 with fetcher:38 with fetcher:
39 packages = fetcher.fetch_packages(self.config.packages)39 packages = fetcher.fetch_packages(
40 self.config.packages,
41 download_content=self.config.include_debs)
40 hwpack.add_packages(packages)42 hwpack.add_packages(packages)
41 with open(hwpack.filename(), 'w') as f:43 with open(hwpack.filename(), 'w') as f:
42 hwpack.to_file(f)44 hwpack.to_file(f)
4345
=== modified file 'hwpack/packages.py'
--- hwpack/packages.py 2010-09-14 02:33:50 +0000
+++ hwpack/packages.py 2010-09-14 02:33:51 +0000
@@ -359,11 +359,14 @@
359 self.cleanup()359 self.cleanup()
360 return False360 return False
361361
362 def fetch_packages(self, packages):362 def fetch_packages(self, packages, download_content=True):
363 """Fetch the files for the given list of package names.363 """Fetch the files for the given list of package names.
364364
365 :param packages: a list of package names to install365 :param packages: a list of package names to install
366 :type packages: an iterable of str366 :type packages: an iterable of str
367 :param download_content: whether to download the content of the
368 packages. Default is to do so.
369 :type download_content: bool
367 :return: a list of the packages that were fetched, with relevant370 :return: a list of the packages that were fetched, with relevant
368 metdata and the contents of the files available.371 metdata and the contents of the files available.
369 :rtype: an iterable of FetchedPackages.372 :rtype: an iterable of FetchedPackages.
@@ -374,17 +377,18 @@
374 for package in packages:377 for package in packages:
375 candidate = self.cache.cache[package].candidate378 candidate = self.cache.cache[package].candidate
376 base = os.path.basename(candidate.filename)379 base = os.path.basename(candidate.filename)
377 destfile = os.path.join(self.cache.tempdir, base)380 result_package = FetchedPackage.from_apt(candidate, base)
378 acq = apt_pkg.Acquire(DummyProgress())381 if download_content:
379 acqfile = apt_pkg.AcquireFile(382 destfile = os.path.join(self.cache.tempdir, base)
380 acq, candidate.uri, candidate.md5, candidate.size,383 acq = apt_pkg.Acquire(DummyProgress())
381 base, destfile=destfile)384 acqfile = apt_pkg.AcquireFile(
382 acq.run()385 acq, candidate.uri, candidate.md5, candidate.size,
383 if acqfile.status != acqfile.STAT_DONE:386 base, destfile=destfile)
384 raise FetchError(387 acq.run()
385 "The item %r could not be fetched: %s" %388 if acqfile.status != acqfile.STAT_DONE:
386 (acqfile.destfile, acqfile.error_text))389 raise FetchError(
387 result_package = FetchedPackage.from_apt(390 "The item %r could not be fetched: %s" %
388 candidate, base, open(destfile))391 (acqfile.destfile, acqfile.error_text))
392 result_package.set_content(open(destfile))
389 results.append(result_package)393 results.append(result_package)
390 return results394 return results
391395
=== modified file 'hwpack/tests/test_builder.py'
--- hwpack/tests/test_builder.py 2010-09-02 21:31:22 +0000
+++ hwpack/tests/test_builder.py 2010-09-14 02:33:51 +0000
@@ -72,3 +72,28 @@
72 IsHardwarePack(72 IsHardwarePack(
73 metadata, [available_package],73 metadata, [available_package],
74 {source_id: source.sources_entry}))74 {source_id: source.sources_entry}))
75
76 def test_obeys_include_debs(self):
77 hwpack_name = "ahwpack"
78 hwpack_version = "1.0"
79 architecture = "armel"
80 package_name = "foo"
81 source_id = "ubuntu"
82 available_package = DummyFetchedPackage(
83 package_name, "1.1", architecture=architecture)
84 source = self.useFixture(AptSourceFixture([available_package]))
85 config = self.useFixture(ConfigFileFixture(
86 '[hwpack]\nname=%s\npackages=%s\narchitectures=%s\n'
87 'include-debs=no\n\n[%s]\nsources-entry=%s\n'
88 % (hwpack_name, package_name, architecture,
89 source_id, source.sources_entry)))
90 builder = HardwarePackBuilder(config.filename, hwpack_version)
91 builder.build()
92 metadata = Metadata(hwpack_name, hwpack_version, architecture)
93 self.assertThat(
94 "hwpack_%s_%s_%s.tar.gz" % (hwpack_name, hwpack_version,
95 architecture),
96 IsHardwarePack(
97 metadata, [available_package],
98 {source_id: source.sources_entry},
99 packages_without_content=[available_package]))
75100
=== modified file 'hwpack/tests/test_packages.py'
--- hwpack/tests/test_packages.py 2010-09-14 02:33:50 +0000
+++ hwpack/tests/test_packages.py 2010-09-14 02:33:51 +0000
@@ -653,3 +653,11 @@
653 fetcher = self.get_fetcher([source])653 fetcher = self.get_fetcher([source])
654 self.assertEqual(654 self.assertEqual(
655 wanted_package, fetcher.fetch_packages(["foo"])[0])655 wanted_package, fetcher.fetch_packages(["foo"])[0])
656
657 def test_fetch_packages_download_content_False_doesnt_set_content(self):
658 available_package = DummyFetchedPackage("foo", "1.0")
659 source = self.useFixture(AptSourceFixture([available_package]))
660 fetcher = self.get_fetcher([source])
661 fetched_package = fetcher.fetch_packages(
662 ["foo"], download_content=False)[0]
663 self.assertIs(None, fetched_package.content)

Subscribers

People subscribed via source and target branches