[PackageKit-commit] packagekit: Branch 'master' - 5 commits

Richard Hughes hughsient at kemper.freedesktop.org
Fri Jun 13 00:46:05 PDT 2008


 backends/yum/helpers/yumBackend.py      |   21 +++++++++++-
 backends/yum2/helpers/yumDBUSBackend.py |   21 +++++++++++-
 data/tests/pk-spawn-test.sh             |    2 -
 libpackagekit/pk-client.c               |    4 +-
 libpackagekit/pk-common.c               |   52 ++++++++++++++++++++++++++++++++
 libpackagekit/pk-common.h               |    4 ++
 src/pk-spawn.c                          |   14 +-------
 7 files changed, 98 insertions(+), 20 deletions(-)

New commits:
commit 768cc50222ce17d45c662bb2e11069392a6be5d0
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Jun 13 08:43:47 2008 +0100

    bugfix: In PkSpawn don't convert stdout from the C locale to UTF-8, as some backends are quite capable of outputting valid UTF-8 themselves.
    
    We already do UTF8 validation in the pk_strsafe() function, so the conversion is safe to remove.

diff --git a/data/tests/pk-spawn-test.sh b/data/tests/pk-spawn-test.sh
index 67f0c7a..7be7395 100755
--- a/data/tests/pk-spawn-test.sh
+++ b/data/tests/pk-spawn-test.sh
@@ -18,7 +18,7 @@ sleep ${time}
 echo -e "percentage\t40"
 sleep ${time}
 echo -e "package\tavailable\tpolkit;0.0.1;i386;data\tPolicyKit daemon"
-echo -e "package\tinstalled\tpolkit-gnome;0.0.1;i386;data\tPolicyKit helper for GNOME"
+echo -e "package\tinstalled\tpolkit-gnome;0.0.1;i386;data\tPolicyKit helper (•) for GNOME"
 sleep ${time}
 echo -e -n "package\tavailable\tConsoleKit"
 sleep ${time}
diff --git a/src/pk-spawn.c b/src/pk-spawn.c
index dc08e4c..7c23af7 100644
--- a/src/pk-spawn.c
+++ b/src/pk-spawn.c
@@ -99,12 +99,11 @@ pk_spawn_read_fd_into_buffer (gint fd, GString *string)
  * pk_spawn_emit_whole_lines:
  **/
 static gboolean
-pk_spawn_emit_whole_lines (PkSpawn *spawn, GString *string, gboolean is_stdout)
+pk_spawn_emit_whole_lines (PkSpawn *spawn, GString *string)
 {
 	guint i;
 	guint size;
 	gchar **lines;
-	gchar *message;
 	guint bytes_processed;
 
 	/* ITS4: ignore, GString is always NULL terminated */
@@ -124,14 +123,7 @@ pk_spawn_emit_whole_lines (PkSpawn *spawn, GString *string, gboolean is_stdout)
 	bytes_processed = 0;
 	/* we only emit n-1 strings */
 	for (i=0; i<(size-1); i++) {
-		message = g_locale_to_utf8 (lines[i], -1, NULL, NULL, NULL);
-		if (message == NULL) {
-			pk_warning ("cannot covert line to UTF8: %s", lines[i]);
-		} else if (is_stdout) {
-			pk_debug ("emitting stdout %s", message);
-			g_signal_emit (spawn, signals [PK_SPAWN_STDOUT], 0, message);
-		}
-		g_free (message);
+		g_signal_emit (spawn, signals [PK_SPAWN_STDOUT], 0, lines[i]);
 		/* ITS4: ignore, g_strsplit always NULL terminates */
 		bytes_processed += strlen (lines[i]) + 1;
 	}
@@ -157,7 +149,7 @@ pk_spawn_check_child (PkSpawn *spawn)
 	}
 
 	pk_spawn_read_fd_into_buffer (spawn->priv->stdout_fd, spawn->priv->stdout_buf);
