Merge lp:~flamingolof/aptdaemon/s-p-gtk-fixes into lp:aptdaemon

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
Reviewer Review Type Date Requested Status
Aptdaemon Developers Pending
Review via email: mp+8533@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Olof Kindgren (flamingolof) wrote :

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'aptdaemon/client.py'
--- aptdaemon/client.py 2009-07-07 13:25:51 +0000
+++ aptdaemon/client.py 2009-07-09 17:05:04 +0000
@@ -40,7 +40,6 @@
40import errors40import errors
41import policykit41import policykit
4242
43
44class AptMessage:43class AptMessage:
45 """Represents a non-cirtical information or warning from the daemon"""44 """Represents a non-cirtical information or warning from the daemon"""
46 def __init__(self, enum, details):45 def __init__(self, enum, details):
@@ -320,6 +319,11 @@
320 self._locale = "%s.%s" % locale.getdefaultlocale()319 self._locale = "%s.%s" % locale.getdefaultlocale()
321 self.terminal = None320 self.terminal = None
322321
322 def get_trusted_keys(self, exit_handler=None):
323 daemon = get_aptdaemon()
324 keys = polkit_auth_wrapper(daemon.GetTrustedKeys)
325 return keys
326
323 def upgrade_system(self, safe_mode=True, exit_handler=None):327 def upgrade_system(self, safe_mode=True, exit_handler=None):
324 """Upgrade system."""328 """Upgrade system."""
325 return self._run_transaction("UpgradeSystem", [safe_mode],329 return self._run_transaction("UpgradeSystem", [safe_mode],
@@ -330,6 +334,14 @@
330 return self._run_transaction("InstallPackages", [package_names],334 return self._run_transaction("InstallPackages", [package_names],
331 exit_handler)335 exit_handler)
332336
337 def install_key_file(self, path, exit_handler=None):
338 """Install repository key file."""
339 return self._run_transaction("InstallKeyFile", [path], exit_handler)
340
341 def remove_key(self, fingerprint, exit_handler=None):
342 """Remove repository key."""
343 return self._run_transaction("RemoveKey", [fingerprint], exit_handler)
344
333 def install_file(self, path, exit_handler=None):345 def install_file(self, path, exit_handler=None):
334 """Install local package file."""346 """Install local package file."""
335 return self._run_transaction("InstallFile", [path], exit_handler)347 return self._run_transaction("InstallFile", [path], exit_handler)
336348
=== modified file 'aptdaemon/console.py'
--- aptdaemon/console.py 2009-07-09 08:16:58 +0000
+++ aptdaemon/console.py 2009-07-09 17:05:04 +0000
@@ -78,12 +78,30 @@
78 self._set_transaction(trans)78 self._set_transaction(trans)
79 trans.run(block=True)79 trans.run(block=True)
8080
81 def install_key_file(self, path):
82 """Install repository key file."""
83 trans = self._client.install_key_file(path,
84 exit_handler=self._on_exit)
85 self._set_transaction(trans)
86 trans.run(block=True)
87
88 def remove_key(self, fingerprint):
89 """Remove repository key."""
90 trans = self._client.remove_key(fingerprint, exit_handler=self._on_exit)
91 self._set_transaction(trans)
92 trans.run(block=True)
93
81 def install_file(self, path):94 def install_file(self, path):
82 """Install package file."""95 """Install package file."""
83 trans = self._client.install_file(path, exit_handler=self._on_exit)96 trans = self._client.install_file(path, exit_handler=self._on_exit)
84 self._set_transaction(trans)97 self._set_transaction(trans)
85 trans.run(block=True)98 trans.run(block=True)
8699
100 def get_trusted_keys(self):
101 keys = self._client.get_trusted_keys(exit_handler=self._on_exit)
102 for key in keys:
103 print key
104
87 def remove_packages(self, packages):105 def remove_packages(self, packages):
88 """Remove packages"""106 """Remove packages"""
89 trans = self._client.remove_packages(packages,107 trans = self._client.remove_packages(packages,
@@ -293,6 +311,15 @@
293 parser.add_option("", "--upgrade-system", default="",311 parser.add_option("", "--upgrade-system", default="",
294 action="store_true", dest="dist_upgrade",312 action="store_true", dest="dist_upgrade",
295 help=_("Upgrade the system"))313 help=_("Upgrade the system"))
314 parser.add_option("", "--install-key-file", default="",
315 action="store", type="string", dest="install_key_file",
316 help=_("Install key from file"))
317 parser.add_option("", "--list-trusted-keys", default="",
318 action="store_true", dest="get_trusted_keys",
319 help=_("Get trusted keys"))
320 parser.add_option("", "--remove-key", default="",
321 action="store", type="string", dest="remove_key",
322 help=_("Remove key with the given fingerprint"))
296 parser.add_option("", "--hide-terminal",323 parser.add_option("", "--hide-terminal",
297 action="store_true", dest="hide_terminal",324 action="store_true", dest="hide_terminal",
298 help=_("Do not attach to the apt terminal"))325 help=_("Do not attach to the apt terminal"))
@@ -309,6 +336,12 @@
309 options.remove.split(),336 options.remove.split(),
310 options.purge.split(),337 options.purge.split(),
311 options.upgrade.split())338 options.upgrade.split())
339 elif options.install_key_file:
340 client.install_key_file(options.install_key_file)
341 elif options.remove_key:
342 client.remove_key(options.remove_key)
343 elif options.get_trusted_keys:
344 client.get_trusted_keys()
312 else:345 else:
313 parser.print_help()346 parser.print_help()
314 sys.exit(1)347 sys.exit(1)
315348
=== modified file 'aptdaemon/core.py'
--- aptdaemon/core.py 2009-07-07 15:07:52 +0000
+++ aptdaemon/core.py 2009-07-09 17:05:04 +0000
@@ -55,7 +55,7 @@
55import policykit55import policykit
56from worker import AptWorker56from worker import AptWorker
57from misc import get_main_loop57from misc import get_main_loop
5858from softwareproperties.AptAuth import AptAuth
59# Setup i18n59# Setup i18n
60gettext.textdomain("aptdaemon")60gettext.textdomain("aptdaemon")
6161
@@ -551,6 +551,54 @@
551 @dbus.service.method(APTDAEMON_TRANSACTION_DBUS_INTERFACE,551 @dbus.service.method(APTDAEMON_TRANSACTION_DBUS_INTERFACE,
552 in_signature="s", out_signature="",552 in_signature="s", out_signature="",
553 sender_keyword="sender")553 sender_keyword="sender")
554 def InstallKeyFile(self, path, sender):
555 """Install the given key file.
556
557 Keyword arguments:
558 path -- the absolute path to the package file
559 sender -- the unique D-Bus name of the sender (provided by D-Bus)
560 """
561 log_trans.info("InstallKeyFile() was called: %s" % path)
562 self._check_caller(sender)
563 if self.role != ROLE_UNSET:
564 raise TransactionRoleAlreadySet()
565 action = policykit.PK_ACTION_INSTALL_KEY_FILE
566 if not policykit.is_authorized_sender(action, sender):
567 raise errors.NotAuthorizedError(action, sender)
568 #FIXME: Perform some checks
569 self.role = ROLE_INSTALL_KEY_FILE
570 self.kwargs = {"path" : path}
571 log_trans.debug("Queue transaction")
572 self.queue.put(self)
573 log_trans.debug("Queued")
574
575 @dbus.service.method(APTDAEMON_TRANSACTION_DBUS_INTERFACE,
576 in_signature="s", out_signature="",
577 sender_keyword="sender")
578 def RemoveKey(self, fingerprint, sender):
579 """Remove the given key.
580
581 Keyword arguments:
582 fingerprint -- the fingerprint of the key to remove
583 sender -- the unique D-Bus name of the sender (provided by D-Bus)
584 """
585 log_trans.info("RemoveKey() was called: %s" % fingerprint)
586 self._check_caller(sender)
587 if self.role != ROLE_UNSET:
588 raise TransactionRoleAlreadySet()
589 action = policykit.PK_ACTION_REMOVE_KEY
590 if not policykit.is_authorized_sender(action, sender):
591 raise errors.NotAuthorizedError(action, sender)
592 #FIXME: Perform some checks
593 self.role = ROLE_REMOVE_KEY
594 self.kwargs = {"fingerprint" : fingerprint}
595 log_trans.debug("Queue transaction")
596 self.queue.put(self)
597 log_trans.debug("Queued")
598
599 @dbus.service.method(APTDAEMON_TRANSACTION_DBUS_INTERFACE,
600 in_signature="s", out_signature="",
601 sender_keyword="sender")
554 def InstallFile(self, path, sender):602 def InstallFile(self, path, sender):
555 """Install the given package file.603 """Install the given package file.
556604
@@ -940,6 +988,19 @@
940 return trans.tid988 return trans.tid
941989
942 @dbus.service.method(APTDAEMON_DBUS_INTERFACE,990 @dbus.service.method(APTDAEMON_DBUS_INTERFACE,
991 in_signature="", out_signature="as",
992 sender_keyword="sender")
993 def GetTrustedKeys(self,sender):
994 """Return a list of installed repository keys."""
995 log_trans.info("GetTrustedKeys() was called")
996 action = policykit.PK_ACTION_GET_TRUSTED_KEYS
997 if not policykit.is_authorized_sender(action, sender):
998 raise errors.NotAuthorizedError(action, sender)
999 aptauth = AptAuth()
1000 keys = aptauth.list()
1001 return keys
1002
1003 @dbus.service.method(APTDAEMON_DBUS_INTERFACE,
943 in_signature="", out_signature="sas")1004 in_signature="", out_signature="sas")
944 def GetActiveTransactions(self):1005 def GetActiveTransactions(self):
945 """Return the currently running transaction and the list of queued1006 """Return the currently running transaction and the list of queued
9461007
=== modified file 'aptdaemon/enums.py'
--- aptdaemon/enums.py 2009-07-06 23:29:31 +0000
+++ aptdaemon/enums.py 2009-07-09 17:00:21 +0000
@@ -33,6 +33,8 @@
33(ERROR_PACKAGE_DOWNLOAD_FAILED,33(ERROR_PACKAGE_DOWNLOAD_FAILED,
34 ERROR_REPO_DOWNLOAD_FAILED,34 ERROR_REPO_DOWNLOAD_FAILED,
35 ERROR_DEPENDENCIES_BROKEN,35 ERROR_DEPENDENCIES_BROKEN,
36 ERROR_KEY_NOT_INSTALLED,
37 ERROR_KEY_NOT_REMOVED,
36 ERROR_NO_LOCK,38 ERROR_NO_LOCK,
37 ERROR_NO_CACHE,39 ERROR_NO_CACHE,
38 ERROR_NO_PACKAGE,40 ERROR_NO_PACKAGE,
@@ -41,7 +43,7 @@
41 ERROR_PACKAGE_NOT_INSTALLED,43 ERROR_PACKAGE_NOT_INSTALLED,
42 ERROR_NOT_REMOVE_ESSENTIAL_PACKAGE,44 ERROR_NOT_REMOVE_ESSENTIAL_PACKAGE,
43 ERROR_DAEMON_DIED,45 ERROR_DAEMON_DIED,
44 ERROR_UNKNOWN) = range(12)46 ERROR_UNKNOWN) = range(14)
4547
46# Message enums48# Message enums
47(MSG_SYSTEM_ALREADY_UPTODATE,49(MSG_SYSTEM_ALREADY_UPTODATE,
@@ -62,14 +64,15 @@
6264
63(ROLE_UNSET,65(ROLE_UNSET,
64 ROLE_INSTALL_PACKAGES,66 ROLE_INSTALL_PACKAGES,
65 ROLE_INSTALL_SIGNATURE,67 ROLE_INSTALL_KEY_FILE,
66 ROLE_INSTALL_FILE,68 ROLE_INSTALL_FILE,
67 ROLE_UPGRADE_PACKAGES,69 ROLE_UPGRADE_PACKAGES,
68 ROLE_UPGRADE_SYSTEM,70 ROLE_UPGRADE_SYSTEM,
69 ROLE_UPDATE_CACHE,71 ROLE_UPDATE_CACHE,
72 ROLE_REMOVE_KEY,
70 ROLE_REMOVE_PACKAGES,73 ROLE_REMOVE_PACKAGES,
71 ROLE_COMMIT_PACKAGES,74 ROLE_COMMIT_PACKAGES,
72 ROLE_REMOVE_SIGNATURE) = range(10)75 ROLE_REMOVE_KEY_FILE) = range(11)
7376
74ICONS_STATUS = {77ICONS_STATUS = {
75 STATUS_CANCELLING:'aptdaemon-cleanup',78 STATUS_CANCELLING:'aptdaemon-cleanup',
@@ -94,7 +97,7 @@
94ICONS_ROLE = {97ICONS_ROLE = {
95 ROLE_INSTALL_FILE:'aptdaemon-add',98 ROLE_INSTALL_FILE:'aptdaemon-add',
96 ROLE_INSTALL_PACKAGES:'aptdaemon-add',99 ROLE_INSTALL_PACKAGES:'aptdaemon-add',
97 ROLE_INSTALL_SIGNATURE:'emblem-system',100 ROLE_INSTALL_KEY_FILE:'emblem-system',
98 ROLE_UPDATE_CACHE:'aptdaemon-update-cache',101 ROLE_UPDATE_CACHE:'aptdaemon-update-cache',
99 ROLE_REMOVE_PACKAGES:'aptdaemon-delete',102 ROLE_REMOVE_PACKAGES:'aptdaemon-delete',
100 ROLE_UPGRADE_PACKAGES:'aptdaemon-upgrade',103 ROLE_UPGRADE_PACKAGES:'aptdaemon-upgrade',
@@ -127,8 +130,9 @@
127PAST_ROLE = {130PAST_ROLE = {
128 ROLE_INSTALL_FILE : _("Installed file"),131 ROLE_INSTALL_FILE : _("Installed file"),
129 ROLE_INSTALL_PACKAGES : _("Installed packages"),132 ROLE_INSTALL_PACKAGES : _("Installed packages"),
130 ROLE_INSTALL_SIGNATURE: _("Installed signature"),133 ROLE_INSTALL_KEY_FILE: _("Installed key"),
131 ROLE_UPDATE_CACHE : _("Updated cache"),134 ROLE_UPDATE_CACHE : _("Updated cache"),
135 ROLE_REMOVE_KEY : _("Removed key"),
132 ROLE_REMOVE_PACKAGES : _("Removed packages"),136 ROLE_REMOVE_PACKAGES : _("Removed packages"),
133 ROLE_UPGRADE_PACKAGES : _("Updated packages"),137 ROLE_UPGRADE_PACKAGES : _("Updated packages"),
134 ROLE_UPGRADE_SYSTEM : _("Upgraded system"),138 ROLE_UPGRADE_SYSTEM : _("Upgraded system"),
@@ -157,8 +161,9 @@
157PRESENT_ROLE = {161PRESENT_ROLE = {
158 ROLE_INSTALL_FILE : _("Installing file"),162 ROLE_INSTALL_FILE : _("Installing file"),
159 ROLE_INSTALL_PACKAGES : _("Installing packages"),163 ROLE_INSTALL_PACKAGES : _("Installing packages"),
160 ROLE_INSTALL_SIGNATURE: _("Installing signature"),164 ROLE_INSTALL_KEY_FILE : _("Installing key"),
161 ROLE_UPDATE_CACHE : _("Updating cache"),165 ROLE_UPDATE_CACHE : _("Updating cache"),
166 ROLE_REMOVE_KEY : _("Removing key"),
162 ROLE_REMOVE_PACKAGES : _("Removing packages"),167 ROLE_REMOVE_PACKAGES : _("Removing packages"),
163 ROLE_UPGRADE_PACKAGES : _("Updating packages"),168 ROLE_UPGRADE_PACKAGES : _("Updating packages"),
164 ROLE_UPGRADE_SYSTEM : _("Upgrading system"),169 ROLE_UPGRADE_SYSTEM : _("Upgrading system"),
@@ -180,6 +185,10 @@
180 "they are a common source of problems.\n"185 "they are a common source of problems.\n"
181 "Furthermore run the following command in a "186 "Furthermore run the following command in a "
182 "Terminal: apt-get install -f"),187 "Terminal: apt-get install -f"),
188 ERROR_KEY_NOT_INSTALLED : _("The selected file may not be a GPG key file "
189 "or it might be corrupt."),
190 ERROR_KEY_NOT_REMOVED : _("The selected key couldn't be removed "
191 "Check if you provided a valid fingerprint."),
183 ERROR_NO_LOCK : _("Check if you are currently running another "192 ERROR_NO_LOCK : _("Check if you are currently running another "
184 "software management tool, e.g. Synaptic or aptitude. "193 "software management tool, e.g. Synaptic or aptitude. "
185 "Only one tool is allowed to make changes at the "194 "Only one tool is allowed to make changes at the "
@@ -211,6 +220,8 @@
211 ERROR_PACKAGE_DOWNLOAD_FAILED : _("Failed to download package files"),220 ERROR_PACKAGE_DOWNLOAD_FAILED : _("Failed to download package files"),
212 ERROR_REPO_DOWNLOAD_FAILED : _("Failed to download repository information"),221 ERROR_REPO_DOWNLOAD_FAILED : _("Failed to download repository information"),
213 ERROR_DEPENDENCIES_BROKEN : _("Package dependencies are broken"),222 ERROR_DEPENDENCIES_BROKEN : _("Package dependencies are broken"),
223 ERROR_KEY_NOT_INSTALLED : _("Key was not installed"),
224 ERROR_KEY_NOT_INSTALLED : _("Key was not removed"),
214 ERROR_NO_LOCK : _("Failed to lock the package manager"),225 ERROR_NO_LOCK : _("Failed to lock the package manager"),
215 ERROR_NO_CACHE : _("Failed to load the package list"),226 ERROR_NO_CACHE : _("Failed to load the package list"),
216 ERROR_NO_PACKAGE : _("Package does not exist"),227 ERROR_NO_PACKAGE : _("Package does not exist"),
217228
=== modified file 'aptdaemon/policykit.py'
--- aptdaemon/policykit.py 2009-07-02 10:43:47 +0000
+++ aptdaemon/policykit.py 2009-07-09 17:00:21 +0000
@@ -24,8 +24,11 @@
24import dbus24import dbus
2525
26PK_ACTION_REMOVE_PACKAGES = "org.debian.apt.remove-packages"26PK_ACTION_REMOVE_PACKAGES = "org.debian.apt.remove-packages"
27PK_ACTION_REMOVE_KEY = "org.debian.apt.remove-key"
27PK_ACTION_INSTALL_PACKAGES = "org.debian.apt.install-packages"28PK_ACTION_INSTALL_PACKAGES = "org.debian.apt.install-packages"
29PK_ACTION_INSTALL_KEY_FILE = "org.debian.apt.install-key-file"
28PK_ACTION_INSTALL_FILE = "org.debian.apt.install-file"30PK_ACTION_INSTALL_FILE = "org.debian.apt.install-file"
31PK_ACTION_GET_TRUSTED_KEYS = "org.debian.apt.get-trusted-keys"
29PK_ACTION_UPGRADE_PACKAGES = "org.debian.apt.upgrade-packages"32PK_ACTION_UPGRADE_PACKAGES = "org.debian.apt.upgrade-packages"
30PK_ACTION_UPDATE_CACHE = "org.debian.apt.update-cache"33PK_ACTION_UPDATE_CACHE = "org.debian.apt.update-cache"
31PK_ACTION_UPGRADE_SYSTEM = "org.debian.apt.upgrade-system"34PK_ACTION_UPGRADE_SYSTEM = "org.debian.apt.upgrade-system"
3235
=== modified file 'aptdaemon/worker.py'
--- aptdaemon/worker.py 2009-07-07 14:03:32 +0000
+++ aptdaemon/worker.py 2009-07-09 17:00:21 +0000
@@ -39,6 +39,8 @@
39 DaemonDpkgInstallProgress, \39 DaemonDpkgInstallProgress, \
40 DaemonDpkgRecoverProgress40 DaemonDpkgRecoverProgress
4141
42from softwareproperties.SoftwareProperties import SoftwareProperties
43from softwareproperties.AptAuth import AptAuth
42log = logging.getLogger("AptDamon.Worker")44log = logging.getLogger("AptDamon.Worker")
4345
44class AptWorker(gobject.GObject):46class AptWorker(gobject.GObject):
@@ -100,6 +102,10 @@
100 self.upgrade_packages(**self.trans.kwargs)102 self.upgrade_packages(**self.trans.kwargs)
101 elif self.trans.role == ROLE_COMMIT_PACKAGES:103 elif self.trans.role == ROLE_COMMIT_PACKAGES:
102 self.commit_packages(**self.trans.kwargs)104 self.commit_packages(**self.trans.kwargs)
105 elif self.trans.role == ROLE_INSTALL_KEY_FILE:
106 self.install_key_file(**self.trans.kwargs)
107 elif self.trans.role == ROLE_REMOVE_KEY:
108 self.remove_key(**self.trans.kwargs)
103 except TransactionFailed, excep:109 except TransactionFailed, excep:
104 self.trans.error = excep110 self.trans.error = excep
105 self.trans.exit = EXIT_FAILED111 self.trans.exit = EXIT_FAILED
@@ -172,6 +178,31 @@
172 pkg_name)178 pkg_name)
173 pkg.markInstall()179 pkg.markInstall()
174 180
181 def install_key_file(self, path):
182 """Install repository key file.
183
184 Keyword argument:
185 path -- absolute path to the key file
186 """
187 softwareproperties = SoftwareProperties()
188 if not softwareproperties.add_key(os.path.expanduser(path)):
189 raise TransactionFailed(ERROR_KEY_NOT_INSTALLED,
190 "Key file %s couldn't be installed" % \
191 path)
192
193 def remove_key(self, fingerprint):
194 """Remove repository key.
195
196 Keyword argument:
197 fingerprint -- fingerprint of the key to remove
198 """
199 softwareproperties = SoftwareProperties()
200 if not softwareproperties.remove_key(fingerprint):
201 raise TransactionFailed(ERROR_KEY_NOT_REMOVED,
202 "Key with fingerprint %s couldn't be removed" % \
203 fingerprint)
204
205
175 def install_file(self, path):206 def install_file(self, path):
176 """Install local package file.207 """Install local package file.
177208
178209
=== modified file 'data/org.debian.apt.policy.in'
--- data/org.debian.apt.policy.in 2009-07-02 10:43:47 +0000
+++ data/org.debian.apt.policy.in 2009-07-09 17:00:21 +0000
@@ -17,6 +17,39 @@
17 </defaults>17 </defaults>
18 </action>18 </action>
1919
20 <action id="org.debian.apt.install-key-file">
21 <description>Install repository key file</description>
22 <message>
23 Authentication is required to install a repository key.
24 </message>
25 <defaults>
26 <allow_inactive>no</allow_inactive>
27 <allow_active>auth_admin_keep_always</allow_active>
28 </defaults>
29 </action>
30
31 <action id="org.debian.apt.remove-key">
32 <description>Remove a repository key</description>
33 <message>
34 Authentication is required to remove repository key.
35 </message>
36 <defaults>
37 <allow_inactive>no</allow_inactive>
38 <allow_active>auth_admin_keep_always</allow_active>
39 </defaults>
40 </action>
41
42 <action id="org.debian.apt.get-trusted-keys">
43 <description>View trusted keys</description>
44 <message>
45 Authentication is required to view trusted keys.
46 </message>
47 <defaults>
48 <allow_inactive>no</allow_inactive>
49 <allow_active>auth_admin_keep_always</allow_active>
50 </defaults>
51 </action>
52
20 <action id="org.debian.apt.install-file">53 <action id="org.debian.apt.install-file">
21 <_description>Install package file</_description>54 <_description>Install package file</_description>
22 <_message>55 <_message>

Subscribers

People subscribed via source and target branches

to status/vote changes: