Merge lp:~aptdaemon-developers/sessioninstaller/multiarch into lp:sessioninstaller

Proposed by Sebastian Heinlein
Status: Merged
Merged at revision: 126
Proposed branch: lp:~aptdaemon-developers/sessioninstaller/multiarch
Merge into: lp:sessioninstaller
Diff against target: 162 lines (+55/-12)
2 files modified
sessioninstaller/core.py (+43/-10)
sessioninstaller/utils.py (+12/-2)
To merge this branch: bzr merge lp:~aptdaemon-developers/sessioninstaller/multiarch
Reviewer Review Type Date Requested Status
Michael Vogt Approve
Review via email: mp+99693@code.launchpad.net

Description of the change

fix installing codecs on multi arch systems

To post a comment you must log in.
Revision history for this message
Sebastian Heinlein (glatzor) wrote :

This branch depends on the fix of bug 966916 in python-apt

Revision history for this message
Michael Vogt (mvo) wrote :

This looks good, thanks for you detailed analysis of this!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sessioninstaller/core.py'
2--- sessioninstaller/core.py 2012-03-28 10:16:59 +0000
3+++ sessioninstaller/core.py 2012-03-28 10:23:18 +0000
4@@ -33,6 +33,7 @@
5
6 import apt
7 import apt.debfile
8+import apt_pkg
9 from aptdaemon.policykit1 import get_pid_from_dbus_name
10 from defer import Deferred, defer, inline_callbacks, return_value
11 from defer.utils import dbus_deferred_method
12@@ -314,7 +315,7 @@
13 score -- the ranking of the package which should be used for ordering
14 restricted -- if the use or redistribution is restriceted
15 """
16- if name in RESTRICTED_PACKAGES or restricted:
17+ if restricted:
18 #TRANSLATORS: %s is the name of a piece of software
19 tooltip = _("The use of %s may be restricted in some "
20 "countries. You must verify that one of the following "
21@@ -345,10 +346,8 @@
22 details -- additional information about the package
23 score -- the ranking of the package which should be used for ordering
24 """
25- restricted = pkg.candidate.origins[0].component in ("non-free",
26- "multiverse")
27 self.add_confirm(pkg.name, pkg.summary, active, details, score,
28- restricted)
29+ _is_package_restricted(pkg))
30
31 def get_selected_pkgs(self):
32 """Return a list of the package names which are selected."""
33@@ -389,6 +388,8 @@
34 """Show a warning icon for restricted packages."""
35 if model.get_value(iter, COLUMN_TOOLTIP):
36 renderer.props.stock_id = Gtk.STOCK_DIALOG_WARNING
37+ else:
38+ renderer.props.stock_id = None
39
40 def run(self):
41 """Run the dialog."""
42@@ -1267,6 +1268,27 @@
43 pkgs = []
44 partial_providers = False
45 self._init_cache(progress)
46+
47+ # Get the architectures with an installed gstreamer library
48+ # Unfortunately the architecture isn't part of the request. So we
49+ # have to detect for which architectuers gstreamer has been installed
50+ # on the system, to avoid showing codecs for not used but enabeled
51+ # architecures, see LP #899001
52+ architectures = apt_pkg.get_architectures()
53+ supported_archs = set()
54+ if len(architectures) > 1:
55+ for gst_version in set([struct.version for struct in structures]):
56+ for arch in architectures:
57+ try:
58+ pkg = self._cache["libgstreamer%s-0:%s" % (gst_version,
59+ arch)]
60+ except KeyError:
61+ continue
62+ if pkg.is_installed:
63+ supported_archs.add(arch)
64+ else:
65+ supported_archs = architectures
66+
67 for count, pkg in enumerate(self._cache):
68 if not count % 100:
69 while Gtk.events_pending():
70@@ -1276,8 +1298,10 @@
71 progress.hide()
72 progress.destroy()
73 raise errors.ModifyCancelled
74- if pkg.is_installed or not pkg.candidate or \
75- not "Gstreamer-Version" in pkg.candidate.record:
76+ if (pkg.is_installed or
77+ not pkg.candidate or
78+ not "Gstreamer-Version" in pkg.candidate.record or
79+ not pkg.candidate.architecture in supported_archs):
80 continue
81 # Check if the package could not be free in usage or distribution
82 # Allow to prefer special packages
83@@ -1285,8 +1309,7 @@
84 score = GSTREAMER_SCORING[pkg.name]
85 except KeyError:
86 score = 0
87- if pkg.name in RESTRICTED_PACKAGES or \
88- pkg.candidate.origins[0].component in ("non-free", "multiverse"):
89+ if _is_package_restricted(pkg):
90 score -= 10
91 provides = []
92 for struct in structures:
93@@ -1309,7 +1332,8 @@
94 provides.append(struct.name)
95 struct.satisfied = True
96 if score > struct.best_score:
97- struct.best_provider = pkg.name
98+ struct.best_provider = pkg.name.split(":")[0]
99+ struct.best_score = score
100 if provides:
101 provides_all = len(structures) == len(provides)
102 if not provides_all:
103@@ -1358,7 +1382,8 @@
104 else:
105 #TRANSLATORS: Separator for a list of plugins
106 details = _(",\n").join(provides)
107- install = pkg.name in best_providers
108+ # Skip the architecture from the name
109+ install = pkg.name.split(":")[0] in best_providers
110 confirm.add_confirm_package(pkg, install, details, score)
111 res = confirm.run()
112 if res == Gtk.ResponseType.OK:
113@@ -1468,6 +1493,14 @@
114 text += "\n• %s" % element
115 return text
116
117+
118+def _is_package_restricted(pkg):
119+ """If a package is possibly restricted in use."""
120+ return (pkg.name.split(":")[0] in RESTRICTED_PACKAGES or
121+ pkg.candidate.origins[0].component in ("non-free",
122+ "restricted",
123+ "multiverse"))
124+
125 def main():
126 log.setLevel(logging.DEBUG)
127 si = SessionInstaller()
128
129=== modified file 'sessioninstaller/utils.py'
130--- sessioninstaller/utils.py 2010-06-26 10:21:41 +0000
131+++ sessioninstaller/utils.py 2012-03-28 10:23:18 +0000
132@@ -52,6 +52,10 @@
133 use the name and comment of the applications.
134 """
135 markup = ""
136+ try:
137+ pkg, arch = pkg.split(":")
138+ except ValueError:
139+ arch = None
140 if axi:
141 for m in axi.postlist("XP" + pkg):
142 doc = axi.get_document(m.docid)
143@@ -65,11 +69,17 @@
144 app_name = de.getName()
145 app_comment = de.getComment()
146 if app_name:
147- markup += "<b>%s</b>" % app_name
148+ markup += "<b>%s" % app_name
149+ if arch:
150+ markup += " (%s)" % arch
151+ markup += "</b>"
152 if app_comment:
153 markup += "\n%s" % app_comment
154 if not markup:
155- markup = "<b>%s</b>" % pkg
156+ if arch:
157+ markup = "<b>%s (%s)</b>" % (pkg, arch)
158+ else:
159+ markup = "<b>%s</b>" % pkg
160 if summary:
161 markup += "\n%s" % summary
162 return markup

Subscribers

People subscribed via source and target branches