-	pk_spawn_emit_whole_lines (spawn, spawn->priv->stdout_buf, TRUE);
+	pk_spawn_emit_whole_lines (spawn, spawn->priv->stdout_buf);
 
 	/* check if the child exited */
 	if (waitpid (spawn->priv->child_pid, &status, WNOHANG) != spawn->priv->child_pid)
commit 8ff45df6816ed52efeaab2ebf47a7ccdde088ba9
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Jun 11 11:56:38 2008 +0100

    yum: limit the error text to 1024 chars to avoid hanging the daemon when rpm is broken. fixes rh#450594

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 47a0ef5..10ff660 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -1074,10 +1074,17 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                 self.require_restart(RESTART_SYSTEM,"")
                 break
 
+    def _truncate(text,length,etc='...'):
+        if len(text) < length:
+            return text
+        else:
+            return text[:length] + etc
+
     def _format_msgs(self,msgs):
         if isinstance(msgs,basestring):
              msgs = msgs.split('\n')
         text = ";".join(msgs)
+        text = self._truncate(text, 1024);
         text = text.replace("Missing Dependency: ","")
         text = text.replace(" (installed)","")
         return text
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index 48f5b78..df15b98 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -1739,10 +1739,17 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                 self.require_restart(RESTART_SYSTEM,"")
                 break
 
+    def _truncate(text,length,etc='...'):
+        if len(text) < length:
+            return text
+        else:
+            return text[:length] + etc
+
     def _format_msgs(self,msgs):
         if isinstance(msgs,basestring):
              msgs = msgs.split('\n')
         text = ";".join(msgs)
+        text = self._truncate(text, 1024);
         text = text.replace("Missing Dependency: ","")
         text = text.replace(" (installed)","")
         return text
commit 41b7b2c40996a02487c9c696fc5753643dd66888
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Jun 11 11:36:43 2008 +0100

    yum: use the proper package group when we do ::Details()

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 4703638..47a0ef5 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -1012,7 +1012,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                         self.error(ERROR_LOCAL_INSTALL_FAILED,"Can't install %s" % inst_file)
             except yum.Errors.InstallError,e:
                 self.error(ERROR_LOCAL_INSTALL_FAILED,str(e))
