Merge lp:~mvo/snapcraft/more-python-apt into lp:~ted/snapcraft/arbitrary-repos

Proposed by Michael Vogt on 2015-09-11
Status: Work in progress
Proposed branch: lp:~mvo/snapcraft/more-python-apt
Merge into: lp:~ted/snapcraft/arbitrary-repos
Diff against target: 99 lines (+27/-41)
2 files modified
examples/ros/snapcraft.yaml (+11/-0)
snapcraft/repo.py (+16/-41)
To merge this branch: bzr merge lp:~mvo/snapcraft/more-python-apt
Reviewer Review Type Date Requested Status
Michael Vogt (community) Needs Fixing on 2015-09-11
Sergio Schvezov (community) Needs Fixing on 2015-09-11
Ted Gould 2015-09-11 Pending
Review via email: mp+270831@code.launchpad.net

Description of the Change

Fix "can not find python-argparse" error by using the python-apt resolver to find the dependencies of the packages.

To post a comment you must log in.
Sergio Schvezov (sergiusens) wrote :

it seems that manifest.txt is not required anymore, mind cleaning it from setup.py and also getting rid of self.manifest_dep_names or not removing it and doing a elif pkg.candidate.name in self.manifest_dep_names unless whatever is in manifest.txt is already covered by your condition.

review: Needs Fixing
Sergio Schvezov (sergiusens) wrote :

Thanks for the simplification btw

Sergio Schvezov (sergiusens) wrote :

One more comment, not sure if it is good, but it was originally like that.

Also, can you use single quotes for strings?

lp:~mvo/snapcraft/more-python-apt updated on 2015-09-11
160. By Michael Vogt on 2015-09-11

address sergios review points

Michael Vogt (mvo) wrote :

One open question here is what to do with manifest.txt

review: Needs Fixing

Unmerged revisions

160. By Michael Vogt on 2015-09-11

address sergios review points

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'examples/ros'
2=== added directory 'examples/ros/snap'
3=== added file 'examples/ros/snapcraft.yaml'
4--- examples/ros/snapcraft.yaml 1970-01-01 00:00:00 +0000
5+++ examples/ros/snapcraft.yaml 2015-09-11 14:45:18 +0000
6@@ -0,0 +1,11 @@
7+name: ros
8+version: 1.0
9+vendor: Snappy developers <snappy-dev@lists.canonical.com>
10+summary: A ros example
11+icon: icon.png
12+description: A really small ros examples
13+
14+parts:
15+ ros:
16+ type: roscore
17+
18
19=== modified file 'snapcraft/repo.py'
20--- snapcraft/repo.py 2015-09-10 22:01:22 +0000
21+++ snapcraft/repo.py 2015-09-11 14:45:18 +0000
22@@ -51,23 +51,29 @@
23 srcfile = os.path.join(download_dir, 'etc', 'apt', 'sources.list')
24 with open(srcfile, 'w') as f:
25 f.write(sources)
26+ progress=apt.progress.text.AcquireProgress()
27 self.apt_cache = apt.Cache(rootdir=download_dir, memonly=True)
28- self.apt_cache.update(sources_list=srcfile)
29+ self.apt_cache.update(fetch_progress=progress, sources_list=srcfile)
30 self.apt_cache.open()
31 self.manifest_dep_names = self._manifest_dep_names()
32 self.recommends = recommends
33 self.download_dir = download_dir
34
35 def get(self, package_names):
36- # TODO cleanup download_dir for clean gets and unpacks
37- self.all_dep_names = set()
38-
39- all_package_names = self._compute_deps(package_names)
40-
41- for pkg in all_package_names:
42- self.apt_cache[pkg].candidate.fetch_binary(destdir=self.download_dir)
43-
44- return all_package_names
45+ for name in package_names:
46+ self.apt_cache[name].mark_install()
47+
48+ for pkg in self.apt_cache:
49+ # those should be already on each system, it also prevents
50+ # diving into downloading libc6
51+ if (pkg.candidate.priority in ('essential', 'important') and
52+ pkg.name not in package_names):
53+ print('Skipping priority essential/imporant %s' % pkg.name)
54+ continue
55+ if pkg.marked_install:
56+ pkg.candidate.fetch_binary(destdir=self.download_dir)
57+
58+ return
59
60 def unpack(self, root_dir):
61 pkgs_abs_path = glob.glob(os.path.join(self.download_dir, '*.deb'))
62@@ -91,37 +97,6 @@
63
64 return manifest_dep_names
65
66- def _compute_deps(self, package_names):
67- self._add_deps(package_names)
68-
69- for pkg in package_names:
70- if pkg not in self.all_dep_names:
71- raise PackageNotFoundError(pkg)
72-
73- return sorted(self.all_dep_names)
74-
75- def _add_deps(self, package_names):
76- def add_deps(packages):
77- for pkg in packages:
78- # Remove the :any in packages
79- # TODO support multiarch
80- pkg = pkg.rsplit(':', 1)[0]
81- if pkg in self.all_dep_names:
82- continue
83- if pkg in self.manifest_dep_names and pkg not in package_names:
84- continue
85- deps = set()
86- try:
87- candidate_pkg = self.apt_cache[pkg].candidate
88- except KeyError:
89- raise PackageNotFoundError(pkg)
90- deps = candidate_pkg.dependencies
91- if self.recommends:
92- deps += candidate_pkg.recommends
93- self.all_dep_names.add(pkg)
94- add_deps([x[0].name for x in deps])
95- add_deps(package_names)
96-
97
98 def _fix_symlinks(debdir):
99 '''

Subscribers

People subscribed via source and target branches

to all changes: