[packagekit] packagekit: Branch 'master' - 9 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Thu Oct 4 11:22:17 PDT 2007
TODO | 1
backends/alpm/pk-backend-alpm.c | 1
backends/apt/pk-backend-apt.cpp | 1
backends/box/pk-backend-box.c | 1
backends/conary/pk-backend-conary.c | 9 ++
backends/dummy/pk-backend-dummy.c | 11 +++
backends/test/pk-backend-test-fail.c | 11 +++
backends/test/pk-backend-test-nop.c | 1
backends/test/pk-backend-test-spawn.c | 1
backends/test/pk-backend-test-succeed.c | 11 +++
backends/test/pk-backend-test-thread.c | 1
backends/yum/helpers/yumBackend.py | 103 ++++++++++++++++++++++++++------
backends/yum/pk-backend-yum.c | 1
configure.ac | 2
libpackagekit/pk-enum.c | 1
libpackagekit/pk-enum.h | 1
policy/packagekit.policy | 9 ++
src/pk-backend-internal.h | 2
src/pk-backend.c | 59 +++++++++++++-----
src/pk-backend.h | 4 -
src/pk-engine.c | 74 ++++++++++++++++++++++
src/pk-engine.h | 5 +
src/pk-interface.xml | 4 +
src/pk-transaction-list.c | 6 +
src/run-pk.sh | 2
25 files changed, 280 insertions(+), 42 deletions(-)
New commits:
diff-tree e8d632dd0c64f9dfb1e25e433f3498dc21ac1ec2 (from 3b58e4b1d63ac16a38bb2d76a1dec6008a31fb69)
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Oct 4 19:19:21 2007 +0100
add rollback in the daemon and backend code - it does nothing yet
diff --git a/TODO b/TODO
index 058c5f8..0e23cf1 100644
--- a/TODO
+++ b/TODO
@@ -39,5 +39,4 @@ To do rollbacks sanely in PK we need a f
* emit internal signal for SetTransactionData
* write pk_transaction_id_equal to not compare data
* allow transaction data to be changed in _db
- * use an new method to handle the rollbacks and pass it to the backend
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 4adc7ab..6925a80 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -60,6 +60,7 @@ static PkTaskEnumMatch task_role[] = {
{PK_ROLE_ENUM_UNKNOWN, "unknown"}, /* fall though value */
{PK_ROLE_ENUM_CANCEL, "cancel"},
{PK_ROLE_ENUM_RESOLVE, "resolve"},
+ {PK_ROLE_ENUM_ROLLBACK, "rollback"},
{PK_ROLE_ENUM_GET_DEPENDS, "get-depends"},
{PK_ROLE_ENUM_GET_UPDATE_DETAIL, "get-update-detail"},
{PK_ROLE_ENUM_GET_DESCRIPTION, "get-description"},
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index bddda8b..a27c9c9 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -31,6 +31,7 @@ G_BEGIN_DECLS
typedef enum {
PK_ROLE_ENUM_CANCEL,
PK_ROLE_ENUM_RESOLVE,
+ PK_ROLE_ENUM_ROLLBACK,
PK_ROLE_ENUM_GET_DEPENDS,
PK_ROLE_ENUM_GET_UPDATE_DETAIL,
PK_ROLE_ENUM_GET_DESCRIPTION,
diff --git a/policy/packagekit.policy b/policy/packagekit.policy
index fceb17e..d41fc3b 100644
--- a/policy/packagekit.policy
+++ b/policy/packagekit.policy
@@ -54,5 +54,14 @@ Copyright (c) 2007 Richard Hughes <richa
</defaults>
</action>
+ <action id="org.freedesktop.packagekit.rollback">
+ <description>Rollback to a previous transaction</description>
+ <message>System policy prevents rollback</message>
+ <defaults>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>auth_admin_keep_always</allow_active>
+ </defaults>
+ </action>
+
</policyconfig>
diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
index 9781421..bcb3dee 100644
--- a/src/pk-backend-internal.h
+++ b/src/pk-backend-internal.h
@@ -90,6 +90,8 @@ gboolean pk_backend_search_details (Pk
const gchar *search);
gboolean pk_backend_resolve (PkBackend *backend,
const gchar *package);
+gboolean pk_backend_rollback (PkBackend *backend,
+ const gchar *transaction_id);
gboolean pk_backend_search_file (PkBackend *backend,
const gchar *filter,
const gchar *search);
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 63a7934..86bf36b 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -60,6 +60,7 @@ struct _PkBackendPrivate
gboolean xcached_force;
gboolean xcached_allow_deps;
gchar *xcached_package_id;
+ gchar *xcached_transaction_id;
gchar *xcached_full_path;
gchar *xcached_filter;
gchar *xcached_search;
@@ -969,6 +970,8 @@ pk_backend_run (PkBackend *backend)
backend->priv->xcached_package_id);
} else if (backend->priv->role == PK_ROLE_ENUM_RESOLVE) {
backend->desc->resolve (backend, backend->priv->xcached_package_id);
+ } else if (backend->priv->role == PK_ROLE_ENUM_ROLLBACK) {
+ backend->desc->rollback (backend, backend->priv->xcached_transaction_id);
} else if (backend->priv->role == PK_ROLE_ENUM_GET_DESCRIPTION) {
backend->desc->get_description (backend,
backend->priv->xcached_package_id);
@@ -1178,6 +1181,22 @@ pk_backend_resolve (PkBackend *backend,
}
/**
+ * pk_backend_rollback:
+ */
+gboolean
+pk_backend_rollback (PkBackend *backend, const gchar *transaction_id)
+{
+ g_return_val_if_fail (backend != NULL, FALSE);
+ if (backend->desc->rollback == NULL) {
+ pk_backend_not_implemented_yet (backend, "Rollback");
+ return FALSE;
+ }
+ backend->priv->xcached_transaction_id = g_strdup (transaction_id);
+ pk_backend_set_role (backend, PK_ROLE_ENUM_ROLLBACK);
+ return TRUE;
+}
+
+/**
* pk_backend_search_details:
*/
gboolean
@@ -1336,6 +1355,9 @@ pk_backend_get_actions (PkBackend *backe
if (backend->desc->resolve != NULL) {
pk_enum_list_append (elist, PK_ROLE_ENUM_RESOLVE);
}
+ if (backend->desc->rollback != NULL) {
+ pk_enum_list_append (elist, PK_ROLE_ENUM_ROLLBACK);
+ }
if (backend->desc->search_details != NULL) {
pk_enum_list_append (elist, PK_ROLE_ENUM_SEARCH_DETAILS);
}
@@ -1434,6 +1456,7 @@ pk_backend_finalize (GObject *object)
g_timer_destroy (backend->priv->timer);
g_free (backend->priv->xcached_package_id);
+ g_free (backend->priv->xcached_transaction_id);
g_free (backend->priv->xcached_filter);
g_free (backend->priv->xcached_search);
@@ -1537,6 +1560,7 @@ pk_backend_init (PkBackend *backend)
backend->priv->spawn = NULL;
backend->priv->handle = NULL;
backend->priv->xcached_package_id = NULL;
+ backend->priv->xcached_transaction_id = NULL;
backend->priv->xcached_full_path = NULL;
backend->priv->xcached_filter = NULL;
backend->priv->xcached_search = NULL;
diff --git a/src/pk-engine.c b/src/pk-engine.c
index be87ad2..b0aedde 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1473,6 +1473,59 @@ pk_engine_install_file (PkEngine *engine
}
/**
+ * pk_engine_rollback:
+ *
+ * This is async, so we have to treat it a bit carefully
+ **/
+void
+pk_engine_rollback (PkEngine *engine, const gchar *tid, const gchar *transaction_id,
+ DBusGMethodInvocation *context, GError **dead_error)
+{
+ gboolean ret;
+ PkTransactionItem *item;
+ GError *error;
+
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
+
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "transaction_id '%s' not found", tid);
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
+ /* check with PolicyKit if the action is allowed from this client - if not, set an error */
+ ret = pk_engine_action_is_allowed (engine, context, "org.freedesktop.packagekit.rollback", &error);
+ if (ret == FALSE) {
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
+ ret = pk_backend_rollback (item->backend, transaction_id);
+ if (ret == FALSE) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ pk_engine_item_delete (engine, item);
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+ pk_engine_item_add (engine, item);
+ dbus_g_method_return (context);
+}
+
+/**
* pk_engine_update_package:
*
* This is async, so we have to treat it a bit carefully
diff --git a/src/pk-engine.h b/src/pk-engine.h
index a08567f..b3e5de8 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -122,6 +122,11 @@ gboolean pk_engine_resolve (PkEngine
const gchar *tid,
const gchar *package,
GError **error);
+void pk_engine_rollback (PkEngine *engine,
+ const gchar *tid,
+ const gchar *transaction_id,
+ DBusGMethodInvocation *context,
+ GError **error);
gboolean pk_engine_refresh_cache (PkEngine *engine,
const gchar *tid,
gboolean force,
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index 840a0d3..d7970e6 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -21,6 +21,10 @@
<arg type="s" name="tid" direction="in"/>
<arg type="s" name="package" direction="in"/>
</method>
+ <method name="Rollback">
+ <arg type="s" name="tid" direction="in"/>
+ <arg type="s" name="transaction_id" direction="in"/>
+ </method>
<method name="SearchName">
<arg type="s" name="tid" direction="in"/>
<arg type="s" name="filter" direction="in"/>
diff-tree 3b58e4b1d63ac16a38bb2d76a1dec6008a31fb69 (from 357ea29c62132dc8ccd1e9908c6086e27ad7bfa6)
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Oct 4 19:18:41 2007 +0100
drop the version of dbus-glib so we can build on rawhide
diff --git a/configure.ac b/configure.ac
index 32ddc71..f945914 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,7 +50,7 @@ dnl - Library dependencies
dnl ---------------------------------------------------------------------------
GLIB_REQUIRED=2.14.0
DBUS_REQUIRED=1.1.1
-DBUS_GLIB_REQUIRED=0.74
+DBUS_GLIB_REQUIRED=0.73
LIBNM_REQUIRED=0.6.4
POLKIT_DBUS_REQUIRED=0.5
POLKIT_GRANT_REQUIRED=0.5
diff-tree 357ea29c62132dc8ccd1e9908c6086e27ad7bfa6 (from parents)
Merge: 495171f364d84584ca809d001b3c5377fad8f241 9c279d909a2ca3dd4f47459e6a875aabcba253b6
Author: Ken VanDine <ken at vandine.org>
Date: Thu Oct 4 10:06:09 2007 -0400
Merge branch 'master' of git+ssh://kvandine@git.packagekit.org/srv/git/PackageKit
Conflicts:
backends/conary/pk-backend-conary.c
diff --cc backends/conary/pk-backend-conary.c
index 72e8ff8,6d20c80..9efba66
@@@ -214,7 -210,8 +214,8 @@@
backend_refresh_cache, /* refresh_cache */
backend_remove_package, /* remove_package */
NULL, /* resolve */
+ NULL, /* search_details */
+ NULL, /* rollback */
- backend_search_details, /* search_details */
NULL, /* search_file */
NULL, /* search_group */
backend_search_name, /* search_name */
diff-tree 495171f364d84584ca809d001b3c5377fad8f241 (from a21422005fa99b60e8f8d33c0075c4cbcdbbb981)
Author: Ken VanDine <ken at vandine.org>
Date: Thu Oct 4 10:00:05 2007 -0400
Disable details for now
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index bd6f4e4..72e8ff8 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -64,6 +64,7 @@ backend_get_filters (PkBackend *backend,
/**
* backend_get_description:
*/
+/**
static void
backend_get_description (PkBackend *backend, const gchar *package_id)
{
@@ -71,6 +72,7 @@ backend_get_description (PkBackend *back
pk_backend_allow_interrupt (backend, TRUE);
pk_backend_spawn_helper (backend, "get-description.py", package_id, NULL);
}
+ */
/**
* backend_get_updates:
@@ -134,6 +136,7 @@ backend_remove_package (PkBackend *backe
/**
* backend_search_details:
*/
+/**
static void
backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
{
@@ -141,6 +144,7 @@ backend_search_details (PkBackend *backe
pk_backend_allow_interrupt (backend, TRUE);
pk_backend_spawn_helper (backend, "search-details.py", filter, search, NULL);
}
+ */
/**
* backend_search_name:
@@ -201,7 +205,7 @@ PK_BACKEND_OPTIONS (
backend_get_filters, /* get_filters */
NULL, /* cancel */
backend_get_depends, /* get_depends */
- backend_get_description, /* get_description */
+ NULL, /* get_description */
NULL, /* get_requires */
NULL, /* get_update_detail */
backend_get_updates, /* get_updates */
@@ -210,7 +214,7 @@ PK_BACKEND_OPTIONS (
backend_refresh_cache, /* refresh_cache */
backend_remove_package, /* remove_package */
NULL, /* resolve */
- backend_search_details, /* search_details */
+ NULL, /* search_details */
NULL, /* search_file */
NULL, /* search_group */
backend_search_name, /* search_name */
diff-tree 9c279d909a2ca3dd4f47459e6a875aabcba253b6 (from 881a3e213415a4209fa3c35c233fd1b39859e884)
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Thu Oct 4 11:38:14 2007 +0200
Make some changes to yum backend get-depends to work better with multilib and dont show false positives
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 2b77cb7..edd240b 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -30,7 +30,8 @@ from yum.rpmtrans import RPMBaseCallback
from yum.constants import *
from yum.update_md import UpdateMetadata
from yum.callbacks import *
-from yum.misc import prco_tuple_to_string
+from yum.misc import prco_tuple_to_string, unique
+import rpmUtils
class PackageKitYumBackend(PackageKitBaseBackend):
@@ -233,14 +234,56 @@ class PackageKitYumBackend(PackageKitBas
self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
def _is_inst(self,pkg):
- (n,a,e,v,r) = pkg.pkgtup
- pkgs = self.yumbase.rpmdb.searchNevra(name=n,epoch=e,ver=v,rel=r,arch=a)
- # if the package is found, then return it
- if len(pkgs) != 0:
- return True
- else:
+ return self.yumbase.rpmdb.installed(po=pkg)
+
+ def _installable(self, pkg, ematch=False):
+
+ """check if the package is reasonably installable, true/false"""
+
+ exactarchlist = self.yumbase.conf.exactarchlist
+ # we look through each returned possibility and rule out the
+ # ones that we obviously can't use
+
+ if self.yumbase.rpmdb.installed(po=pkg):
return False
+ # everything installed that matches the name
+ installedByKey = self.yumbase.rpmdb.searchNevra(name=pkg.name)
+ comparable = []
+ for instpo in installedByKey:
+ if rpmUtils.arch.isMultiLibArch(instpo.arch) == rpmUtils.arch.isMultiLibArch(pkg.arch):
+ comparable.append(instpo)
+ else:
+ continue
+
+ # go through each package
+ if len(comparable) > 0:
+ for instpo in comparable:
+ if pkg.EVR > instpo.EVR: # we're newer - this is an update, pass to them
+ if instpo.name in exactarchlist:
+ if pkg.arch == instpo.arch:
+ return True
+ else:
+ return True
+
+ elif pkg.EVR == instpo.EVR: # same, ignore
+ return False
+
+ elif pkg.EVR < instpo.EVR: # lesser, check if the pkgtup is an exactmatch
+ # if so then add it to be installed
+ # if it can be multiply installed
+ # this is where we could handle setting
+ # it to be an 'oldpackage' revert.
+
+ if ematch and self.yumbase.allowedMultipleInstalls(pkg):
+ return True
+
+ else: # we've not got any installed that match n or n+a
+ return True
+
+ return False
+
+
def _get_best_dependencies(self,po):
''' find the most recent packages that provides the dependencies for a package
@param po: yum package object to find deps for
@@ -264,7 +307,7 @@ class PackageKitYumBackend(PackageKitBas
else:
best= po
bestdeps.append(best)
- return bestdeps
+ return unique(bestdeps)
def get_depends(self,package):
'''
@@ -286,7 +329,8 @@ class PackageKitYumBackend(PackageKitBas
if self._is_inst(pkg):
self.package(id, INFO_INSTALLED, pkg.summary)
else:
- self.package(id, INFO_AVAILABLE, pkg.summary)
+ if self._installable(pkg):
+ self.package(id, INFO_AVAILABLE, pkg.summary)
def update_system(self):
diff-tree 881a3e213415a4209fa3c35c233fd1b39859e884 (from f332fba0922c5b938d9939c2cea9f86da0eed756)
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Thu Oct 4 10:02:28 2007 +0200
Make the yum backend get-depend show the best fit dependencies and the right install state
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 638b7df..2b77cb7 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -30,7 +30,7 @@ from yum.rpmtrans import RPMBaseCallback
from yum.constants import *
from yum.update_md import UpdateMetadata
from yum.callbacks import *
-
+from yum.misc import prco_tuple_to_string
class PackageKitYumBackend(PackageKitBaseBackend):
@@ -240,6 +240,31 @@ class PackageKitYumBackend(PackageKitBas
return True
else:
return False
+
+ def _get_best_dependencies(self,po):
+ ''' find the most recent packages that provides the dependencies for a package
+ @param po: yum package object to find deps for
+ @return: a list for yum package object providing the dependencies
+ '''
+ results = self.yumbase.findDeps([po])
+ pkg = results.keys()[0]
+ bestdeps=[]
+ if len(results[pkg].keys()) == 0: # No dependencies for this package ?
+ return bestdeps
+ for req in results[pkg].keys():
+ reqlist = results[pkg][req]
+ if not reqlist: # Unsatisfied dependency
+ self.error(ERROR_DEP_RESOLUTION_FAILED,"the (%s) requirement could not be resolved" % prco_tuple_to_string(req),exit=False)
+ continue
+ best = None
+ for po in reqlist:
+ if best:
+ if po.EVR > best.EVR:
+ best=po
+ else:
+ best= po
+ bestdeps.append(best)
+ return bestdeps
def get_depends(self,package):
'''
@@ -250,15 +275,10 @@ class PackageKitYumBackend(PackageKitBas
pkg,inst = self._findPackage(package)
results = {}
if pkg:
- deps = self.yumbase.findDeps([pkg]).values()[0]
- for deplist in deps.values():
- for dep in deplist:
- if not results.has_key(dep.name):
- results[dep.name] = dep
+ deps = self._get_best_dependencies(pkg)
else:
self.error(ERROR_INTERNAL_ERROR,'Package was not found')
-
- for pkg in results.values():
+ for pkg in deps:
if pkg.name != name:
pkgver = self._get_package_ver(pkg)
id = self.get_package_id(pkg.name, pkgver, pkg.arch, pkg.repoid)
diff-tree f332fba0922c5b938d9939c2cea9f86da0eed756 (from b99636f51ec18ddae4e3af050d1b92aa0e4638e2)
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Thu Oct 4 08:16:46 2007 +0200
Make some changes to yum get-depends to make it better to detect installation state, not perfect yet, but better :)
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 80c99f3..638b7df 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -232,6 +232,14 @@ class PackageKitYumBackend(PackageKitBas
'''
self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+ def _is_inst(self,pkg):
+ (n,a,e,v,r) = pkg.pkgtup
+ pkgs = self.yumbase.rpmdb.searchNevra(name=n,epoch=e,ver=v,rel=r,arch=a)
+ # if the package is found, then return it
+ if len(pkgs) != 0:
+ return True
+ else:
+ return False
def get_depends(self,package):
'''
@@ -252,9 +260,10 @@ class PackageKitYumBackend(PackageKitBas
for pkg in results.values():
if pkg.name != name:
- pkgver = self._get_package_ver(pkg)
- id = self.get_package_id(pkg.name, pkgver, pkg.arch, pkg.repo)
- if pkg.repo == 'installed':
+ pkgver = self._get_package_ver(pkg)
+ id = self.get_package_id(pkg.name, pkgver, pkg.arch, pkg.repoid)
+
+ if self._is_inst(pkg):
self.package(id, INFO_INSTALLED, pkg.summary)
else:
self.package(id, INFO_AVAILABLE, pkg.summary)
@@ -302,12 +311,6 @@ class PackageKitYumBackend(PackageKitBas
except yum.Errors.YumBaseError, e:
self.error(ERROR_INTERNAL_ERROR,str(e))
- def _is_inst(self,name): # fast check for if package is installed
- mi = self.yumbase.ts.ts.dbMatch('name', name)
- if mi.count() > 0:
- return True
- return False
-
def resolve(self, name):
'''
Implement the {backend}-resolve functionality
diff-tree b99636f51ec18ddae4e3af050d1b92aa0e4638e2 (from 1b5e5c79177065e5b8ae93506342de6a2cd55a2c)
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Oct 3 22:48:01 2007 +0100
make some warnings less fatal, and fix a crasher when we race with the backend creation with an async GetDescription
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 0f336b7..63a7934 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -256,7 +256,7 @@ pk_backend_parse_common_output (PkBacken
if (strcmp (command, "package") == 0) {
if (size != 4) {
- g_error ("invalid command '%s'", command);
+ g_warning ("invalid command '%s'", command);
ret = FALSE;
goto out;
}
@@ -266,7 +266,9 @@ pk_backend_parse_common_output (PkBacken
if (info == PK_INFO_ENUM_UNKNOWN) {
g_print ("Info enumerated type '%s' not recognised\n", sections[1]);
g_print ("See src/pk-enum.c for allowed values.\n");
- pk_error ("Runtime error, cannot continue");
+ pk_warning ("Runtime error, cannot continue");
+ ret = FALSE;
+ goto out;
}
pk_debug ("info=%s, package='%s' shortdesc='%s'",
pk_info_enum_to_text (info), sections[2], sections[3]);
@@ -276,7 +278,7 @@ pk_backend_parse_common_output (PkBacken
}
} else if (strcmp (command, "description") == 0) {
if (size != 8) {
- g_error ("invalid command '%s'", command);
+ g_warning ("invalid command '%s'", command);
ret = FALSE;
goto out;
}
@@ -323,7 +325,7 @@ pk_backend_parse_common_error (PkBackend
if (strcmp (command, "percentage") == 0) {
if (size != 2) {
- g_error ("invalid command '%s'", command);
+ g_warning ("invalid command '%s'", command);
ret = FALSE;
goto out;
}
@@ -331,7 +333,7 @@ pk_backend_parse_common_error (PkBackend
pk_backend_change_percentage (backend, percentage);
} else if (strcmp (command, "subpercentage") == 0) {
if (size != 2) {
- g_error ("invalid command '%s'", command);
+ g_warning ("invalid command '%s'", command);
ret = FALSE;
goto out;
}
@@ -339,7 +341,7 @@ pk_backend_parse_common_error (PkBackend
pk_backend_change_sub_percentage (backend, percentage);
} else if (strcmp (command, "error") == 0) {
if (size != 3) {
- g_error ("invalid command '%s'", command);
+ g_warning ("invalid command '%s'", command);
ret = FALSE;
goto out;
}
@@ -347,7 +349,7 @@ pk_backend_parse_common_error (PkBackend
pk_backend_error_code (backend, error_enum, sections[2]);
} else if (strcmp (command, "requirerestart") == 0) {
if (size != 3) {
- g_error ("invalid command '%s'", command);
+ g_warning ("invalid command '%s'", command);
ret = FALSE;
goto out;
}
@@ -355,7 +357,7 @@ pk_backend_parse_common_error (PkBackend
pk_backend_require_restart (backend, restart_enum, sections[2]);
} else if (strcmp (command, "status") == 0) {
if (size != 2) {
- g_error ("invalid command '%s'", command);
+ g_warning ("invalid command '%s'", command);
ret = FALSE;
goto out;
}
@@ -363,7 +365,7 @@ pk_backend_parse_common_error (PkBackend
pk_backend_change_status (backend, status_enum);
} else if (strcmp (command, "allow-interrupt") == 0) {
if (size != 2) {
- g_error ("invalid command '%s'", command);
+ g_warning ("invalid command '%s'", command);
ret = FALSE;
goto out;
}
@@ -378,7 +380,7 @@ pk_backend_parse_common_error (PkBackend
}
} else if (strcmp (command, "no-percentage-updates") == 0) {
if (size != 1) {
- g_error ("invalid command '%s'", command);
+ g_warning ("invalid command '%s'", command);
ret = FALSE;
goto out;
}
@@ -398,7 +400,8 @@ static gboolean
pk_backend_spawn_helper_delete (PkBackend *backend)
{
if (backend->priv->spawn == NULL) {
- pk_error ("spawn object not in use");
+ pk_warning ("spawn object not in use");
+ return FALSE;
}
pk_debug ("deleting spawn %p", backend->priv->spawn);
g_signal_handler_disconnect (backend->priv->spawn, backend->priv->signal_finished);
@@ -454,7 +457,8 @@ static gboolean
pk_backend_spawn_helper_new (PkBackend *backend)
{
if (backend->priv->spawn != NULL) {
- pk_error ("spawn object already in use");
+ pk_warning ("spawn object already in use");
+ return FALSE;
}
backend->priv->spawn = pk_spawn_new ();
pk_debug ("allocating spawn %p", backend->priv->spawn);
@@ -597,8 +601,9 @@ pk_backend_set_role (PkBackend *backend,
/* Should only be called once... */
if (backend->priv->role != PK_ROLE_ENUM_UNKNOWN) {
- pk_error ("cannot set role more than once, already %s",
- pk_role_enum_to_text (backend->priv->role));
+ pk_warning ("cannot set role more than once, already %s",
+ pk_role_enum_to_text (backend->priv->role));
+ return FALSE;
}
pk_debug ("setting role to %s", pk_role_enum_to_text (role));
backend->priv->assigned = TRUE;
@@ -779,7 +784,7 @@ pk_backend_error_code (PkBackend *backen
if (backend->priv->set_error == TRUE) {
g_print ("pk_backend_error_code was used more than once in the same backend instance!\n");
g_print ("You tried to set '%s'\n", buffer);
- pk_error ("Internal error, cannot continue");
+ pk_warning ("Internal error");
return FALSE;
}
backend->priv->set_error = TRUE;
diff --git a/src/pk-engine.c b/src/pk-engine.c
index c0cbe37..be87ad2 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -433,6 +433,11 @@ pk_engine_finished_cb (PkBackend *backen
pk_warning ("could not find backend");
return;
}
+ /* we might not have this set yet */
+ if (item->backend == NULL) {
+ g_warning ("Backend not set yet!");
+ return;
+ }
exit_text = pk_exit_enum_to_text (exit);
/* find the length of time we have been running */
@@ -554,6 +559,12 @@ pk_engine_item_add (PkEngine *engine, Pk
/* commit, so it appears in the JobList */
pk_transaction_list_commit (engine->priv->transaction_list, item);
+ /* we might not have this set yet */
+ if (item->backend == NULL) {
+ g_warning ("Backend not set yet!");
+ return FALSE;
+ }
+
/* only save into the database for useful stuff */
pk_backend_get_role (item->backend, &role, NULL);
if (role == PK_ROLE_ENUM_REFRESH_CACHE ||
@@ -689,8 +700,7 @@ pk_engine_refresh_cache (PkEngine *engin
/* create a new backend */
item->backend = pk_engine_new_backend (engine);
if (item->backend == NULL) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
- "Backend '%s' could not be initialized", engine->priv->backend);
+ g_warning ("Backend not set yet!");
return FALSE;
}
@@ -1585,6 +1595,13 @@ pk_engine_get_role (PkEngine *engine, co
"No tid:%s", tid);
return FALSE;
}
+
+ /* we might not have this set yet */
+ if (item->backend == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
+ "Backend not set with tid:%s", tid);
+ return FALSE;
+ }
pk_backend_get_role (item->backend, &role_enum, package_id);
*role = g_strdup (pk_role_enum_to_text (role_enum));
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 0d18bb1..0343fa4 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -80,6 +80,10 @@ pk_transaction_list_role_present (PkTran
length = tlist->priv->array->len;
for (i=0; i<length; i++) {
item = (PkTransactionItem *) g_ptr_array_index (tlist->priv->array, i);
+ /* we might not have this set yet */
+ if (item->backend == NULL) {
+ continue;
+ }
pk_backend_get_role (item->backend, &role_temp, NULL);
if (role_temp == role) {
return TRUE;
@@ -147,7 +151,7 @@ pk_transaction_list_backend_finished_cb
item = pk_transaction_list_get_from_backend (tlist, backend);
if (item == NULL) {
- pk_error ("moo!");
+ pk_error ("no transaction list found!");
}
pk_debug ("transaction %s completed, removing", item->tid);
pk_transaction_list_remove (tlist, item);
diff --git a/src/run-pk.sh b/src/run-pk.sh
index 6d4c284..283da33 100755
--- a/src/run-pk.sh
+++ b/src/run-pk.sh
@@ -1,4 +1,4 @@
export G_DEBUG=fatal_criticals
killall packagekitd
-./packagekitd --verbose --disable-timer | tee debug.log
+./packagekitd --verbose --disable-timer --backend=dummy | tee debug.log
diff-tree 1b5e5c79177065e5b8ae93506342de6a2cd55a2c (from 69f98f3f1547fd3a263635cc4d2c4ac469097d6e)
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Oct 3 22:20:41 2007 +0100
add the rollback hooks into the backends - they do nothign yet
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 57c21ed..2d2b721 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -752,6 +752,7 @@ PK_BACKEND_OPTIONS (
backend_refresh_cache, /* refresh_cache */
backend_remove_package, /* remove_package */
NULL, /* resolve */
+ NULL, /* rollback */
NULL, /* search_details */
NULL, /* search_file */
NULL, /* search_group */
diff --git a/backends/apt/pk-backend-apt.cpp b/backends/apt/pk-backend-apt.cpp
index 6ae221f..7f8d823 100644
--- a/backends/apt/pk-backend-apt.cpp
+++ b/backends/apt/pk-backend-apt.cpp
@@ -670,6 +670,7 @@ extern "C" PK_BACKEND_OPTIONS (
backend_refresh_cache, /* refresh_cache */
NULL, /* remove_package */
NULL, /* resolve */
+ NULL, /* rollback */
backend_search_details, /* search_details */
backend_search_file, /* search_file */
NULL, /* search_group */
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 1a908d9..4314db6 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -512,6 +512,7 @@ PK_BACKEND_OPTIONS (
backend_refresh_cache, /* refresh_cache */
backend_remove_package, /* remove_package */
backend_resolve, /* resolve */
+ NULL, /* rollback */
backend_search_details, /* search_details */
backend_search_file, /* search_file */
NULL, /* search_group */
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index bd6f4e4..6d20c80 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -210,6 +210,7 @@ PK_BACKEND_OPTIONS (
backend_refresh_cache, /* refresh_cache */
backend_remove_package, /* remove_package */
NULL, /* resolve */
+ NULL, /* rollback */
backend_search_details, /* search_details */
NULL, /* search_file */
NULL, /* search_group */
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index 215b124..2f774b1 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -234,6 +234,16 @@ backend_resolve (PkBackend *backend, con
}
/**
+ * backend_rollback:
+ */
+static void
+backend_rollback (PkBackend *backend, const gchar *transaction_id)
+{
+ g_return_if_fail (backend != NULL);
+ pk_backend_finished (backend);
+}
+
+/**
* backend_remove_package:
*/
static void
@@ -375,6 +385,7 @@ PK_BACKEND_OPTIONS (
backend_refresh_cache, /* refresh_cache */
backend_remove_package, /* remove_package */
backend_resolve, /* resolve */
+ backend_rollback, /* rollback */
backend_search_details, /* search_details */
backend_search_file, /* search_file */
backend_search_group, /* search_group */
diff --git a/backends/test/pk-backend-test-fail.c b/backends/test/pk-backend-test-fail.c
index c2b1120..1ce3e10 100644
--- a/backends/test/pk-backend-test-fail.c
+++ b/backends/test/pk-backend-test-fail.c
@@ -185,6 +185,16 @@ backend_resolve (PkBackend *backend, con
}
/**
+ * backend_rollback:
+ */
+static void
+backend_rollback (PkBackend *backend, const gchar *package_id)
+{
+ g_return_if_fail (backend != NULL);
+ pk_backend_finished (backend);
+}
+
+/**
* backend_search_details:
*/
static void
@@ -269,6 +279,7 @@ PK_BACKEND_OPTIONS (
backend_refresh_cache, /* refresh_cache */
backend_remove_package, /* remove_package */
backend_resolve, /* resolve */
+ backend_rollback, /* rollback */
backend_search_details, /* search_details */
backend_search_file, /* search_file */
backend_search_group, /* search_group */
diff --git a/backends/test/pk-backend-test-nop.c b/backends/test/pk-backend-test-nop.c
index 1ccb6b4..8266b8f 100644
--- a/backends/test/pk-backend-test-nop.c
+++ b/backends/test/pk-backend-test-nop.c
@@ -42,6 +42,7 @@ PK_BACKEND_OPTIONS (
NULL, /* refresh_cache */
NULL, /* remove_package */
NULL, /* resolve */
+ NULL, /* rollback */
NULL, /* search_details */
NULL, /* search_file */
NULL, /* search_group */
diff --git a/backends/test/pk-backend-test-spawn.c b/backends/test/pk-backend-test-spawn.c
index 3d7a534..84f2291 100644
--- a/backends/test/pk-backend-test-spawn.c
+++ b/backends/test/pk-backend-test-spawn.c
@@ -55,6 +55,7 @@ PK_BACKEND_OPTIONS (
NULL, /* refresh_cache */
NULL, /* remove_package */
NULL, /* resolve */
+ NULL, /* rollback */
NULL, /* search_details */
NULL, /* search_file */
NULL, /* search_group */
diff --git a/backends/test/pk-backend-test-succeed.c b/backends/test/pk-backend-test-succeed.c
index 5111797..7d179d0 100644
--- a/backends/test/pk-backend-test-succeed.c
+++ b/backends/test/pk-backend-test-succeed.c
@@ -181,6 +181,16 @@ backend_resolve (PkBackend *backend, con
}
/**
+ * backend_rollback:
+ */
+static void
+backend_rollback (PkBackend *backend, const gchar *transaction_id)
+{
+ g_return_if_fail (backend != NULL);
+ pk_backend_finished (backend);
+}
+
+/**
* backend_search_details:
*/
static void
@@ -273,6 +283,7 @@ PK_BACKEND_OPTIONS (
backend_refresh_cache, /* refresh_cache */
backend_remove_package, /* remove_package */
backend_resolve, /* resolve */
+ backend_rollback, /* rollback */
backend_search_details, /* search_details */
backend_search_file, /* search_file */
backend_search_group, /* search_group */
diff --git a/backends/test/pk-backend-test-thread.c b/backends/test/pk-backend-test-thread.c
index c6efd32..47810dc 100644
--- a/backends/test/pk-backend-test-thread.c
+++ b/backends/test/pk-backend-test-thread.c
@@ -102,6 +102,7 @@ PK_BACKEND_OPTIONS (
NULL, /* refresh_cache */
NULL, /* remove_package */
NULL, /* resolve */
+ NULL, /* rollback */
NULL, /* search_details */
NULL, /* search_file */
backend_search_group, /* search_group */
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 5c46467..de183b0 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -246,6 +246,7 @@ PK_BACKEND_OPTIONS (
backend_refresh_cache, /* refresh_cache */
backend_remove_package, /* remove_package */
NULL, /* resolve */
+ NULL, /* rollback */
backend_search_details, /* search_details */
backend_search_file, /* search_file */
NULL, /* search_group */
diff --git a/src/pk-backend.h b/src/pk-backend.h
index 64a25fb..64eea5f 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -106,6 +106,7 @@ struct _PkBackendDesc {
void (*refresh_cache) (PkBackend *backend, gboolean force);
void (*remove_package) (PkBackend *backend, const gchar *package_id, gboolean allow_deps);
void (*resolve) (PkBackend *backend, const gchar *package);
+ void (*rollback) (PkBackend *backend, const gchar *transaction_id);
void (*search_details) (PkBackend *backend, const gchar *filter, const gchar *search);
void (*search_file) (PkBackend *backend, const gchar *filter, const gchar *search);
void (*search_group) (PkBackend *backend, const gchar *filter, const gchar *search);
@@ -118,7 +119,7 @@ struct _PkBackendDesc {
#define PK_BACKEND_OPTIONS(description, version, author, initialize, destroy, \
get_groups, get_filters, cancel, get_depends, get_description, \
get_requires, get_update_detail, get_updates, install_package, install_file, \
- refresh_cache, remove_package, resolve, search_details, \
+ refresh_cache, remove_package, resolve, rollback, search_details, \
search_file, search_group, search_name, \
update_package, update_system) \
G_MODULE_EXPORT const PkBackendDesc pk_backend_desc = { \
@@ -140,6 +141,7 @@ struct _PkBackendDesc {
refresh_cache, \
remove_package, \
resolve, \
+ rollback, \
search_details, \
search_file, \
search_group, \
More information about the PackageKit
mailing list