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

Richard Hughes hughsient at kemper.freedesktop.org
Sun Nov 11 09:59:11 PST 2007


 backends/yum/helpers/yumBackend.py |   11 +++-
 client/pk-console.c                |   98 +++++++++++++++++++++++++++++++++++--
 docs/wscript_build                 |   19 +++++--
 libpackagekit/pk-enum.c            |    1 
 libpackagekit/pk-enum.h            |   17 +++++-
 5 files changed, 133 insertions(+), 13 deletions(-)

New commits:
commit d3d25bbc99955c8b86cb9473420ae71b8d8783ad
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Nov 11 17:57:04 2007 +0000

    add in the 'do you want to remove all of foo' message when you do pkcon remove hal - some work still required - i need a console legend to help me with the input stuff

diff --git a/client/pk-console.c b/client/pk-console.c
index 20e9eb2..8bb1694 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -41,10 +41,12 @@
 #define MINIMUM_COLUMNS (PROGRESS_BAR_PADDING + 5)
 
 static GMainLoop *loop = NULL;
+static PkEnumList *role_list = NULL;
 static gboolean is_console = FALSE;
 static gboolean has_output = FALSE;
 static gboolean printed_bar = FALSE;
 static guint timer_id = 0;
+static gchar *package_id = NULL;
 
 typedef struct {
 	gint position;
@@ -460,21 +462,104 @@ pk_console_install_package (PkClient *client, const gchar *package)
 }
 
 /**
+ * pk_console_remove_only:
+ **/
+static gboolean
+pk_console_remove_only (PkClient *client, gboolean force)
+{
+	gboolean ret;
+
+	pk_debug ("remove %s", package_id);
+	pk_client_reset (client);
+	ret = pk_client_remove_package (client, package_id, force);
+	/* ick, we failed so pretend we didn't do the action */
+	if (ret == FALSE) {
+		pk_warning ("The package could not be removed");
+	}
+	return ret;
+}
+
+/**
+ * pk_console_requires_finished_cb:
+ **/
+static void
+pk_console_requires_finished_cb (PkClient *client2, PkStatusEnum status, guint runtime, PkClient *client)
+{
+	guint length;
+	PkPackageItem *item;
+	PkPackageId *ident;
+	guint i;
+	gboolean remove;
+
+	/* see how many packages there are */
+	length = pk_client_package_buffer_get_size (client2);
+
+	/* if there are no required packages, just do the remove */
+	if (length == 0) {
+		pk_debug ("no requires");
+		pk_console_remove_only (client, FALSE);
+		g_object_unref (client2);
+		return;
+	}
+
+	/* present this to the user */
+	g_print ("The following packages have to be removed:\n");
+	for (i=0; i<length; i++) {
+		item = pk_client_package_buffer_get_item (client2, i);
+		ident = pk_package_id_new_from_string (item->package_id);
+		g_print ("%i\t%s-%s\n", i, ident->name, ident->version);
+		pk_package_id_free (ident);
+	}
+
+	/* check for user input */
+	g_print ("Okay to remove additional packages? [N/y]\n");
+
+	/* TODO: prompt the user */
+	remove = FALSE;
+
+	if (remove == FALSE) {
+		g_print ("Cancelled!\n");
+		if (loop != NULL) {
+			g_main_loop_quit (loop);
+			pk_debug ("<kjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
+		}
+	} else {
+		pk_debug ("the user aggreed, remove with deps");
+		pk_console_remove_only (client, TRUE);
+	}
+	g_object_unref (client2);
+}
+
+/**
  * pk_console_remove_package:
  **/
 static gboolean
 pk_console_remove_package (PkClient *client, const gchar *package)
 {
-	gboolean ret;
-	gchar *package_id;
+	PkClient *client2;
+
+	g_free (package_id);
 	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_INSTALLED, package);
 	if (package_id == NULL) {
 		g_print ("Could not find a package with that name to remove\n");
 		return FALSE;
 	}
-	ret = pk_client_remove_package (client, package_id, FALSE);
-	g_free (package_id);
-	return ret;
+
+	/* are we dumb and can't check for requires? */
+	if (pk_enum_list_contains (role_list, PK_ROLE_ENUM_GET_REQUIRES) == FALSE) {
+		/* no, just try to remove it without deps */
+		pk_console_remove_only (client, FALSE);
+		return TRUE;
+	}
+
+	/* see if any packages require this one */
+	client2 = pk_client_new ();
+	pk_client_set_use_buffer (client2, TRUE);
+	g_signal_connect (client2, "finished",
+			  G_CALLBACK (pk_console_requires_finished_cb), client);
+	pk_debug ("getting requires for %s", package_id);
+	pk_client_get_requires (client2, package_id, TRUE);
+	return TRUE;
 }
 
 /**
@@ -966,6 +1051,9 @@ main (int argc, char *argv[])
 	g_signal_connect (client, "error-code",
 			  G_CALLBACK (pk_console_error_code_cb), NULL);
 
+	role_list = pk_client_get_actions (client);
+	pk_debug ("actions=%s", pk_enum_list_to_string (role_list));
+
 	/* run the commands */
 	pk_console_process_commands (client, argc, argv, !nowait, &error);
 	if (error != NULL) {
commit ef84c1e3ec716ddc21fab7d46a99202063e28211
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Nov 11 17:24:30 2007 +0000

    yup, we install to doc/name-version by default

diff --git a/docs/wscript_build b/docs/wscript_build
index e795116..34aee40 100644
--- a/docs/wscript_build
+++ b/docs/wscript_build
@@ -11,9 +11,8 @@
 
 import Utils
 
-## FIXME: shouldn't it be: doc_subdir = os.path.join('doc', Utils.g_module.APPNAME) ?
-doc_subdir = os.path.join(Utils.g_module.APPNAME, 'docs')
-
+#install to a versioned doc folder
+doc_subdir = os.path.join('doc', Utils.g_module.APPNAME+'-'+Utils.g_module.VERSION)
 install_files('DATADIR', doc_subdir, 'pk-reference.html')
 install_files('DATADIR', doc_subdir, 'pk-structure.png')
 install_files('DATADIR', doc_subdir, 'docbook.css')
commit 80b1224f198d2c09e4ef72c1a9e8c83a3793cb2e
Author: Gustavo Carneiro <gjc at inescporto.pt>
Date:   Sun Nov 11 15:06:07 2007 +0000

    Use the new cwd option of command-output to work around xmlto bug.  Needs waf trunk update.

diff --git a/docs/wscript_build b/docs/wscript_build
index 9951d58..e795116 100644
--- a/docs/wscript_build
+++ b/docs/wscript_build
@@ -23,6 +23,7 @@ cmd = bld.create_obj('command-output')
 cmd.hidden_outputs = 'pk-reference.html'
 cmd.command = 'xmlto'
 cmd.command_is_external = True
+cmd.cwd = cmd.input_dir('.') # xmlto is stupid, doesn't work from outside the xml source dir :(
 cmd.argv = ['html-nochunks', '-m', cmd.input_file('config.xsl'),
             '--searchpath', cmd.input_dir('.'), '-o', cmd.output_dir('.'),
             cmd.input_file('pk-reference.xml')]
commit d1699ea08498e39004c7bb3c2433003a19087f37
Author: Gustavo Carneiro <gjc at inescporto.pt>
Date:   Sun Nov 11 12:45:21 2007 +0000

    Run the xmlto command to generate html docs. Caveat1: requires waf trunk; Caveat2: xmlto fails (does not seem to validate), I don't know why.

diff --git a/docs/wscript_build b/docs/wscript_build
index dd64aaa..9951d58 100644
--- a/docs/wscript_build
+++ b/docs/wscript_build
@@ -9,8 +9,6 @@
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
 
-# TODO: we want to build this using xmlto, i.e. doxmlto html-nochunks -m config.xsl pk-reference.xml
-
 import Utils
 
 ## FIXME: shouldn't it be: doc_subdir = os.path.join('doc', Utils.g_module.APPNAME) ?
@@ -20,3 +18,11 @@ install_files('DATADIR', doc_subdir, 'pk-reference.html')
 install_files('DATADIR', doc_subdir, 'pk-structure.png')
 install_files('DATADIR', doc_subdir, 'docbook.css')
 
+# xmlto html-nochunks -m config.xsl pk-reference.xml
+cmd = bld.create_obj('command-output')
+cmd.hidden_outputs = 'pk-reference.html'
+cmd.command = 'xmlto'
+cmd.command_is_external = True
+cmd.argv = ['html-nochunks', '-m', cmd.input_file('config.xsl'),
+            '--searchpath', cmd.input_dir('.'), '-o', cmd.output_dir('.'),
+            cmd.input_file('pk-reference.xml')]
commit 167e832d9b228ffa960c77e3ef741e3c67488b61
Author: Gustavo Carneiro <gjc at inescporto.pt>
Date:   Sun Nov 11 11:39:57 2007 +0000

    Fix the docs installation dir.

diff --git a/docs/wscript_build b/docs/wscript_build
index 0a772fa..dd64aaa 100644
--- a/docs/wscript_build
+++ b/docs/wscript_build
@@ -11,7 +11,12 @@
 
 # TODO: we want to build this using xmlto, i.e. doxmlto html-nochunks -m config.xsl pk-reference.xml
 
-install_files('DATADIR', 'APPNAME/docs', 'pk-reference.html')
-install_files('DATADIR', 'APPNAME/docs', 'pk-structure.png')
-install_files('DATADIR', 'APPNAME/docs', 'docbook.css')
+import Utils
+
+## FIXME: shouldn't it be: doc_subdir = os.path.join('doc', Utils.g_module.APPNAME) ?
+doc_subdir = os.path.join(Utils.g_module.APPNAME, 'docs')
+
+install_files('DATADIR', doc_subdir, 'pk-reference.html')
+install_files('DATADIR', doc_subdir, 'pk-structure.png')
+install_files('DATADIR', doc_subdir, 'docbook.css')
 
commit bc7703666d677c3e8b901fe7382d7b7673a0e430
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Nov 11 10:09:11 2007 +0000

    add another info enum so we get the correct icon

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index f18a318..5b8fe18 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -642,6 +642,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         '''
         self.allow_interrupt(True);
         self.percentage(0)
+        self.status(STATUS_REFRESH_CACHE)
 
         pct = 0
         try:
commit d9009da075576451fce4ad05c811990e9d4638cc
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Nov 11 10:03:54 2007 +0000

    use the new STATUS_INFO enu state so we can get the correct icon

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 0322b6d..f18a318 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -512,7 +512,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         '''
         self.allow_interrupt(True)
         self.percentage(None)
-        self.status(STATUS_QUERY)
+        self.status(STATUS_INFO)
         name = package.split(';')[0]
         pkg,inst = self._findPackage(package)
         pkgs = self.yumbase.rpmdb.searchRequires(pkg.name)
@@ -603,7 +603,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         '''
         self.allow_interrupt(True)
         self.percentage(None)
-        self.status(STATUS_QUERY)
+        self.status(STATUS_INFO)
 
         name = package.split(';')[0]
         pkg,inst = self._findPackage(package)
@@ -678,6 +678,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         self.percentage(None)
         self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)# Setup Yum Config
         self.yumbase.conf.cache = 1 # Only look in cache.
+        self.status(STATUS_QUERY)
 
         fltlist = filters.split(';')
         try:
@@ -919,6 +920,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         '''
         self.allow_interrupt(True)
         self.percentage(None)
+        self.status(STATUS_INFO)
 
         pkg,inst = self._findPackage(package)
         if pkg:
@@ -941,6 +943,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
     def get_files(self, package):
         self.allow_interrupt(True)
         self.percentage(None)
+        self.status(STATUS_INFO)
 
         pkg,inst = self._findPackage(package)
         if pkg:
@@ -977,6 +980,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         '''
         self.allow_interrupt(True)
         self.percentage(None)
+        self.status(STATUS_INFO)
         md = UpdateMetadata()
         # Added extra Update Metadata
         for repo in self.yumbase.repos.listEnabled():
@@ -1015,6 +1019,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         '''
         Implement the {backend}-get-repo-list functionality
         '''
+        self.status(STATUS_INFO)
         for repo in self.yumbase.repos.repos.values():
             if repo.isEnabled():
                 self.repo_detail(repo.id,repo.name,'true')
@@ -1054,6 +1059,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         '''
         self.allow_interrupt(True)
         self.percentage(None)
+        self.status(STATUS_INFO)
         name = package.split(';')[0]
         pkg,inst = self._findPackage(package)
         update = self._get_updated(pkg)
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 4339c30..abaa61a 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -45,6 +45,7 @@ static PkEnumMatch enum_status[] = {
 	{PK_STATUS_ENUM_WAIT,			"wait"},
 	{PK_STATUS_ENUM_SETUP,			"setup"},
 	{PK_STATUS_ENUM_QUERY,			"query"},
+	{PK_STATUS_ENUM_INFO,			"info"},
 	{PK_STATUS_ENUM_REFRESH_CACHE,		"refresh-cache"},
 	{PK_STATUS_ENUM_REMOVE,			"remove"},
 	{PK_STATUS_ENUM_DOWNLOAD,		"download"},
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index ccd3f3a..b869485 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -32,7 +32,10 @@ typedef struct {
 	const gchar	*string;
 } PkEnumMatch;
 
-/* what we asked to do */
+/* What we were asked to do, this never changes for the lifetime of the
+ * transaction
+ * Icons that have to represent the whole "aim" of the transaction will use
+ * these constants */
 typedef enum {
 	PK_ROLE_ENUM_CANCEL,
 	PK_ROLE_ENUM_RESOLVE,
@@ -59,11 +62,16 @@ typedef enum {
 	PK_ROLE_ENUM_UNKNOWN
 } PkRoleEnum;
 
-/* if you add to this, make sure you add filenames in pk-watch */
+/* What status we are now; this can change for each transaction giving a
+ * status of what sort of thing is happening
+ * Icons that change to represent the current status of the transaction will
+ * use these constants
+ * If you add to these, make sure you add filenames in pk-watch also */
 typedef enum {
 	PK_STATUS_ENUM_SETUP,
 	PK_STATUS_ENUM_WAIT,
 	PK_STATUS_ENUM_QUERY,
+	PK_STATUS_ENUM_INFO,
 	PK_STATUS_ENUM_REMOVE,
 	PK_STATUS_ENUM_REFRESH_CACHE,
 	PK_STATUS_ENUM_DOWNLOAD,
@@ -74,6 +82,7 @@ typedef enum {
 	PK_STATUS_ENUM_UNKNOWN
 } PkStatusEnum;
 
+/* how the backend exited */
 typedef enum {
 	PK_EXIT_ENUM_SUCCESS,
 	PK_EXIT_ENUM_FAILED,
@@ -82,6 +91,7 @@ typedef enum {
 	PK_EXIT_ENUM_UNKNOWN
 } PkExitEnum;
 
+/* the filter types */
 typedef enum {
 	PK_FILTER_ENUM_DEVELOPMENT,
 	PK_FILTER_ENUM_INSTALLED,
@@ -93,6 +103,7 @@ typedef enum {
 	PK_FILTER_ENUM_UNKNOWN
 } PkFilterEnum;
 
+/* what restart we need to after a transaction */
 typedef enum {
 	PK_RESTART_ENUM_NONE,
 	PK_RESTART_ENUM_APPLICATION,
@@ -171,6 +182,8 @@ typedef enum {
 	PK_UPDATE_ENUM_UNKNOWN
 } PkUpdateEnum;
 
+/* the enumerated types used in Package() - these have to refer to a specific
+   package action, rather than a general state */
 typedef enum {
 	PK_INFO_ENUM_INSTALLED,
 	PK_INFO_ENUM_AVAILABLE,



More information about the PackageKit mailing list