[packagekit] packagekit: Branch 'master' - 8 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Fri Oct 26 07:19:37 PDT 2007
backends/pisi/helpers/Makefile.am | 1
backends/pisi/helpers/install-file.py | 19 ++++++++++
backends/pisi/helpers/pisiBackend.py | 14 ++++++++
backends/pisi/pk-backend-pisi.c | 2 -
backends/yum/pk-backend-yum.c | 2 -
client/pk-console.c | 8 ++++
docs/pk-introduction.xml | 9 +++--
html/pk-faq.html | 2 -
libpackagekit/pk-client.c | 59 ++++++++++++++++++++++++----------
policy/packagekit.policy | 9 ++++-
src/pk-engine.c | 36 +++++++++++++-------
src/pk-engine.h | 3 +
src/pk-interface.xml | 1
src/pk-security-polkit.c | 2 +
14 files changed, 131 insertions(+), 36 deletions(-)
New commits:
commit 62cfbe805af8e1182292b7ab55ee1f0eab66103a
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Oct 26 14:40:56 2007 +0100
yum can't do get_requires yet, so don't advertise it
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index c69c37b..39884c6 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -61,7 +61,7 @@ PK_BACKEND_OPTIONS (
pk_backend_python_cancel, /* cancel */
pk_backend_python_get_depends, /* get_depends */
pk_backend_python_get_description, /* get_description */
- pk_backend_python_get_requires, /* get_requires */
+ NULL, /* get_requires */
NULL, /* get_update_detail */
pk_backend_python_get_updates, /* get_updates */
pk_backend_python_install_package, /* install_package */
commit 57f4b15e49535be108ea5e4a963da3cf78672b5a
Merge: 6958b80... 6c18484...
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Oct 26 14:20:54 2007 +0100
Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit
commit 6c184847987b7c04c18f220d78cdbf32864e669d
Author: S.ÃaÄlar Onur <caglar at pardus.org.tr>
Date: Fri Oct 26 16:22:31 2007 +0300
Convert RefreshCache to a privileged operation but with default to allow when on active console.
The distro can then patch this default to whatever depending on the security policy - and the admin can of course change the default.
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 8404083..a27d218 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -1459,6 +1459,31 @@ pk_client_remove_package (PkClient *client, const gchar *package, gboolean allow
}
/**
+ * pk_client_refresh_cache_action:
+ **/
+gboolean
+pk_client_refresh_cache_action (PkClient *client, gboolean force, GError **error)
+{
+ gboolean ret;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+ *error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "RefreshCache", error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_BOOLEAN, force,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("RefreshCache failed!");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
* pk_client_refresh_cache:
**/
gboolean
@@ -1480,25 +1505,27 @@ pk_client_refresh_cache (PkClient *client, gboolean force)
client->priv->role = PK_ROLE_ENUM_REFRESH_CACHE;
client->priv->xcached_force = force;
- error = NULL;
- ret = dbus_g_proxy_call (client->priv->proxy, "RefreshCache", &error,
- G_TYPE_STRING, client->priv->tid,
- G_TYPE_BOOLEAN, force,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (error != NULL) {
- const gchar *error_name;
- error_name = pk_client_get_error_name (error);
- pk_debug ("ERROR: %s: %s", error_name, error->message);
- g_error_free (error);
- }
+ /* hopefully do the operation first time */
+ ret = pk_client_refresh_cache_action (client, force, &error);
+
+ /* we were refused by policy then try to get auth */
if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("RefreshCache failed!");
- return FALSE;
+ if (pk_polkit_client_error_denied_by_policy (error) == TRUE) {
+ /* retry the action if we succeeded */
+ if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error->message) == TRUE) {
+ pk_debug ("gained priv");
+ g_error_free (error);
+ /* do it all over again */
+ ret = pk_client_refresh_cache_action (client, force, &error);
+ }
+ }
+ if (error != NULL) {
+ pk_debug ("ERROR: %s", error->message);
+ g_error_free (error);
+ }
}
- return TRUE;
+ return ret;
}
/**
diff --git a/policy/packagekit.policy b/policy/packagekit.policy
index 10faa24..2c27827 100644
--- a/policy/packagekit.policy
+++ b/policy/packagekit.policy
@@ -72,5 +72,12 @@ Copyright (c) 2007 Richard Hughes <richard at hughsie.com>
</defaults>
</action>
+ <action id="org.freedesktop.packagekit.refresh-cache">
+ <description>Refresh package cache</description>
+ <message>System policy prevents refresh package cache</message>
+ <defaults>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>yes</allow_active>
+ </defaults>
+ </action>
</policyconfig>
-
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 7e0f051..cf9b582 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -773,30 +773,42 @@ pk_engine_action_is_allowed (PkEngine *engine, const gchar *dbus_sender,
/**
* pk_engine_refresh_cache:
**/
-gboolean
-pk_engine_refresh_cache (PkEngine *engine, const gchar *tid, gboolean force, GError **error)
+void
+pk_engine_refresh_cache (PkEngine *engine, const gchar *tid, gboolean force,
+ DBusGMethodInvocation *context, GError **dead_error)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("RefreshCache method called: %s, %i", tid, force);
/* find pre-requested transaction id */
item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"transaction_id '%s' not found", tid);
- return FALSE;
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
+ /* check if the action is allowed from this client - if not, set an error */
+ ret = pk_engine_action_is_allowed (engine, dbus_g_method_get_sender (context), PK_ROLE_ENUM_REFRESH_CACHE, &error);
+ if (ret == FALSE) {
+ dbus_g_method_return_error (context, error);
+ return;
}
/* create a new backend */
item->backend = pk_engine_backend_new (engine);
if (item->backend == NULL) {
- g_warning ("Backend not set yet!");
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Could not create backend instance");
+ dbus_g_method_return_error (context, error);
+ return;
}
/* we unref the update cache if it exists */
@@ -808,14 +820,14 @@ pk_engine_refresh_cache (PkEngine *engine, const gchar *tid, gboolean force, GEr
ret = pk_backend_refresh_cache (item->backend, force);
if (ret == FALSE) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
pk_engine_item_delete (engine, item);
- return FALSE;
+ dbus_g_method_return_error (context, error);
+ return;
}
-
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
diff --git a/src/pk-engine.h b/src/pk-engine.h
index f9c5cb0..90e9310 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -129,9 +129,10 @@ void pk_engine_rollback (PkEngine *engine,
const gchar *transaction_id,
DBusGMethodInvocation *context,
GError **error);
-gboolean pk_engine_refresh_cache (PkEngine *engine,
+void pk_engine_refresh_cache (PkEngine *engine,
const gchar *tid,
gboolean force,
+ DBusGMethodInvocation *context,
GError **error);
gboolean pk_engine_get_old_transactions (PkEngine *engine,
const gchar *tid,
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index 4627814..1542725 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -10,6 +10,7 @@
<arg type="s" name="tid" direction="in"/>
</method>
<method name="RefreshCache">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="tid" direction="in"/>
<arg type="b" name="force" direction="in"/>
</method>
diff --git a/src/pk-security-polkit.c b/src/pk-security-polkit.c
index acf03f0..48b1377 100644
--- a/src/pk-security-polkit.c
+++ b/src/pk-security-polkit.c
@@ -113,6 +113,8 @@ pk_security_action_is_allowed (PkSecurity *security, const gchar *dbus_sender,
} else if (role == PK_ROLE_ENUM_REPO_ENABLE ||
role == PK_ROLE_ENUM_REPO_SET_DATA) {
policy = "org.freedesktop.packagekit.repo-change";
+ } else if (role == PK_ROLE_ENUM_REFRESH_CACHE) {
+ policy = "org.freedesktop.packagekit.refresh-cache";
} else {
pk_error ("policykit type required for '%s'", pk_role_enum_to_text (role));
}
commit 6958b800d928bc529b62458c300625cc5e2dae9e
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Oct 26 14:19:31 2007 +0100
add some more detail to the RefreshCache documentation
diff --git a/docs/pk-introduction.xml b/docs/pk-introduction.xml
index 8258a08..658fecd 100644
--- a/docs/pk-introduction.xml
+++ b/docs/pk-introduction.xml
@@ -1141,7 +1141,12 @@
There are no arguments.
</para>
<para>
- This should fetch the metadata from the repositories.
+ This should fetch updated metadata for all enabled repositories.
+ This operation should be only scheduled when the computer is idle as
+ the network connection will be very active, and will the computer will
+ have have non-trivial levels of hard disk and processor activity.
+ For these reasons, it should not be done automatically when on battery
+ power.
</para>
<para>
This method typically emits
commit 18672af2b9e84330b91d9a742829adc9f3c9abd9
Author: S.ÃaÄlar Onur <caglar at pardus.org.tr>
Date: Fri Oct 26 16:09:24 2007 +0300
PiSi: Add forgotton install-file.py from previous commit
diff --git a/backends/pisi/helpers/install-file.py b/backends/pisi/helpers/install-file.py
new file mode 100644
index 0000000..c44c45c
--- /dev/null
+++ b/backends/pisi/helpers/install-file.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2007 S.ÃaÄlar Onur <caglar at pardus.org.tr>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+import sys
+import pisiBackend
+
+backend = pisiBackend.PackageKitPisiBackend(sys.argv[1:])
+backend.install_file(sys.argv[1])
+
+sys.exit()
commit 0deb80e66a8d2fbea8197ab8aed3caeb6ae793c2
Author: S.ÃaÄlar Onur <caglar at pardus.org.tr>
Date: Fri Oct 26 16:08:04 2007 +0300
PiSi: add install-file support to backend,
Update BACKEND status
diff --git a/backends/pisi/helpers/Makefile.am b/backends/pisi/helpers/Makefile.am
index 9399b69..45fc045 100644
--- a/backends/pisi/helpers/Makefile.am
+++ b/backends/pisi/helpers/Makefile.am
@@ -10,6 +10,7 @@ dist_helper_DATA = \
get-requires.py \
get-updates.py \
install.py \
+ install-file.py \
refresh-cache.py \
remove.py \
resolve.py \
diff --git a/backends/pisi/helpers/pisiBackend.py b/backends/pisi/helpers/pisiBackend.py
index 94103c5..70114fb 100644
--- a/backends/pisi/helpers/pisiBackend.py
+++ b/backends/pisi/helpers/pisiBackend.py
@@ -96,6 +96,20 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
else:
self.error(ERROR_PACKAGE_NOT_INSTALLED, "Package is already installed")
+ def install_file(self, file):
+ """ Installs given package into system"""
+ # FIXME: install progress
+ self.allow_interrupt(False);
+ self.percentage(None)
+
+ try:
+ self.status(STATE_INSTALL)
+ pisi.api.install([file])
+ except pisi.Error,e:
+ # FIXME: Error: internal-error : Package re-install declined
+ # Force needed?
+ self.error(ERROR_PACKAGE_ALREADY_INSTALLED, e)
+
def update(self, package_id):
""" Updates given package to its latest version """
# FIXME: fetch/install progress
diff --git a/backends/pisi/pk-backend-pisi.c b/backends/pisi/pk-backend-pisi.c
index f1809a9..74ac955 100644
--- a/backends/pisi/pk-backend-pisi.c
+++ b/backends/pisi/pk-backend-pisi.c
@@ -38,7 +38,7 @@ PK_BACKEND_OPTIONS (
NULL, /* get_update_detail */
pk_backend_python_get_updates, /* get_updates */
pk_backend_python_install_package, /* install_package */
- NULL, /* install_file */
+ pk_backend_python_install_file, /* install_file */
pk_backend_python_refresh_cache, /* refresh_cache */
pk_backend_python_remove_package, /* remove_package */
pk_backend_python_resolve, /* resolve */
diff --git a/html/pk-faq.html b/html/pk-faq.html
index 83b48f9..ceb10d1 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -34,7 +34,7 @@ search-details | | X | X | X | | | |
search-file | | X | | X | | | |
search-group | | | | | | | |
install-package | X | X | | X | X | X | X |
-install-file | | X | | X | | | |
+install-file | | X | | X | | | X |
remove-package | X | X | | X | X | X | X |
update-package | | X | | X | | X | X |
get-depends | | X | | X | | | X |
commit 36b8f947d535f3cdecd031f879de07f3e54e14aa
Author: S.ÃaÄlar Onur <caglar at pardus.org.tr>
Date: Fri Oct 26 16:06:45 2007 +0300
Add install-file support to pkcon
diff --git a/client/pk-console.c b/client/pk-console.c
index 53b1db9..3b223be 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -302,6 +302,7 @@ const gchar *summary =
"Subcommands:\n"
" search name|details|group|file data\n"
" install <package_id>\n"
+ " install-file <file>\n"
" remove <package_id>\n"
" update <package_id>\n"
" refresh\n"
@@ -609,6 +610,13 @@ pk_console_process_commands (PkClient *client, int argc, char *argv[], gboolean
} else {
wait = pk_console_install_package (client, value);
}
+ } else if (strcmp (mode, "install-file") == 0) {
+ if (value == NULL) {
+ g_set_error (error, 0, 0, "you need to specify a package to install");
+ return FALSE;
+ } else {
+ wait = pk_client_install_file (client, value);
+ }
} else if (strcmp (mode, "remove") == 0) {
if (value == NULL) {
g_set_error (error, 0, 0, "you need to specify a package to remove");
commit 6969688ece00dd0163b6f170a087138fa2542c51
Author: S.ÃaÄlar Onur <caglar at pardus.org.tr>
Date: Fri Oct 26 14:40:13 2007 +0300
Correct Refresh method's description
diff --git a/docs/pk-introduction.xml b/docs/pk-introduction.xml
index fc3364e..8258a08 100644
--- a/docs/pk-introduction.xml
+++ b/docs/pk-introduction.xml
@@ -1141,9 +1141,7 @@
There are no arguments.
</para>
<para>
- This should search for files.
- This should allow an application to find out what package owns
- a file on the system.
+ This should fetch the metadata from the repositories.
</para>
<para>
This method typically emits
More information about the PackageKit
mailing list