[zif] - Backport 2 fixes from git master to fix

Richard Hughes rhughes at fedoraproject.org
Tue Oct 12 12:23:03 UTC 2010


commit f45648e967408e32918a5d5f8678c29c04987d0d
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 12 14:23:34 2010 +0100

    - Backport 2 fixes from git master to fix

 backport-fixes.patch |  244 ++++++++++++++++++++++++++++++++++++++++++++++++++
 zif.spec             |   11 ++-
 2 files changed, 254 insertions(+), 1 deletions(-)
---
diff --git a/backport-fixes.patch b/backport-fixes.patch
new file mode 100644
index 0000000..a6efdb1
--- /dev/null
+++ b/backport-fixes.patch
@@ -0,0 +1,244 @@
+diff --git a/libzif/zif-self-test.c b/libzif/zif-self-test.c
+index 61dbb21..cbac932 100644
+--- a/libzif/zif-self-test.c
++++ b/libzif/zif-self-test.c
+@@ -1340,6 +1340,7 @@ zif_state_func (void)
+ 
+ 	g_object_unref (state);
+ 	g_object_unref (child);
++	g_clear_error (&error);
+ 
+ 	/* test new child gets error handler passed to it */
+ 	state = zif_state_new ();
+@@ -1351,6 +1352,25 @@ zif_state_func (void)
+ 
+ 	g_object_unref (state);
+ 	g_object_unref (child);
++	g_clear_error (&error);
++
++	/* check straight finish */
++	state = zif_state_new ();
++	zif_state_set_number_steps (state, 3);
++
++	child = zif_state_get_child (state);
++	zif_state_set_number_steps (child, 3);
++	ret = zif_state_finished (child, &error);
++	g_assert_no_error (error);
++	g_assert (ret);
++
++	/* parent step done after child finish */
++	ret = zif_state_done (state, &error);
++	g_assert_no_error (error);
++	g_assert (ret);
++
++	g_object_unref (state);
++	g_object_unref (child);
+ }
+ 
+ static void
+diff --git a/libzif/zif-store-remote.c b/libzif/zif-store-remote.c
+index add98f3..03dd62e 100644
+--- a/libzif/zif-store-remote.c
++++ b/libzif/zif-store-remote.c
+@@ -1200,6 +1200,91 @@ out:
+ }
+ 
+ /**
++ * zif_store_remote_refresh_md:
++ **/
++static gboolean
++zif_store_remote_refresh_md (ZifStoreRemote *remote, ZifMd *md, gboolean force, ZifState *state, GError **error)
++{
++	const gchar *filename;
++	gboolean repo_verified;
++	gboolean ret;
++	GError *error_local = NULL;
++	ZifState *state_local = NULL;
++
++	/* setup progress */
++	zif_state_set_number_steps (state, 3);
++
++	/* get filename */
++	filename = zif_md_get_location (md);
++	if (filename == NULL) {
++		egg_debug ("no filename set for %s",
++			   zif_md_type_to_text (zif_md_get_mdtype (md)));
++		ret = zif_state_finished (state, error);
++		goto out;
++	}
++
++	/* does current uncompressed file equal what repomd says it should be */
++	state_local = zif_state_get_child (state);
++	repo_verified = zif_md_file_check (md, TRUE, state_local, &error_local);
++	if (!repo_verified) {
++		egg_warning ("failed to verify md: %s", error_local->message);
++		g_clear_error (&error_local);
++		ret = zif_state_finished (state_local, error);
++		goto out;
++	}
++	if (repo_verified && !force) {
++		egg_debug ("%s is okay, and we're not forcing",
++			   zif_md_type_to_text (zif_md_get_mdtype (md)));
++		ret = zif_state_finished (state, error);
++		goto out;
++	}
++
++	/* this section done */
++	ret = zif_state_done (state, error);
++	if (!ret)
++		goto out;
++
++	/* download new file */
++	state_local = zif_state_get_child (state);
++	ret = zif_store_remote_download (remote, filename, remote->priv->directory, state_local, &error_local);
++	if (!ret) {
++		g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
++			     "failed to refresh %s (%s): %s",
++			     zif_md_type_to_text (zif_md_get_mdtype (md)),
++			     filename,
++			     error_local->message);
++		g_error_free (error_local);
++		goto out;
++	}
++
++	/* this section done */
++	ret = zif_state_done (state, error);
++	if (!ret)
++		goto out;
++
++	/* decompress */
++	state_local = zif_state_get_child (state);
++	filename = zif_md_get_filename (md);
++	ret = zif_store_file_decompress (filename, state_local, &error_local);
++	if (!ret) {
++		g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
++			     "failed to decompress %s for %s: %s",
++			     filename,
++			     zif_md_type_to_text (zif_md_get_mdtype (md)),
++			     error_local->message);
++		g_error_free (error_local);
++		goto out;
++	}
++
++	/* this section done */
++	ret = zif_state_done (state, error);
++	if (!ret)
++		goto out;
++out:
++	return ret;
++}
++
++/**
+  * zif_store_remote_refresh:
+  **/
+ static gboolean
+@@ -1207,10 +1292,8 @@ zif_store_remote_refresh (ZifStore *store, gboolean force, ZifState *state, GErr
+ {
+ 	gboolean ret = FALSE;
+ 	GError *error_local = NULL;
+-	const gchar *filename;
+ 	ZifState *state_local = NULL;
+ 	ZifState *state_loop = NULL;
+-	ZifState *state_tmp = NULL;
+ 	ZifStoreRemote *remote = ZIF_STORE_REMOTE (store);
+ 	ZifMd *md;
+ 	guint i;
+@@ -1274,81 +1357,19 @@ zif_store_remote_refresh (ZifStore *store, gboolean force, ZifState *state, GErr
+ 	/* refresh each repo type */
+ 	for (i=0; i<ZIF_MD_TYPE_UNKNOWN; i++) {
+ 
+-		/* do in nested completion */
+-		state_loop = zif_state_get_child (state_local);
+-		zif_state_set_number_steps (state_loop, 3);
+-
+ 		/* get md */
+ 		md = zif_store_remote_get_md_from_type (remote, i);
+ 		if (md == NULL) {
+ 			egg_debug ("failed to get local store for %s", zif_md_type_to_text (i));
+-			ret = zif_state_finished (state_loop, error);
+-			if (!ret)
+-				goto out;
+-			goto skip;
+-		}
+-
+-		/* get filename */
+-		filename = zif_md_get_location (md);
+-		if (filename == NULL) {
+-			egg_warning ("no filename set for %s", zif_md_type_to_text (i));
+-			ret = zif_state_finished (state_loop, error);
+-			if (!ret)
+-				goto out;
+-			goto skip;
+-		}
+-
+-		/* does current uncompressed file equal what repomd says it should be */
+-		state_tmp = zif_state_get_child (state_loop);
+-		ret = zif_md_file_check (md, TRUE, state_tmp, &error_local);
+-		if (!ret) {
+-			egg_warning ("failed to verify md: %s", error_local->message);
+-			g_clear_error (&error_local);
+-			ret = zif_state_finished (state_tmp, error);
+-			if (!ret)
+-				goto out;
+-		}
+-		if (ret && !force) {
+-			egg_debug ("%s is okay, and we're not forcing", zif_md_type_to_text (i));
+-			ret = zif_state_finished (state_loop, error);
++		} else {
++			/* refresh this md object */
++			state_loop = zif_state_get_child (state_local);
++			ret = zif_store_remote_refresh_md (remote, md, force, state_loop, error);
+ 			if (!ret)
+ 				goto out;
+-			goto skip;
+-		}
+-
+-		/* this section done */
+-		ret = zif_state_done (state_loop, error);
+-		if (!ret)
+-			goto out;
+-
+-		/* download new file */
+-		state_tmp = zif_state_get_child (state_loop);
+-		ret = zif_store_remote_download (remote, filename, remote->priv->directory, state_tmp, &error_local);
+-		if (!ret) {
+-			g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
+-				     "failed to refresh %s (%s): %s", zif_md_type_to_text (i), filename, error_local->message);
+-			g_error_free (error_local);
+-			goto out;
+ 		}
+ 
+ 		/* this section done */
+-		ret = zif_state_done (state_loop, error);
+-		if (!ret)
+-			goto out;
+-
+-		/* decompress */
+-		state_tmp = zif_state_get_child (state_loop);
+-		filename = zif_md_get_filename (md);
+-		ret = zif_store_file_decompress (filename, state_tmp, &error_local);
+-		if (!ret) {
+-			g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
+-				     "failed to decompress %s for %s: %s",
+-				     filename, zif_md_type_to_text (i), error_local->message);
+-			g_error_free (error_local);
+-			goto out;
+-		}
+-skip:
+-		/* this section done */
+ 		ret = zif_state_done (state_local, error);
+ 		if (!ret)
+ 			goto out;
+diff --git a/libzif/zif.pc.in b/libzif/zif.pc.in
+index 56dd846..69d1d7d 100644
+--- a/libzif/zif.pc.in
++++ b/libzif/zif.pc.in
+@@ -7,7 +7,7 @@ Name: zif
+ Description: Zif is a simple library on top of rpm
+ Version: @VERSION@
+ Requires.private: gthread-2.0
+-Requires: glib-2.0, gobject-2.0, sqlite3, libarchive
++Requires: glib-2.0, gobject-2.0, sqlite3, libarchive, rpm, libsoup-2.4
+ Libs: -L${libdir} -lzif
+ Cflags: -I${includedir}/libzif
+ 
diff --git a/zif.spec b/zif.spec
index 1ac7e61..f0d34f5 100644
--- a/zif.spec
+++ b/zif.spec
@@ -1,7 +1,7 @@
 Summary:   Simple wrapper for rpm
 Name:      zif
 Version:   0.1.1
-Release:   2%{?dist}
+Release:   3%{?dist}
 License:   GPLv2+
 URL:       http://github.com/hughsie/zif
 Source0:   http://www.packagekit.org/releases/%{name}-%{version}.tar.gz
@@ -18,6 +18,9 @@ BuildRequires: gtk-doc
 BuildRequires: bzip2-devel
 BuildRequires: zlib-devel
 
+# already upstream
+Patch0:    backport-fixes.patch
+
 %description
 Zif is a simple yum-compatible library that only provides read-only
 access to the rpm database and the Fedora metadata for PackageKit.
@@ -27,12 +30,15 @@ Zif is not designed as a replacement to yum, nor to be used by end users.
 %package devel
 Summary: GLib Libraries and headers for zif
 Requires: %{name} = %{version}-%{release}
+Requires: bzip2-devel
+Requires: zlib-devel
 
 %description devel
 GLib headers and libraries for zif.
 
 %prep
 %setup -q
+%patch0 -p1 -b .backports
 
 %build
 %configure \
@@ -67,6 +73,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libzif*.la
 %{_datadir}/gtk-doc
 
 %changelog
+* Tue Oct 12 2010 Richard Hughes <richard at hughsie.com> 0.1.1-3
+- Backport 2 fixes from git master to fix 
+
 * Tue Oct 05 2010 Parag Nemade <paragn AT fedoraproject.org> 0.1.1-2
 - drop the ldconfig and pkgconfig as a Requires.
 


More information about the scm-commits mailing list