Merge lp:~james-w/linaro-image-tools/add-relations-to-packages-file into lp:linaro-image-tools/11.11
Status: | Merged |
---|---|
Merged at revision: | 75 |
Proposed branch: | lp:~james-w/linaro-image-tools/add-relations-to-packages-file |
Merge into: | lp:linaro-image-tools/11.11 |
Prerequisite: | lp:~james-w/linaro-image-tools/split-package-fetcher |
Diff against target: |
223 lines (+130/-11) 3 files modified
hwpack/packages.py (+55/-8) hwpack/testing.py (+2/-1) hwpack/tests/test_packages.py (+73/-2) |
To merge this branch: | bzr merge lp:~james-w/linaro-image-tools/add-relations-to-packages-file |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Zygmunt Krynicki (community) | Approve | ||
Review via email: mp+35167@code.launchpad.net |
Description of the change
Hi,
This adds "depends" to FetchedPackage, corresponding to the "Depends"
that should be put in the Packages file.
First it allows you to set it on the object, and works it in to __eq__,
__hash__ etc.
It then adds code the Packages file creation to write out the dependencies
in the file.
Then it adds a "from_apt" constructor to FetchedPackage that allows you
to create one from a python-apt apt.package.Version (meaning a single
version of a package) instance. This centralises that code, and allows
us to encapsulate the tedious process of going from apt's object definition
of dependencies to the string version that we want.
The tests for that use IsolatedAptCache from the previous branch to
get an actual python-apt object to use.
We should do the same for other dependencies (Pre-Depends and Conflicts being
the most important), but I'll put that in a separate branch.
Thanks,
James
Hi.
I'm not familiar with this API but this method seems quite magic.
You could add a docstring explaining what it does.
+ @classmethod dependencies( "Depends" ) or_dependencies : relation: relation, or_alternative. version) append( "%s%s" % (or_alternative .name, suffix)) list.append( " | ".join(or_list)) depends_ list)
+ def from_apt(cls, pkg, filename, content):
+ depends = None
+ pkg_dependencies = pkg.get_
+ if pkg_dependencies:
+ depends_list = []
+ for or_dep in pkg_dependencies:
+ or_list = []
+ for or_alternative in or_dep.
+ suffix = ""
+ if or_alternative.
+ suffix = " (%s %s)" % (
+ or_alternative.
+ or_list.
+ depends_
+ depends = ", ".join(
+ return cls(
+ pkg.package.name, pkg.version, filename, content, pkg.size,
+ pkg.md5, pkg.architecture, depends=depends)