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
1=== modified file 'hwpack/builder.py'
2--- hwpack/builder.py 2010-09-03 15:14:32 +0000
3+++ hwpack/builder.py 2010-09-14 02:33:51 +0000
4@@ -36,7 +36,9 @@
5 fetcher = PackageFetcher(
6 sources.values(), architecture=architecture)
7 with fetcher:
8- packages = fetcher.fetch_packages(self.config.packages)
9+ packages = fetcher.fetch_packages(
10+ self.config.packages,
11+ download_content=self.config.include_debs)
12 hwpack.add_packages(packages)
13 with open(hwpack.filename(), 'w') as f:
14 hwpack.to_file(f)
15
16=== modified file 'hwpack/packages.py'
17--- hwpack/packages.py 2010-09-14 02:33:50 +0000
18+++ hwpack/packages.py 2010-09-14 02:33:51 +0000
19@@ -359,11 +359,14 @@
20 self.cleanup()
21 return False
22
23- def fetch_packages(self, packages):
24+ def fetch_packages(self, packages, download_content=True):
25 """Fetch the files for the given list of package names.
26
27 :param packages: a list of package names to install
28 :type packages: an iterable of str
29+ :param download_content: whether to download the content of the
30+ packages. Default is to do so.
31+ :type download_content: bool
32 :return: a list of the packages that were fetched, with relevant
33 metdata and the contents of the files available.
34 :rtype: an iterable of FetchedPackages.
35@@ -374,17 +377,18 @@
36 for package in packages:
37 candidate = self.cache.cache[package].candidate
38 base = os.path.basename(candidate.filename)
39- destfile = os.path.join(self.cache.tempdir, base)
40- acq = apt_pkg.Acquire(DummyProgress())
41- acqfile = apt_pkg.AcquireFile(
42- acq, candidate.uri, candidate.md5, candidate.size,
43- base, destfile=destfile)
44- acq.run()
45- if acqfile.status != acqfile.STAT_DONE:
46- raise FetchError(
47- "The item %r could not be fetched: %s" %
48- (acqfile.destfile, acqfile.error_text))
49- result_package = FetchedPackage.from_apt(
50- candidate, base, open(destfile))
51+ result_package = FetchedPackage.from_apt(candidate, base)
52+ if download_content:
53+ destfile = os.path.join(self.cache.tempdir, base)
54+ acq = apt_pkg.Acquire(DummyProgress())
55+ acqfile = apt_pkg.AcquireFile(
56+ acq, candidate.uri, candidate.md5, candidate.size,
57+ base, destfile=destfile)
58+ acq.run()
59+ if acqfile.status != acqfile.STAT_DONE:
60+ raise FetchError(
61+ "The item %r could not be fetched: %s" %
62+ (acqfile.destfile, acqfile.error_text))
63+ result_package.set_content(open(destfile))
64 results.append(result_package)
65 return results
66
67=== modified file 'hwpack/tests/test_builder.py'
68--- hwpack/tests/test_builder.py 2010-09-02 21:31:22 +0000
69+++ hwpack/tests/test_builder.py 2010-09-14 02:33:51 +0000
70@@ -72,3 +72,28 @@
71 IsHardwarePack(
72 metadata, [available_package],
73 {source_id: source.sources_entry}))
74+
75+ def test_obeys_include_debs(self):
76+ hwpack_name = "ahwpack"
77+ hwpack_version = "1.0"
78+ architecture = "armel"
79+ package_name = "foo"
80+ source_id = "ubuntu"
81+ available_package = DummyFetchedPackage(
82+ package_name, "1.1", architecture=architecture)
83+ source = self.useFixture(AptSourceFixture([available_package]))
84+ config = self.useFixture(ConfigFileFixture(
85+ '[hwpack]\nname=%s\npackages=%s\narchitectures=%s\n'
86+ 'include-debs=no\n\n[%s]\nsources-entry=%s\n'
87+ % (hwpack_name, package_name, architecture,
88+ source_id, source.sources_entry)))
89+ builder = HardwarePackBuilder(config.filename, hwpack_version)
90+ builder.build()
91+ metadata = Metadata(hwpack_name, hwpack_version, architecture)
92+ self.assertThat(
93+ "hwpack_%s_%s_%s.tar.gz" % (hwpack_name, hwpack_version,
94+ architecture),
95+ IsHardwarePack(
96+ metadata, [available_package],
97+ {source_id: source.sources_entry},
98+ packages_without_content=[available_package]))
99
100=== modified file 'hwpack/tests/test_packages.py'
101--- hwpack/tests/test_packages.py 2010-09-14 02:33:50 +0000
102+++ hwpack/tests/test_packages.py 2010-09-14 02:33:51 +0000
103@@ -653,3 +653,11 @@
104 fetcher = self.get_fetcher([source])
105 self.assertEqual(
106 wanted_package, fetcher.fetch_packages(["foo"])[0])
107+
108+ def test_fetch_packages_download_content_False_doesnt_set_content(self):
109+ available_package = DummyFetchedPackage("foo", "1.0")
110+ source = self.useFixture(AptSourceFixture([available_package]))
111+ fetcher = self.get_fetcher([source])
112+ fetched_package = fetcher.fetch_packages(
113+ ["foo"], download_content=False)[0]
114+ self.assertIs(None, fetched_package.content)

Subscribers

People subscribed via source and target branches