Merge lp:~flamingolof/aptdaemon/s-p-gtk-fixes into lp:aptdaemon
- s-p-gtk-fixes
- Merge into main
Proposed by
Olof Kindgren
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~flamingolof/aptdaemon/s-p-gtk-fixes |
Merge into: | lp:aptdaemon |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~flamingolof/aptdaemon/s-p-gtk-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Aptdaemon Developers | Pending | ||
Review via email: mp+8533@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Olof Kindgren (flamingolof) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'aptdaemon/client.py' |
2 | --- aptdaemon/client.py 2009-07-07 13:25:51 +0000 |
3 | +++ aptdaemon/client.py 2009-07-09 17:05:04 +0000 |
4 | @@ -40,7 +40,6 @@ |
5 | import errors |
6 | import policykit |
7 | |
8 | - |
9 | class AptMessage: |
10 | """Represents a non-cirtical information or warning from the daemon""" |
11 | def __init__(self, enum, details): |
12 | @@ -320,6 +319,11 @@ |
13 | self._locale = "%s.%s" % locale.getdefaultlocale() |
14 | self.terminal = None |
15 | |
16 | + def get_trusted_keys(self, exit_handler=None): |
17 | + daemon = get_aptdaemon() |
18 | + keys = polkit_auth_wrapper(daemon.GetTrustedKeys) |
19 | + return keys |
20 | + |
21 | def upgrade_system(self, safe_mode=True, exit_handler=None): |
22 | """Upgrade system.""" |
23 | return self._run_transaction("UpgradeSystem", [safe_mode], |
24 | @@ -330,6 +334,14 @@ |
25 | return self._run_transaction("InstallPackages", [package_names], |
26 | exit_handler) |
27 | |
28 | + def install_key_file(self, path, exit_handler=None): |
29 | + """Install repository key file.""" |
30 | + return self._run_transaction("InstallKeyFile", [path], exit_handler) |
31 | + |
32 | + def remove_key(self, fingerprint, exit_handler=None): |
33 | + """Remove repository key.""" |
34 | + return self._run_transaction("RemoveKey", [fingerprint], exit_handler) |
35 | + |
36 | def install_file(self, path, exit_handler=None): |
37 | """Install local package file.""" |
38 | return self._run_transaction("InstallFile", [path], exit_handler) |
39 | |
40 | === modified file 'aptdaemon/console.py' |
41 | --- aptdaemon/console.py 2009-07-09 08:16:58 +0000 |
42 | +++ aptdaemon/console.py 2009-07-09 17:05:04 +0000 |
43 | @@ -78,12 +78,30 @@ |
44 | self._set_transaction(trans) |
45 | trans.run(block=True) |
46 | |
47 | + def install_key_file(self, path): |
48 | + """Install repository key file.""" |
49 | + trans = self._client.install_key_file(path, |
50 | + exit_handler=self._on_exit) |
51 | + self._set_transaction(trans) |
52 | + trans.run(block=True) |
53 | + |
54 | + def remove_key(self, fingerprint): |
55 | + """Remove repository key.""" |
56 | + trans = self._client.remove_key(fingerprint, exit_handler=self._on_exit) |
57 | + self._set_transaction(trans) |
58 | + trans.run(block=True) |
59 | + |
60 | def install_file(self, path): |
61 | """Install package file.""" |
62 | trans = self._client.install_file(path, exit_handler=self._on_exit) |
63 | self._set_transaction(trans) |
64 | trans.run(block=True) |
65 | |
66 | + def get_trusted_keys(self): |
67 | + keys = self._client.get_trusted_keys(exit_handler=self._on_exit) |
68 | + for key in keys: |
69 | + print key |
70 | + |
71 | def remove_packages(self, packages): |
72 | """Remove packages""" |
73 | trans = self._client.remove_packages(packages, |
74 | @@ -293,6 +311,15 @@ |
75 | parser.add_option("", "--upgrade-system", default="", |
76 | action="store_true", dest="dist_upgrade", |
77 | help=_("Upgrade the system")) |
78 | + parser.add_option("", "--install-key-file", default="", |
79 | + action="store", type="string", dest="install_key_file", |
80 | + help=_("Install key from file")) |
81 | + parser.add_option("", "--list-trusted-keys", default="", |
82 | + action="store_true", dest="get_trusted_keys", |
83 | + help=_("Get trusted keys")) |
84 | + parser.add_option("", "--remove-key", default="", |
85 | + action="store", type="string", dest="remove_key", |
86 | + help=_("Remove key with the given fingerprint")) |
87 | parser.add_option("", "--hide-terminal", |
88 | action="store_true", dest="hide_terminal", |
89 | help=_("Do not attach to the apt terminal")) |
90 | @@ -309,6 +336,12 @@ |
91 | options.remove.split(), |
92 | options.purge.split(), |
93 | options.upgrade.split()) |
94 | + elif options.install_key_file: |
95 | + client.install_key_file(options.install_key_file) |
96 | + elif options.remove_key: |
97 | + client.remove_key(options.remove_key) |
98 | + elif options.get_trusted_keys: |
99 | + client.get_trusted_keys() |
100 | else: |
101 | parser.print_help() |
102 | sys.exit(1) |
103 | |
104 | === modified file 'aptdaemon/core.py' |
105 | --- aptdaemon/core.py 2009-07-07 15:07:52 +0000 |
106 | +++ aptdaemon/core.py 2009-07-09 17:05:04 +0000 |
107 | @@ -55,7 +55,7 @@ |
108 | import policykit |
109 | from worker import AptWorker |
110 | from misc import get_main_loop |
111 | - |
112 | +from softwareproperties.AptAuth import AptAuth |
113 | # Setup i18n |
114 | gettext.textdomain("aptdaemon") |
115 | |
116 | @@ -551,6 +551,54 @@ |
117 | @dbus.service.method(APTDAEMON_TRANSACTION_DBUS_INTERFACE, |
118 | in_signature="s", out_signature="", |
119 | sender_keyword="sender") |
120 | + def InstallKeyFile(self, path, sender): |
121 | + """Install the given key file. |
122 | + |
123 | + Keyword arguments: |
124 | + path -- the absolute path to the package file |
125 | + sender -- the unique D-Bus name of the sender (provided by D-Bus) |
126 | + """ |
127 | + log_trans.info("InstallKeyFile() was called: %s" % path) |
128 | + self._check_caller(sender) |
129 | + if self.role != ROLE_UNSET: |
130 | + raise TransactionRoleAlreadySet() |
131 | + action = policykit.PK_ACTION_INSTALL_KEY_FILE |
132 | + if not policykit.is_authorized_sender(action, sender): |
133 | + raise errors.NotAuthorizedError(action, sender) |
134 | + #FIXME: Perform some checks |
135 | + self.role = ROLE_INSTALL_KEY_FILE |
136 | + self.kwargs = {"path" : path} |
137 | + log_trans.debug("Queue transaction") |
138 | + self.queue.put(self) |
139 | + log_trans.debug("Queued") |
140 | + |
141 | + @dbus.service.method(APTDAEMON_TRANSACTION_DBUS_INTERFACE, |
142 | + in_signature="s", out_signature="", |
143 | + sender_keyword="sender") |
144 | + def RemoveKey(self, fingerprint, sender): |
145 | + """Remove the given key. |
146 | + |
147 | + Keyword arguments: |
148 | + fingerprint -- the fingerprint of the key to remove |
149 | + sender -- the unique D-Bus name of the sender (provided by D-Bus) |
150 | + """ |
151 | + log_trans.info("RemoveKey() was called: %s" % fingerprint) |
152 | + self._check_caller(sender) |
153 | + if self.role != ROLE_UNSET: |
154 | + raise TransactionRoleAlreadySet() |
155 | + action = policykit.PK_ACTION_REMOVE_KEY |
156 | + if not policykit.is_authorized_sender(action, sender): |
157 | + raise errors.NotAuthorizedError(action, sender) |
158 | + #FIXME: Perform some checks |
159 | + self.role = ROLE_REMOVE_KEY |
160 | + self.kwargs = {"fingerprint" : fingerprint} |
161 | + log_trans.debug("Queue transaction") |
162 | + self.queue.put(self) |
163 | + log_trans.debug("Queued") |
164 | + |
165 | + @dbus.service.method(APTDAEMON_TRANSACTION_DBUS_INTERFACE, |
166 | + in_signature="s", out_signature="", |
167 | + sender_keyword="sender") |
168 | def InstallFile(self, path, sender): |
169 | """Install the given package file. |
170 | |
171 | @@ -940,6 +988,19 @@ |
172 | return trans.tid |
173 | |
174 | @dbus.service.method(APTDAEMON_DBUS_INTERFACE, |
175 | + in_signature="", out_signature="as", |
176 | + sender_keyword="sender") |
177 | + def GetTrustedKeys(self,sender): |
178 | + """Return a list of installed repository keys.""" |
179 | + log_trans.info("GetTrustedKeys() was called") |
180 | + action = policykit.PK_ACTION_GET_TRUSTED_KEYS |
181 | + if not policykit.is_authorized_sender(action, sender): |
182 | + raise errors.NotAuthorizedError(action, sender) |
183 | + aptauth = AptAuth() |
184 | + keys = aptauth.list() |
185 | + return keys |
186 | + |
187 | + @dbus.service.method(APTDAEMON_DBUS_INTERFACE, |
188 | in_signature="", out_signature="sas") |
189 | def GetActiveTransactions(self): |
190 | """Return the currently running transaction and the list of queued |
191 | |
192 | === modified file 'aptdaemon/enums.py' |
193 | --- aptdaemon/enums.py 2009-07-06 23:29:31 +0000 |
194 | +++ aptdaemon/enums.py 2009-07-09 17:00:21 +0000 |
195 | @@ -33,6 +33,8 @@ |
196 | (ERROR_PACKAGE_DOWNLOAD_FAILED, |
197 | ERROR_REPO_DOWNLOAD_FAILED, |
198 | ERROR_DEPENDENCIES_BROKEN, |
199 | + ERROR_KEY_NOT_INSTALLED, |
200 | + ERROR_KEY_NOT_REMOVED, |
201 | ERROR_NO_LOCK, |
202 | ERROR_NO_CACHE, |
203 | ERROR_NO_PACKAGE, |
204 | @@ -41,7 +43,7 @@ |
205 | ERROR_PACKAGE_NOT_INSTALLED, |
206 | ERROR_NOT_REMOVE_ESSENTIAL_PACKAGE, |
207 | ERROR_DAEMON_DIED, |
208 | - ERROR_UNKNOWN) = range(12) |
209 | + ERROR_UNKNOWN) = range(14) |
210 | |
211 | # Message enums |
212 | (MSG_SYSTEM_ALREADY_UPTODATE, |
213 | @@ -62,14 +64,15 @@ |
214 | |
215 | (ROLE_UNSET, |
216 | ROLE_INSTALL_PACKAGES, |
217 | - ROLE_INSTALL_SIGNATURE, |
218 | + ROLE_INSTALL_KEY_FILE, |
219 | ROLE_INSTALL_FILE, |
220 | ROLE_UPGRADE_PACKAGES, |
221 | ROLE_UPGRADE_SYSTEM, |
222 | ROLE_UPDATE_CACHE, |
223 | + ROLE_REMOVE_KEY, |
224 | ROLE_REMOVE_PACKAGES, |
225 | ROLE_COMMIT_PACKAGES, |
226 | - ROLE_REMOVE_SIGNATURE) = range(10) |
227 | + ROLE_REMOVE_KEY_FILE) = range(11) |
228 | |
229 | ICONS_STATUS = { |
230 | STATUS_CANCELLING:'aptdaemon-cleanup', |
231 | @@ -94,7 +97,7 @@ |
232 | ICONS_ROLE = { |
233 | ROLE_INSTALL_FILE:'aptdaemon-add', |
234 | ROLE_INSTALL_PACKAGES:'aptdaemon-add', |
235 | - ROLE_INSTALL_SIGNATURE:'emblem-system', |
236 | + ROLE_INSTALL_KEY_FILE:'emblem-system', |
237 | ROLE_UPDATE_CACHE:'aptdaemon-update-cache', |
238 | ROLE_REMOVE_PACKAGES:'aptdaemon-delete', |
239 | ROLE_UPGRADE_PACKAGES:'aptdaemon-upgrade', |
240 | @@ -127,8 +130,9 @@ |
241 | PAST_ROLE = { |
242 | ROLE_INSTALL_FILE : _("Installed file"), |
243 | ROLE_INSTALL_PACKAGES : _("Installed packages"), |
244 | - ROLE_INSTALL_SIGNATURE: _("Installed signature"), |
245 | + ROLE_INSTALL_KEY_FILE: _("Installed key"), |
246 | ROLE_UPDATE_CACHE : _("Updated cache"), |
247 | + ROLE_REMOVE_KEY : _("Removed key"), |
248 | ROLE_REMOVE_PACKAGES : _("Removed packages"), |
249 | ROLE_UPGRADE_PACKAGES : _("Updated packages"), |
250 | ROLE_UPGRADE_SYSTEM : _("Upgraded system"), |
251 | @@ -157,8 +161,9 @@ |
252 | PRESENT_ROLE = { |
253 | ROLE_INSTALL_FILE : _("Installing file"), |
254 | ROLE_INSTALL_PACKAGES : _("Installing packages"), |
255 | - ROLE_INSTALL_SIGNATURE: _("Installing signature"), |
256 | + ROLE_INSTALL_KEY_FILE : _("Installing key"), |
257 | ROLE_UPDATE_CACHE : _("Updating cache"), |
258 | + ROLE_REMOVE_KEY : _("Removing key"), |
259 | ROLE_REMOVE_PACKAGES : _("Removing packages"), |
260 | ROLE_UPGRADE_PACKAGES : _("Updating packages"), |
261 | ROLE_UPGRADE_SYSTEM : _("Upgrading system"), |
262 | @@ -180,6 +185,10 @@ |
263 | "they are a common source of problems.\n" |
264 | "Furthermore run the following command in a " |
265 | "Terminal: apt-get install -f"), |
266 | + ERROR_KEY_NOT_INSTALLED : _("The selected file may not be a GPG key file " |
267 | + "or it might be corrupt."), |
268 | + ERROR_KEY_NOT_REMOVED : _("The selected key couldn't be removed " |
269 | + "Check if you provided a valid fingerprint."), |
270 | ERROR_NO_LOCK : _("Check if you are currently running another " |
271 | "software management tool, e.g. Synaptic or aptitude. " |
272 | "Only one tool is allowed to make changes at the " |
273 | @@ -211,6 +220,8 @@ |
274 | ERROR_PACKAGE_DOWNLOAD_FAILED : _("Failed to download package files"), |
275 | ERROR_REPO_DOWNLOAD_FAILED : _("Failed to download repository information"), |
276 | ERROR_DEPENDENCIES_BROKEN : _("Package dependencies are broken"), |
277 | + ERROR_KEY_NOT_INSTALLED : _("Key was not installed"), |
278 | + ERROR_KEY_NOT_INSTALLED : _("Key was not removed"), |
279 | ERROR_NO_LOCK : _("Failed to lock the package manager"), |
280 | ERROR_NO_CACHE : _("Failed to load the package list"), |
281 | ERROR_NO_PACKAGE : _("Package does not exist"), |
282 | |
283 | === modified file 'aptdaemon/policykit.py' |
284 | --- aptdaemon/policykit.py 2009-07-02 10:43:47 +0000 |
285 | +++ aptdaemon/policykit.py 2009-07-09 17:00:21 +0000 |
286 | @@ -24,8 +24,11 @@ |
287 | import dbus |
288 | |
289 | PK_ACTION_REMOVE_PACKAGES = "org.debian.apt.remove-packages" |
290 | +PK_ACTION_REMOVE_KEY = "org.debian.apt.remove-key" |
291 | PK_ACTION_INSTALL_PACKAGES = "org.debian.apt.install-packages" |
292 | +PK_ACTION_INSTALL_KEY_FILE = "org.debian.apt.install-key-file" |
293 | PK_ACTION_INSTALL_FILE = "org.debian.apt.install-file" |
294 | +PK_ACTION_GET_TRUSTED_KEYS = "org.debian.apt.get-trusted-keys" |
295 | PK_ACTION_UPGRADE_PACKAGES = "org.debian.apt.upgrade-packages" |
296 | PK_ACTION_UPDATE_CACHE = "org.debian.apt.update-cache" |
297 | PK_ACTION_UPGRADE_SYSTEM = "org.debian.apt.upgrade-system" |
298 | |
299 | === modified file 'aptdaemon/worker.py' |
300 | --- aptdaemon/worker.py 2009-07-07 14:03:32 +0000 |
301 | +++ aptdaemon/worker.py 2009-07-09 17:00:21 +0000 |
302 | @@ -39,6 +39,8 @@ |
303 | DaemonDpkgInstallProgress, \ |
304 | DaemonDpkgRecoverProgress |
305 | |
306 | +from softwareproperties.SoftwareProperties import SoftwareProperties |
307 | +from softwareproperties.AptAuth import AptAuth |
308 | log = logging.getLogger("AptDamon.Worker") |
309 | |
310 | class AptWorker(gobject.GObject): |
311 | @@ -100,6 +102,10 @@ |
312 | self.upgrade_packages(**self.trans.kwargs) |
313 | elif self.trans.role == ROLE_COMMIT_PACKAGES: |
314 | self.commit_packages(**self.trans.kwargs) |
315 | + elif self.trans.role == ROLE_INSTALL_KEY_FILE: |
316 | + self.install_key_file(**self.trans.kwargs) |
317 | + elif self.trans.role == ROLE_REMOVE_KEY: |
318 | + self.remove_key(**self.trans.kwargs) |
319 | except TransactionFailed, excep: |
320 | self.trans.error = excep |
321 | self.trans.exit = EXIT_FAILED |
322 | @@ -172,6 +178,31 @@ |
323 | pkg_name) |
324 | pkg.markInstall() |
325 | |
326 | + def install_key_file(self, path): |
327 | + """Install repository key file. |
328 | + |
329 | + Keyword argument: |
330 | + path -- absolute path to the key file |
331 | + """ |
332 | + softwareproperties = SoftwareProperties() |
333 | + if not softwareproperties.add_key(os.path.expanduser(path)): |
334 | + raise TransactionFailed(ERROR_KEY_NOT_INSTALLED, |
335 | + "Key file %s couldn't be installed" % \ |
336 | + path) |
337 | + |
338 | + def remove_key(self, fingerprint): |
339 | + """Remove repository key. |
340 | + |
341 | + Keyword argument: |
342 | + fingerprint -- fingerprint of the key to remove |
343 | + """ |
344 | + softwareproperties = SoftwareProperties() |
345 | + if not softwareproperties.remove_key(fingerprint): |
346 | + raise TransactionFailed(ERROR_KEY_NOT_REMOVED, |
347 | + "Key with fingerprint %s couldn't be removed" % \ |
348 | + fingerprint) |
349 | + |
350 | + |
351 | def install_file(self, path): |
352 | """Install local package file. |
353 | |
354 | |
355 | === modified file 'data/org.debian.apt.policy.in' |
356 | --- data/org.debian.apt.policy.in 2009-07-02 10:43:47 +0000 |
357 | +++ data/org.debian.apt.policy.in 2009-07-09 17:00:21 +0000 |
358 | @@ -17,6 +17,39 @@ |
359 | </defaults> |
360 | </action> |
361 | |
362 | + <action id="org.debian.apt.install-key-file"> |
363 | + <description>Install repository key file</description> |
364 | + <message> |
365 | + Authentication is required to install a repository key. |
366 | + </message> |
367 | + <defaults> |
368 | + <allow_inactive>no</allow_inactive> |
369 | + <allow_active>auth_admin_keep_always</allow_active> |
370 | + </defaults> |
371 | + </action> |
372 | + |
373 | + <action id="org.debian.apt.remove-key"> |
374 | + <description>Remove a repository key</description> |
375 | + <message> |
376 | + Authentication is required to remove repository key. |
377 | + </message> |
378 | + <defaults> |
379 | + <allow_inactive>no</allow_inactive> |
380 | + <allow_active>auth_admin_keep_always</allow_active> |
381 | + </defaults> |
382 | + </action> |
383 | + |
384 | + <action id="org.debian.apt.get-trusted-keys"> |
385 | + <description>View trusted keys</description> |
386 | + <message> |
387 | + Authentication is required to view trusted keys. |
388 | + </message> |
389 | + <defaults> |
390 | + <allow_inactive>no</allow_inactive> |
391 | + <allow_active>auth_admin_keep_always</allow_active> |
392 | + </defaults> |
393 | + </action> |
394 | + |
395 | <action id="org.debian.apt.install-file"> |
396 | <_description>Install package file</_description> |
397 | <_message> |
Added methods
InstallKeyFile -- Installs a repository key from a given file
GetTrustedKeys -- Returns a list of repository keys
RemoveKey -- Remove a key with the specified fingerprint