-                
+
     def _check_local_file(self, pkg):
         """
         Duplicates some of the checks that yumbase.installLocal would
@@ -1184,8 +1184,16 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         desc = desc.replace('\n\n',';')
         desc = desc.replace('\n',' ')
 
-        self.details(id,pkg.license,"unknown",desc,pkg.url,
-                         pkg.size)
+        # this takes oodles of time
+        pkgGroupDict = self._buildGroupDict()
+        group = GROUP_OTHER
+        if pkgGroupDict.has_key(pkg.name):
+            cg = pkgGroupDict[pkg.name]
+            if groupMap.has_key(cg):
+                # use PK group name
+                group = groupMap[cg]
+
+        self.details(id,pkg.license,group,desc,pkg.url,pkg.size)
 
     def get_files(self,package):
         self._check_init()
diff --git a/backends/yum2/helpers/yumDBUSBackend.py b/backends/yum2/helpers/yumDBUSBackend.py
index 7209baa..48f5b78 100755
--- a/backends/yum2/helpers/yumDBUSBackend.py
+++ b/backends/yum2/helpers/yumDBUSBackend.py
@@ -452,7 +452,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                     if group == key:
                         if self._do_extra_filtering(pkg, fltlist):
                             package_list.append((pkg,INFO_INSTALLED))
-                    installed_nevra.append(self._get_nevra(pkg))                        
+                    installed_nevra.append(self._get_nevra(pkg))
 
             if not FILTER_INSTALLED in fltlist:
                 # Check available for group
@@ -1576,8 +1576,16 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         desc = desc.replace('\n',' ')
         desc = desc.replace('__PARAGRAPH_SEPARATOR__','\n')
 
-        self._show_details(id, pkg.license, "unknown", desc, pkg.url,
-                             pkg.size)
+        # this takes oodles of time
+        pkgGroupDict = self._buildGroupDict()
+        group = GROUP_OTHER
+        if pkgGroupDict.has_key(pkg.name):
+            cg = pkgGroupDict[pkg.name]
+            if groupMap.has_key(cg):
+                # use PK group name
+                group = groupMap[cg]
+
+        self._show_details(id, pkg.license, group, desc, pkg.url, pkg.size)
 
     def _getEVR(self,idver):
         '''
commit 27f737eb6e8120e5c33c406c1b91400eeedf10e8
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Jun 11 11:36:08 2008 +0100

    trivial: add two convenieve functions, pk_ptr_array_find_string() and pk_ptr_array_remove_string()

diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index 0be0e6e..83da6fd 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -187,6 +187,58 @@ pk_iso8601_difference (const gchar *isodate)
 	return time;
 }
 
+/**
+ * pk_ptr_array_find_string:
+ * @array: The GPtrArray to operate on
+ * @string: The string to search for
+ *
+ * Return value: The array index, or -1 if not found
+ **/
+gint
+pk_ptr_array_find_string (GPtrArray *array, const gchar *string)
+{
+	gint i;
+	gchar *item;
+
+	g_return_val_if_fail (array != NULL, FALSE);
+	g_return_val_if_fail (string != NULL, FALSE);
+
+	for (i=0; i<array->len; i++) {
+		item = (gchar *) g_ptr_array_index (array, i);
+		if (pk_strequal (string, item)) {
+			return i;
+		}
+	}
+	return -1;
+}
+
+/**
+ * pk_ptr_array_remove_string:
+ * @array: The GPtrArray to operate on
+ * @string: The string to search for
+ *
+ * Return value: %TRUE if we removed any strings
+ **/
+gboolean
+pk_ptr_array_remove_string (GPtrArray *array, const gchar *string)
+{
+	guint i;
+	gchar *item;
+	gboolean ret = FALSE;
+
+	g_return_val_if_fail (array != NULL, FALSE);
+	g_return_val_if_fail (string != NULL, FALSE);
+
+	for (i=0; i<array->len; i++) {
+		item = (gchar *) g_ptr_array_index (array, i);
+		if (pk_strequal (string, item)) {
+			g_free (item);
+			g_ptr_array_remove_index (array, i);
+			ret = TRUE;
+		}
+	}
+	return ret;
+}
 
 /**
  * pk_strvalidate_char:
diff --git a/libpackagekit/pk-common.h b/libpackagekit/pk-common.h
index 9e5a05e..f5b2aba 100644
--- a/libpackagekit/pk-common.h
+++ b/libpackagekit/pk-common.h
@@ -87,6 +87,10 @@ gchar		*pk_strbuild_va				(const gchar	*first_element,
 gchar		*pk_strreplace				(const gchar	*text,
 							 const gchar	*find,
 							 const gchar	*replace);
+gint		 pk_ptr_array_find_string		(GPtrArray	*array,
+							 const gchar	*string);
+gboolean	 pk_ptr_array_remove_string		(GPtrArray	*array,
+							 const gchar	*string);
 gchar		**pk_ptr_array_to_argv			(GPtrArray	*array)
 							 G_GNUC_WARN_UNUSED_RESULT;
 gchar		**pk_va_list_to_argv			(const gchar	*string_first,
commit c5de7f6cda9ca6d4a31599ad2348025d8c2aea02
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Jun 11 11:35:25 2008 +0100

    trivial: improve some debugging output

diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index e552a99..7ef665e 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -626,8 +626,8 @@ pk_client_details_cb (DBusGProxy  *proxy,
 	g_return_if_fail (PK_IS_CLIENT (client));
 
 	group = pk_group_enum_from_text (group_text);
-	pk_debug ("emit details %s, %s, %i, %s, %s, %ld",
-		  package_id, license, group, description, url, (long int) size);
+	pk_debug ("emit details %s, %s, %s, %s, %s, %ld",
+		  package_id, license, pk_group_enum_to_text (group), description, url, (long int) size);
 	g_signal_emit (client , signals [PK_CLIENT_DETAILS], 0,
 		       package_id, license, group, description, url, size);
 }


More information about the PackageKit-commit mailing list