[packagekit] packagekit: Branch 'master' - 3 commits

Richard Hughes hughsient at kemper.freedesktop.org
Tue Oct 30 13:08:06 PDT 2007


 backends/box/helpers/Makefile.am       |    1 
 backends/box/helpers/remove-package.sh |   15 ---------
 backends/box/pk-backend-box.c          |   50 ++++++++++++++++++++++++++++++---
 backends/yum/helpers/Makefile.am       |    1 
 4 files changed, 47 insertions(+), 20 deletions(-)

New commits:
commit fbb543843f88ee96e26bab7473be11f6e6e76ea3
Merge: c6c7625... 6a100b5...
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 30 20:03:35 2007 +0000

    Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit

commit 6a100b58bccb339bdb8eaa0bb065840f3ebcebeb
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Tue Oct 30 21:06:07 2007 +0000

    [box] use C API with percent updates for removing packages instead of shell script

diff --git a/backends/box/helpers/Makefile.am b/backends/box/helpers/Makefile.am
index 80d5fd3..b9ae0d2 100644
--- a/backends/box/helpers/Makefile.am
+++ b/backends/box/helpers/Makefile.am
@@ -7,7 +7,6 @@ dist_helper_DATA = 			\
 	install-file.sh			\
 	install-package.sh		\
 	refresh-cache.sh		\
-	remove-package.sh		\
 	update-package.sh		\
 	update-system.sh		\
 	$(NULL)
diff --git a/backends/box/helpers/remove-package.sh b/backends/box/helpers/remove-package.sh
deleted file mode 100644
index 5e3ab9b..0000000
--- a/backends/box/helpers/remove-package.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2007 Grzegorz Dabrowski <gdx at o2.pl>
-#
-# 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.
-
-echo "no-percentage-updates" > /dev/stderr
-echo "status	remove" > /dev/stderr
-pkg=$(echo "$2" | cut -f1 -d';')
-box -u "$pkg" 2>&1 >/dev/null
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 3bb4729..cfd554d 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -31,6 +31,7 @@
 #include <libbox/libbox-db-utils.h>
 #include <libbox/libbox-db-repos.h>
 #include <libbox/libbox-repos.h>
+#include <libbox/libbox.h>
 
 enum PkgSearchType {
 	SEARCH_TYPE_NAME = 0,
@@ -44,6 +45,11 @@ enum DepsType {
 	DEPS_TYPE_REQUIRES = 1
 };
 
+enum DepsBehaviour {
+	DEPS_ALLOW = 0,
+	DEPS_NO_ALLOW = 1
+};
+
 typedef struct {
 	gchar *search;
 	gchar *filter;
@@ -383,6 +389,39 @@ backend_get_depends_requires_thread (PkBackend *backend, gpointer data)
 	return TRUE;
 }
 
+static void
+uninstall_progress(int value, gpointer user_data)
+{
+	PkBackend* backend = (PkBackend *) user_data;
+	pk_backend_change_percentage (backend, value);
+}
+
+static gboolean
+backend_remove_package_thread (PkBackend *backend, gpointer data)
+{
+	ThreadData *d = (ThreadData*) data;
+	PkPackageId *pi;
+
+	pi = pk_package_id_new_from_string (d->package_id);
+	if (pi == NULL) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+		g_free (d->package_id);
+		g_free (d);
+		return FALSE;
+	}
+
+	if (!box_package_uninstall (pi->name, "/", uninstall_progress, backend))
+	{
+		pk_backend_error_code (backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "Cannot uninstall");
+	}
+
+	pk_package_id_free (pi);
+	g_free (d->package_id);
+	g_free (d);
+
+	return TRUE;
+}
+
 /* ===================================================================== */
 
 /**
@@ -555,15 +594,18 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
 static void
 backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps)
 {
-	const gchar *deps;
+	ThreadData *data = g_new0(ThreadData, 1);
 
 	g_return_if_fail (backend != NULL);
+
 	if (allow_deps == TRUE) {
-		deps = "yes";
+		data->type = DEPS_ALLOW;
 	} else {
-		deps = "no";
+		data->type = DEPS_NO_ALLOW;
 	}
-	pk_backend_spawn_helper (backend, "remove-package.sh", deps, package_id, NULL);
+	data->package_id = g_strdup (package_id);
+    
+	pk_backend_thread_helper (backend, backend_remove_package_thread, data);
 }
 
 /**
commit c6c7625475be49a0e584088002179d093ca1bdd1
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 30 20:03:18 2007 +0000

    dist get-files.py for the yum backend

diff --git a/backends/yum/helpers/Makefile.am b/backends/yum/helpers/Makefile.am
index f38d74c..e748b4d 100644
--- a/backends/yum/helpers/Makefile.am
+++ b/backends/yum/helpers/Makefile.am
@@ -10,6 +10,7 @@ dist_helper_DATA = 			\
 	search-file.py			\
 	get-depends.py			\
 	get-requires.py			\
+	get-files.py			\
 	get-updates.py			\
 	get-description.py		\
 	get-repo-list.py		\



More information about the PackageKit mailing list