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

Richard Hughes hughsient at kemper.freedesktop.org
Fri May 9 01:19:17 PDT 2008


 backends/opkg/pk-backend-opkg.c   |   14 -
 backends/zypp/pk-backend-zypp.cpp |  357 +++++++++++++++++++++-----------------
 backends/zypp/zypp-utils.cpp      |   75 +++++--
 backends/zypp/zypp-utils.h        |    5 
 configure.ac                      |    2 
 libpackagekit/pk-client.c         |   15 -
 6 files changed, 273 insertions(+), 195 deletions(-)

New commits:
commit 5e4d31c12e236ed697200acb05eb9a81dd1ee4b6
Author: Thomas Wood <thomas at openedhand.com>
Date:   Thu May 8 14:56:52 2008 +0100

    opkg: update to latest opkg api

diff --git a/backends/opkg/pk-backend-opkg.c b/backends/opkg/pk-backend-opkg.c
index fcae794..34193b0 100644
--- a/backends/opkg/pk-backend-opkg.c
+++ b/backends/opkg/pk-backend-opkg.c
@@ -148,13 +148,13 @@ backend_destroy (PkBackend *backend)
 
 
 static void
-pk_opkg_progress_cb (opkg_t *opkg, int percent, void *data)
+pk_opkg_progress_cb (opkg_t *opkg, const opkg_progress_data_t *pdata, void *data)
 {
 	PkBackend *backend = PK_BACKEND (data);
 	if (!backend)
 		return;
 
-	pk_backend_set_percentage (backend, percent);
+	pk_backend_set_percentage (backend, pdata->percentage);
 }
 
 static gboolean
diff --git a/configure.ac b/configure.ac
index 32f85bb..05682b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -535,7 +535,7 @@ if test x$enable_box = xyes; then
 fi
 
 if test x$enable_opkg = xyes; then
-	PKG_CHECK_MODULES(OPKG, libopkg = 0.1)
+	PKG_CHECK_MODULES(OPKG, libopkg = 0.1.2)
 	AC_SUBST(OPKG_CFLAGS)
 	AC_SUBST(OPKG_LIBS)
 fi
commit 3c09b555409004ad8b5131b73b18e5911a62a0eb
Author: Thomas Wood <thomas at openedhand.com>
Date:   Thu May 8 14:56:37 2008 +0100

    opkg: fix broken api change commits

diff --git a/backends/opkg/pk-backend-opkg.c b/backends/opkg/pk-backend-opkg.c
index aa0b89d..fcae794 100644
--- a/backends/opkg/pk-backend-opkg.c
+++ b/backends/opkg/pk-backend-opkg.c
@@ -338,11 +338,11 @@ backend_install_packages_thread (PkBackend *backend)
 {
 	PkPackageId *pi;
 	gint err;
-	gchar *package_ids;
+	const gchar *package_ids;
 
 	package_ids = pk_backend_get_string (backend, "package_ids");
 
-	pi = pk_package_id_new_from_string (package_id);
+	pi = pk_package_id_new_from_string (package_ids);
 
 	err = opkg_install_package (opkg, pi->name, pk_opkg_progress_cb, backend);
 	if (err != 0)
@@ -359,7 +359,7 @@ backend_install_packages (PkBackend *backend, gchar **package_id)
 	pk_backend_no_percentage_updates (backend);
 	pk_backend_set_status (backend, PK_STATUS_ENUM_INSTALL);
 
-	pk_backend_set_string (backend, "pkid", package_id);
+	pk_backend_set_string (backend, "pkid", package_id[0]);
 
 	pk_backend_thread_create (backend, backend_install_packages_thread);
 }
@@ -376,7 +376,7 @@ backend_remove_packages_thread (PkBackend *backend)
 
 	data = pk_backend_get_pointer (backend, "remove-params");
 
-	package_ids = (gchar*) data[0];
+	package_ids = (gchar**) data[0];
 	allow_deps = GPOINTER_TO_INT (data[1]);
 	autoremove = GPOINTER_TO_INT (data[2]);
 	g_free (data);
@@ -398,7 +398,7 @@ backend_remove_packages_thread (PkBackend *backend)
 }
 
 static void
-backend_remove_packages (PkBackend *backend, gchar *package_ids, gboolean allow_deps, gboolean autoremove)
+backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove)
 {
 	gpointer *params;
 
commit f4e3f39302737fd7285d396a9773d463d631514e
Merge: 4cf71fc... cff5abb...
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu May 8 11:39:49 2008 +0100

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

commit 4cf71fc4ff370e4b381c419adfa1c8b88fbe1c4c
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu May 8 11:36:10 2008 +0100

    correct the gtk-doc markup so the ::details signal is descibed properly. Found by thos, many thanks.

diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 2653157..dd2387b 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -544,13 +544,13 @@ pk_client_update_detail_cb (DBusGProxy  *proxy,
  */
 static void
 pk_client_details_cb (DBusGProxy  *proxy,
-			  const gchar *package_id,
-			  const gchar *license,
-			  const gchar *group_text,
-			  const gchar *description,
-			  const gchar *url,
-			  guint64      size,
-			  PkClient    *client)
+		      const gchar *package_id,
+		      const gchar *license,
+		      const gchar *group_text,
+		      const gchar *description,
+		      const gchar *url,
+		      guint64      size,
+		      PkClient    *client)
 {
 	PkGroupEnum group;
 	g_return_if_fail (PK_IS_CLIENT (client));
@@ -3261,6 +3261,7 @@ pk_client_class_init (PkClientClass *klass)
 	 * PkClient::details:
 	 * @client: the #PkClient instance that emitted the signal
 	 * @package_id: the package_id of the package
+	 * @license: the licence of the package, e.g. "GPLv2+"
 	 * @group: the #PkGroupEnum of the package, e.g. PK_GROUP_ENUM_EDUCATION
 	 * @description: the description of the package
 	 * @url: the upstream URL of the package
commit cff5abba4bd008ea4212fb68f98f37e23c94e724
Author: Stefan Haas <shaas at suse.de>
Date:   Thu May 8 11:02:13 2008 +0200

    do not finish a backend twice

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index fd9e07b..bea45e0 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -636,11 +636,7 @@ backend_get_updates_thread (PkBackend *backend)
 	pk_backend_set_percentage (backend, 0);
 
 	// refresh the repos before checking for updates
-	pk_backend_set_bool (backend, "force", FALSE);
-	if (!backend_refresh_cache_thread (backend)) {
-		pk_backend_finished (backend);
-		return FALSE;
-	}
+	backend_refresh_cache (backend, FALSE);
 
 	zypp::ResPool pool = zypp_build_pool (TRUE);
 	pk_backend_set_percentage (backend, 40);
commit 4894d72872bdead670a20f7662345ae7c7aacc59
Author: Stefan Haas <shaas at suse.de>
Date:   Thu May 8 10:28:47 2008 +0200

    changed backend to handle package arrays

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 55f9548..fd9e07b 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -701,16 +701,7 @@ backend_install_files_thread (PkBackend *backend)
 {
 	gchar **full_paths;
 
-	// check if file is really a rpm
 	full_paths = pk_backend_get_strv (backend, "full_paths");
-	zypp::Pathname rpmPath (full_paths[0]);
-	zypp::target::rpm::RpmHeader::constPtr rpmHeader = zypp::target::rpm::RpmHeader::readPackage (rpmPath, zypp::target::rpm::RpmHeader::NOSIGNATURE);
-
-	if (rpmHeader == NULL) {
-		pk_backend_error_code (backend, PK_ERROR_ENUM_LOCAL_INSTALL_FAILED, "%s is not valid rpm-File", full_paths[0]);
-		pk_backend_finished (backend);
-		return FALSE;
-	}
 
 	// create a temporary directory
 	zypp::filesystem::TmpDir tmpDir;
@@ -720,16 +711,28 @@ backend_install_files_thread (PkBackend *backend)
 		return FALSE;
 	}
 
-	// copy the rpm into tmpdir
+	for (guint i = 0; i < g_strv_length (full_paths); i++) {
 
-	std::string tempDest = tmpDir.path ().asString () + "/" + rpmHeader->tag_name () + ".rpm";
-	if (zypp::filesystem::copy (full_paths[0], tempDest) != 0) {
-		pk_backend_error_code (backend, PK_ERROR_ENUM_LOCAL_INSTALL_FAILED, "Could not copy the rpm-file into the temp-dir");
-		pk_backend_finished (backend);
-		return FALSE;
-	}
+		// check if file is really a rpm
+		zypp::Pathname rpmPath (full_paths[i]);
+		zypp::target::rpm::RpmHeader::constPtr rpmHeader = zypp::target::rpm::RpmHeader::readPackage (rpmPath, zypp::target::rpm::RpmHeader::NOSIGNATURE);
+
+		if (rpmHeader == NULL) {
+			pk_backend_error_code (backend, PK_ERROR_ENUM_LOCAL_INSTALL_FAILED, "%s is not valid rpm-File", full_paths[i]);
+			pk_backend_finished (backend);
+			return FALSE;
+		}
 
-	// create a plaindir-repo
+		// copy the rpm into tmpdir
+		std::string tempDest = tmpDir.path ().asString () + "/" + rpmHeader->tag_name () + ".rpm";
+		if (zypp::filesystem::copy (full_paths[i], tempDest) != 0) {
+			pk_backend_error_code (backend, PK_ERROR_ENUM_LOCAL_INSTALL_FAILED, "Could not copy the rpm-file into the temp-dir");
+			pk_backend_finished (backend);
+			return FALSE;
+		}
+	}
+	
+	// create a plaindir-repo and cache it
 	zypp::RepoInfo tmpRepo;
 
 	try {
@@ -761,29 +764,37 @@ backend_install_files_thread (PkBackend *backend)
 		return FALSE;
 	}
 
-	// look for the package and try to install it
-	std::vector<zypp::sat::Solvable> *solvables = new std::vector<zypp::sat::Solvable>;
-	solvables = zypp_get_packages_by_name (rpmHeader->tag_name ().c_str (), zypp::ResKind::package, FALSE);
-	zypp::PoolItem *item = NULL;
-	gboolean found = FALSE;
-
-	for (std::vector<zypp::sat::Solvable>::iterator it = solvables->begin (); it != solvables->end (); it ++) {
-	       if (it->repository ().name () == "PK_TMP_DIR") {
-		       item = new zypp::PoolItem(*it);
-		       found = TRUE;
-		       break;
-	       }
-	}
+	for (guint i = 0; i < g_strv_length (full_paths); i++) {
+		
+		zypp::Pathname rpmPath (full_paths[i]);
+		zypp::target::rpm::RpmHeader::constPtr rpmHeader = zypp::target::rpm::RpmHeader::readPackage (rpmPath, zypp::target::rpm::RpmHeader::NOSIGNATURE);
+		
+		// look for the packages and set them to toBeInstalled
+		std::vector<zypp::sat::Solvable> *solvables = new std::vector<zypp::sat::Solvable>;
+		solvables = zypp_get_packages_by_name (rpmHeader->tag_name ().c_str (), zypp::ResKind::package, FALSE);
+		zypp::PoolItem *item = NULL;
+		gboolean found = FALSE;
 
-	if (!found) {
-		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Could not find the rpm-Package in Pool");
-	} else {
-		zypp::ResStatus status = item->status ().setToBeInstalled (zypp::ResStatus::USER);
+		for (std::vector<zypp::sat::Solvable>::iterator it = solvables->begin (); it != solvables->end (); it ++) {
+		       if (it->repository ().name () == "PK_TMP_DIR") {
+			       item = new zypp::PoolItem(*it);
+			       found = TRUE;
+			       break;
+		       }
+		}
+
+		if (!found) {
+			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Could not find the rpm-Package in Pool");
+		} else {
+			zypp::ResStatus status = item->status ().setToBeInstalled (zypp::ResStatus::USER);
+		}
 		if (!zypp_perform_execution (backend, INSTALL, FALSE)) {
 			pk_backend_error_code (backend, PK_ERROR_ENUM_LOCAL_INSTALL_FAILED, "Could not install the rpm-file.");
 		}
 
 		item->statusReset ();
+		delete (solvables);
+		delete (item);
 	}
 
 	//remove tmp-dir and the tmp-repo
@@ -794,8 +805,6 @@ backend_install_files_thread (PkBackend *backend)
 		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() );
 	}
 
-	delete (solvables);
-	delete (item);
 	pk_backend_finished (backend);
 	return TRUE;
 }
@@ -958,73 +967,82 @@ backend_install_packages_thread (PkBackend *backend)
 
 	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
 	pk_backend_set_percentage (backend, 0);
-
-	package_ids = pk_backend_get_strv (backend, "package_id");
-	PkPackageId *pi = pk_package_id_new_from_string (package_ids[0]);
-	if (pi == NULL) {
-		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
-		pk_backend_finished (backend);
-		return FALSE;
-	}
-
+	
 	zypp::ZYpp::Ptr zypp;
 	zypp = get_zypp ();
 
+	package_ids = pk_backend_get_strv (backend, "package_ids");
+	
 	try
 	{
 		zypp::ResPool pool = zypp_build_pool (TRUE);
 		pk_backend_set_percentage (backend, 10);
 		gboolean hit = false;
+		std::vector<zypp::PoolItem> *items = new std::vector<zypp::PoolItem> ();
 
-		// Iterate over the selectables and mark the one with the right name
-		zypp::ui::Selectable::Ptr selectable;
-		for (zypp::ResPoolProxy::const_iterator it = zypp->poolProxy().byKindBegin <zypp::Package>();
-				it != zypp->poolProxy().byKindEnd <zypp::Package>(); it++) {
-			if (strcmp ((*it)->name ().c_str (), pi->name) == 0) {
-				selectable = *it;
-				break;
+
+		for (guint i = 0; i < g_strv_length (package_ids); i++) {
+
+			PkPackageId *pi = pk_package_id_new_from_string (package_ids[i]);
+			if (pi == NULL) {
+				pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+				pk_backend_finished (backend);
+				return FALSE;
 			}
-		}
 
-		// Choose the PoolItem with the right architecture and version
-		zypp::PoolItem item;
-		for (zypp::ui::Selectable::available_iterator it = selectable->availableBegin ();
-				it != selectable->availableEnd (); it++) {
-			if (strcmp ((*it)->edition ().asString ().c_str (), pi->version) == 0
-					&& strcmp ((*it)->arch ().c_str (), pi->arch) == 0 ) {
-				hit = true;
-				// set status to ToBeInstalled
-				it->status ().setToBeInstalled (zypp::ResStatus::USER);
-				item = *it;
-				break;
+			// Iterate over the selectables and mark the one with the right name
+			zypp::ui::Selectable::Ptr selectable;
+			for (zypp::ResPoolProxy::const_iterator it = zypp->poolProxy().byKindBegin <zypp::Package>();
+					it != zypp->poolProxy().byKindEnd <zypp::Package>(); it++) {
+				if (strcmp ((*it)->name ().c_str (), pi->name) == 0) {
+					selectable = *it;
+					break;
+				}
 			}
-		}
 
-		if (!hit) {
-			pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "Couldn't find the package.");
+			// Choose the PoolItem with the right architecture and version
+			for (zypp::ui::Selectable::available_iterator it = selectable->availableBegin ();
+					it != selectable->availableEnd (); it++) {
+				if (strcmp ((*it)->edition ().asString ().c_str (), pi->version) == 0
+						&& strcmp ((*it)->arch ().c_str (), pi->arch) == 0 ) {
+					hit = true;
+					// set status to ToBeInstalled
+					it->status ().setToBeInstalled (zypp::ResStatus::USER);
+					items->push_back (*it);
+					break;
+				}
+			}
+
+			if (!hit) {
+				pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "Couldn't find the package.");
+				pk_package_id_free (pi);
+				pk_backend_finished (backend);
+				return FALSE;
+			}
+
+			pk_backend_set_percentage (backend, 40);
 			pk_package_id_free (pi);
-			pk_backend_finished (backend);
-			return FALSE;
 		}
 
-		pk_backend_set_percentage (backend, 40);
-
 		if (!zypp_perform_execution (backend, INSTALL, FALSE)) {
+			//reset the status of the marked packages
+			for (std::vector<zypp::PoolItem>::iterator it = items->begin (); it != items->end (); it++) {
+				it->statusReset ();
+			}
+			delete (items);
 			pk_backend_finished (backend);
 			return FALSE;
 		}
+		delete (items);
 
-		item.statusReset ();
 		pk_backend_set_percentage (backend, 100);
 
 	} catch (const zypp::Exception &ex) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str() );
-		pk_package_id_free (pi);
 		pk_backend_finished (backend);
 		return FALSE;
 	}
 
-	pk_package_id_free (pi);
 	pk_backend_finished (backend);
 	return TRUE;
 }
@@ -1064,18 +1082,11 @@ backend_remove_packages_thread (PkBackend *backend)
 {
 	gchar **package_ids;
 	PkPackageId *pi;
+	std::vector<zypp::PoolItem> *items = new std::vector<zypp::PoolItem> ();
 
 	pk_backend_set_status (backend, PK_STATUS_ENUM_REMOVE);
 	pk_backend_set_percentage (backend, 0);
-
-	package_ids = pk_backend_get_strv (backend, "package_ids");
-	pi = pk_package_id_new_from_string (package_ids[0]);
-	if (pi == NULL) {
-		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
-		pk_backend_finished (backend);
-		return FALSE;
-	}
-
+	
 	zypp::Target_Ptr target;
 	zypp::ZYpp::Ptr zypp;
 	zypp = get_zypp ();
@@ -1086,45 +1097,58 @@ backend_remove_packages_thread (PkBackend *backend)
 	target->load ();
 	pk_backend_set_percentage (backend, 10);
 
-	try
-	{
+	package_ids = pk_backend_get_strv (backend, "package_ids");
+	for (guint i = 0; i < g_strv_length (package_ids); i++) {
+		pi = pk_package_id_new_from_string (package_ids[i]);
+		if (pi == NULL) {
+			pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+			pk_backend_finished (backend);
+			return FALSE;
+		}
+
 		// Iterate over the resolvables and mark the ones we want to remove
 		zypp::ResPool pool = zypp::ResPool::instance ();
 		for (zypp::ResPool::byIdent_iterator it = pool.byIdentBegin (zypp::ResKind::package, pi->name);
 				it != pool.byIdentEnd (zypp::ResKind::package, pi->name); it++) {
 			if ((*it)->isSystem ()) {
 				it->status ().setToBeUninstalled (zypp::ResStatus::USER);
+				items->push_back (*it);
 				break;
 			}
 		}
+		pk_package_id_free (pi);
+	}
 
-		pk_backend_set_percentage (backend, 40);
+	pk_backend_set_percentage (backend, 40);
 
+	try
+	{
 		if (!zypp_perform_execution (backend, REMOVE, TRUE)){
+			//reset the status of the marked packages
+			for (std::vector<zypp::PoolItem>::iterator it = items->begin (); it != items->end (); it++) {
+				it->statusReset();
+			}
+			delete (items);
 			pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "Couldn't remove the package");
-
-			pk_package_id_free (pi);
 			pk_backend_finished (backend);
 			return FALSE;
 		}
 
+		delete (items);
 		pk_backend_set_percentage (backend, 100);
 
 	} catch (const zypp::repo::RepoNotFoundException &ex) {
 		// TODO: make sure this dumps out the right sring.
 		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() );
-		pk_package_id_free (pi);
 		pk_backend_finished (backend);
 		return FALSE;
 	} catch (const zypp::Exception &ex) {
 		//pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Error enumerating repositories");
 		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str() );
-		pk_package_id_free (pi);
 		pk_backend_finished (backend);
 		return FALSE;
 	}
 
-	pk_package_id_free (pi);
 	pk_backend_finished (backend);
 	return TRUE;
 }
commit 41e5590c74322940ffc4d8e36d275c80e84774c4
Merge: 583841c... db1c678...
Author: Stefan Haas <shaas at suse.de>
Date:   Thu May 8 09:27:07 2008 +0200

    merged changes

diff --cc backends/zypp/pk-backend-zypp.cpp
index 0e6ede1,ccaccf4..55f9548
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@@ -1041,28 -1020,9 +1041,28 @@@ backend_install_packages (PkBackend *ba
  }
  
  static gboolean
 +backend_install_signature_thread (PkBackend *backend)
 +{
 +	const gchar *key_id = pk_backend_get_string (backend, "key_id");
 +	_signatures[backend]->push_back ((std::string)(key_id));
 +
 +	pk_backend_finished (backend);
 +	return TRUE;
 +}
 +
 +/**
 + * backend_install_signature:
 + */
 +static void
 +backend_install_signature (PkBackend *backend, PkSigTypeEnum type, const gchar *key_id, const gchar *package_id)
 +{
 +	pk_backend_thread_create (backend, backend_install_signature_thread);
 +}
 +
 +static gboolean
- backend_remove_package_thread (PkBackend *backend)
+ backend_remove_packages_thread (PkBackend *backend)
  {
- 	const gchar *package_id;
+ 	gchar **package_ids;
  	PkPackageId *pi;
  
  	pk_backend_set_status (backend, PK_STATUS_ENUM_REMOVE);
@@@ -1130,15 -1090,24 +1130,15 @@@
  }
  
  /**
-  * backend_remove_package:
+  * backend_remove_packages:
   */
  static void
- backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps, gboolean autoremove)
+ backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove)
  {
  	pk_backend_set_uint (backend, "allow_deps", allow_deps == TRUE ? DEPS_ALLOW : DEPS_NO_ALLOW);
- 	pk_backend_thread_create (backend, backend_remove_package_thread);
+ 	pk_backend_thread_create (backend, backend_remove_packages_thread);
  }
  
 -/**
 - * backend_refresh_cache
 - */
 -static void
 -backend_refresh_cache (PkBackend *backend, gboolean force)
 -{
 -	pk_backend_thread_create (backend, backend_refresh_cache_thread);
 -}
 -
  static gboolean
  backend_resolve_thread (PkBackend *backend)
  {
@@@ -1666,11 -1635,11 +1666,11 @@@ extern "C" PK_BACKEND_OPTIONS 
  	backend_get_requires,			/* get_requires */
  	backend_get_update_detail,		/* get_update_detail */
  	backend_get_updates,			/* get_updates */
- 	backend_install_file,			/* install_file */
- 	backend_install_package,		/* install_package */
+ 	backend_install_files,			/* install_files */
+ 	backend_install_packages,		/* install_packages */
 -	NULL,					/* install_signature */
 +	backend_install_signature,		/* install_signature */
  	backend_refresh_cache,			/* refresh_cache */
- 	backend_remove_package,			/* remove_package */
+ 	backend_remove_packages,		/* remove_packages */
  	backend_repo_enable,			/* repo_enable */
  	backend_repo_set_data,			/* repo_set_data */
  	backend_resolve,			/* resolve */
commit 583841c0f4a40a2e415c41aadd184e1cdf6b799f
Merge: 2db16cc... 4af8aff...
Author: Stefan Haas <shaas at suse.de>
Date:   Wed May 7 15:36:25 2008 +0200

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

commit 2db16cc02bef216cf9190eaf3d0d5a14017f0367
Merge: 368659a... 07eb354...
Author: Stefan Haas <shaas at suse.de>
Date:   Wed May 7 10:06:56 2008 +0200

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

commit 368659a70e8694e0e186e6548aa33b4a35e8bdf9
Author: Stefan Haas <shaas at suse.de>
Date:   Tue May 6 12:00:05 2008 +0200

    refresh the repos before checking for updates

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 7cb2a0a..0e6ede1 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -547,57 +547,6 @@ backend_get_details (PkBackend *backend, const gchar *package_id)
 }
 
 static gboolean
-backend_get_updates_thread (PkBackend *backend)
-{
-	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
-	pk_backend_set_percentage (backend, 0);
-
-	zypp::ResPool pool = zypp_build_pool (TRUE);
-	pk_backend_set_percentage (backend, 40);
-
-	// get all Packages and Patches for Update
-	std::set<zypp::PoolItem> *candidates = zypp_get_updates ();
-	std::set<zypp::PoolItem> *candidates2 = zypp_get_patches ();
-
-	candidates->insert (candidates2->begin (), candidates2->end ());
-
-	pk_backend_set_percentage (backend, 80);
-	std::set<zypp::PoolItem>::iterator cb = candidates->begin (), ce = candidates->end (), ci;
-	for (ci = cb; ci != ce; ++ci) {
-		zypp::ResObject::constPtr res = ci->resolvable();
-
-		// Emit the package
-		PkInfoEnum infoEnum = PK_INFO_ENUM_ENHANCEMENT;
-		if (zypp::isKind<zypp::Patch>(res)) {
-			zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>(res);
-			if (patch->category () == "recommended") {
-				infoEnum = PK_INFO_ENUM_IMPORTANT;
-			}else if (patch->category () == "optional") {
-				infoEnum = PK_INFO_ENUM_LOW;
-			}else if (patch->category () == "security") {
-				infoEnum = PK_INFO_ENUM_SECURITY;
-			} else {
-				infoEnum = PK_INFO_ENUM_NORMAL;
-			}
-		}
-
-		gchar *package_id = zypp_build_package_id_from_resolvable (res->satSolvable ());
-		pk_backend_package (backend, infoEnum, package_id, "");
-					// some package descriptions generate markup parse failures
-					// causing the update to show empty package lines, comment for now
-					// res->description ().c_str ());
-		g_free (package_id);
-	}
-
-	delete (candidates);
-	delete (candidates2);
-
- 	pk_backend_set_percentage (backend, 100);
-	pk_backend_finished (backend);
-	return TRUE;
-}
-
-static gboolean
 backend_refresh_cache_thread (PkBackend *backend)
 {
 	//Fixme - we should check the network status and bail if not online
@@ -672,6 +621,73 @@ backend_refresh_cache_thread (PkBackend *backend)
 }
 
 /**
+ * backend_refresh_cache
+ */
+static void
+backend_refresh_cache (PkBackend *backend, gboolean force)
+{
+	pk_backend_thread_create (backend, backend_refresh_cache_thread);
+}
+
+static gboolean
+backend_get_updates_thread (PkBackend *backend)
+{
+	pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+	pk_backend_set_percentage (backend, 0);
+
+	// refresh the repos before checking for updates
+	pk_backend_set_bool (backend, "force", FALSE);
+	if (!backend_refresh_cache_thread (backend)) {
+		pk_backend_finished (backend);
+		return FALSE;
+	}
+
+	zypp::ResPool pool = zypp_build_pool (TRUE);
+	pk_backend_set_percentage (backend, 40);
+
+	// get all Packages and Patches for Update
+	std::set<zypp::PoolItem> *candidates = zypp_get_updates ();
+	std::set<zypp::PoolItem> *candidates2 = zypp_get_patches ();
+
+	candidates->insert (candidates2->begin (), candidates2->end ());
+
+	pk_backend_set_percentage (backend, 80);
+	std::set<zypp::PoolItem>::iterator cb = candidates->begin (), ce = candidates->end (), ci;
+	for (ci = cb; ci != ce; ++ci) {
+		zypp::ResObject::constPtr res = ci->resolvable();
+
+		// Emit the package
+		PkInfoEnum infoEnum = PK_INFO_ENUM_ENHANCEMENT;
+		if (zypp::isKind<zypp::Patch>(res)) {
+			zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>(res);
+			if (patch->category () == "recommended") {
+				infoEnum = PK_INFO_ENUM_IMPORTANT;
+			}else if (patch->category () == "optional") {
+				infoEnum = PK_INFO_ENUM_LOW;
+			}else if (patch->category () == "security") {
+				infoEnum = PK_INFO_ENUM_SECURITY;
+			} else {
+				infoEnum = PK_INFO_ENUM_NORMAL;
+			}
+		}
+
+		gchar *package_id = zypp_build_package_id_from_resolvable (res->satSolvable ());
+		pk_backend_package (backend, infoEnum, package_id, "");
+					// some package descriptions generate markup parse failures
+					// causing the update to show empty package lines, comment for now
+					// res->description ().c_str ());
+		g_free (package_id);
+	}
+
+	delete (candidates);
+	delete (candidates2);
+
+ 	pk_backend_set_percentage (backend, 100);
+	pk_backend_finished (backend);
+	return TRUE;
+}
+
+/**
  * backend_get_updates
  */
 static void
@@ -1123,15 +1139,6 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
 	pk_backend_thread_create (backend, backend_remove_package_thread);
 }
 
-/**
- * backend_refresh_cache
- */
-static void
-backend_refresh_cache (PkBackend *backend, gboolean force)
-{
-	pk_backend_thread_create (backend, backend_refresh_cache_thread);
-}
-
 static gboolean
 backend_resolve_thread (PkBackend *backend)
 {
@@ -1652,7 +1659,7 @@ extern "C" PK_BACKEND_OPTIONS (
 	backend_get_filters,			/* get_filters */
 	NULL,					/* cancel */
 	backend_get_depends,			/* get_depends */
-	backend_get_details,		/* get_details */
+	backend_get_details,			/* get_details */
 	backend_get_files,			/* get_files */
 	backend_get_packages,			/* get_packages */
 	backend_get_repo_list,			/* get_repo_list */
commit 29cdcd85b9009329ce6cbc81730e96eb86342dcc
Merge: 5c2db0a... 2258c1f...
Author: Stefan Haas <shaas at suse.de>
Date:   Tue May 6 10:13:32 2008 +0200

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

commit 5c2db0aa6b083d8735590d1faea4d8921d02dbf0
Merge: fcc1922... a6ecb62...
Author: Stefan Haas <shaas at suse.de>
Date:   Mon May 5 09:52:05 2008 +0200

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

commit fcc1922a55c926f52ade380fdd6ea0a5094456c1
Merge: 673224d... 91fc7d5...
Author: Stefan Haas <shaas at suse.de>
Date:   Fri May 2 09:55:26 2008 +0200

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

commit 673224d1bfcd469af61a893baaa9f57def8f0d98
Merge: 5473900... 23b8d3c...
Author: Stefan Haas <shaas at suse.de>
Date:   Wed Apr 30 17:09:58 2008 +0200

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

commit 54739004fe1ec3716e8e19653c1c3a97c6e6c018
Merge: 822dea3... 19dc110...
Author: Stefan Haas <shaas at suse.de>
Date:   Wed Apr 30 16:02:54 2008 +0200

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

commit 822dea3c552dae45aee9b02a41c0be90b7ffcccf
Author: Stefan Haas <shaas at suse.de>
Date:   Wed Apr 30 15:43:38 2008 +0200

    changed gpg-handling

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 9e930a3..ba3fc4e 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -80,6 +80,7 @@ enum DepsBehavior {
  * each zypp backend that is created.
  */
 static std::map<PkBackend *, EventDirector *> _eventDirectors;
+std::map<PkBackend *, std::vector<std::string> *> _signatures;
 
 /**
  * backend_initialize:
@@ -92,6 +93,8 @@ backend_initialize (PkBackend *backend)
 	pk_debug ("zypp_backend_initialize");
 	EventDirector *eventDirector = new EventDirector (backend);
 	_eventDirectors [backend] = eventDirector;
+	std::vector<std::string> *signature = new std::vector<std::string> ();
+	_signatures [backend] = signature;
 }
 
 /**
@@ -107,6 +110,8 @@ backend_destroy (PkBackend *backend)
 		delete (eventDirector);
 		_eventDirectors.erase (backend);
 	}
+
+	delete (_signatures[backend]);
 }
 
 /**
@@ -1020,6 +1025,25 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 }
 
 static gboolean
+backend_install_signature_thread (PkBackend *backend)
+{
+	const gchar *key_id = pk_backend_get_string (backend, "key_id");
+	_signatures[backend]->push_back ((std::string)(key_id));
+
+	pk_backend_finished (backend);
+	return TRUE;
+}
+
+/**
+ * backend_install_signature:
+ */
+static void
+backend_install_signature (PkBackend *backend, PkSigTypeEnum type, const gchar *key_id, const gchar *package_id)
+{
+	pk_backend_thread_create (backend, backend_install_signature_thread);
+}
+
+static gboolean
 backend_remove_package_thread (PkBackend *backend)
 {
 	const gchar *package_id;
@@ -1636,7 +1660,7 @@ extern "C" PK_BACKEND_OPTIONS (
 	backend_get_updates,			/* get_updates */
 	backend_install_file,			/* install_file */
 	backend_install_package,		/* install_package */
-	NULL,					/* install_signature */
+	backend_install_signature,		/* install_signature */
 	backend_refresh_cache,			/* refresh_cache */
 	backend_remove_package,			/* remove_package */
 	backend_repo_enable,			/* repo_enable */
diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index bd4ba55..96fcca2 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -356,15 +356,22 @@ zypp_build_package_id_from_resolvable (zypp::sat::Solvable resolvable)
 gboolean
 zypp_signature_required (PkBackend *backend, const zypp::PublicKey &key)
 {
-        gboolean ok = pk_backend_repo_signature_required (backend,
-                        "dummy;0.0.1;i386;data",
-                        "TODO: Repo-Name",
-                        key.path ().c_str (),
-                        key.id ().c_str (),
-                        key.id ().c_str (),
-                        key.fingerprint ().c_str (),
-                        key.created ().asString ().c_str (),
-                        PK_SIGTYPE_ENUM_GPG);
+	gboolean ok = FALSE;
+
+	if (std::find (_signatures[backend]->begin (), _signatures[backend]->end (), key.id ()) == _signatures[backend]->end ()) {
+        	pk_backend_repo_signature_required (backend,
+				"dummy;0.0.1;i386;data",
+	                        "TODO: Repo-Name",
+        	                key.path ().c_str (),
+                	        key.id ().c_str (),
+                        	key.id ().c_str (),
+	                        key.fingerprint ().c_str (),
+        	                key.created ().asString ().c_str (),
+                	        PK_SIGTYPE_ENUM_GPG);
+		pk_backend_error_code (backend, PK_ERROR_ENUM_GPG_FAILURE, "Repo signature verification failed");
+	}else{
+		ok = TRUE;
+	}
 
         return ok;
 }
@@ -372,15 +379,22 @@ zypp_signature_required (PkBackend *backend, const zypp::PublicKey &key)
 gboolean
 zypp_signature_required (PkBackend *backend, const std::string &file, const std::string &id)
 {
-        gboolean ok = pk_backend_repo_signature_required (backend,
-                        "dummy;0.0.1;i386;data",
-                        "TODO: Repo-Name",
-                        file.c_str (),
-                        id.c_str (),
-                        id.c_str (),
-                        "UNKNOWN",
-                        "UNKNOWN",
-                        PK_SIGTYPE_ENUM_GPG);
+        gboolean ok = FALSE;
+	
+	if (std::find (_signatures[backend]->begin (), _signatures[backend]->end (), id) == _signatures[backend]->end ()) {
+		pk_backend_repo_signature_required (backend,
+				"dummy;0.0.1;i386;data",
+	                        "TODO: Repo-Name",
+        	                file.c_str (),
+                	        id.c_str (),
+                        	id.c_str (),
+	                        "UNKNOWN",
+        	                "UNKNOWN",
+                	        PK_SIGTYPE_ENUM_GPG);
+		pk_backend_error_code (backend, PK_ERROR_ENUM_GPG_FAILURE, "Repo signature verification failed");
+	}else{
+		ok = TRUE;
+	}
 
         return ok;
 }
@@ -388,15 +402,22 @@ zypp_signature_required (PkBackend *backend, const std::string &file, const std:
 gboolean
 zypp_signature_required (PkBackend *backend, const std::string &file)
 {
-        gboolean ok = pk_backend_repo_signature_required (backend,
-                        "dummy;0.0.1;i386;data",
-                        "TODO: Repo-Name",
-                        file.c_str (),
-                        "UNKNOWN",
-                        "UNKNOWN",
-                        "UNKNOWN",
-                        "UNKNOWN",
-                        PK_SIGTYPE_ENUM_GPG);
+	gboolean ok = FALSE;
+
+	if (std::find (_signatures[backend]->begin (), _signatures[backend]->end (), file) == _signatures[backend]->end ()) {
+        	pk_backend_repo_signature_required (backend,
+				"dummy;0.0.1;i386;data",
+	                        "TODO: Repo-Name",
+        	                file.c_str (),
+	                        "UNKNOWN",
+        	                file.c_str (),
+                	        "UNKNOWN",
+                        	"UNKNOWN",
+	                        PK_SIGTYPE_ENUM_GPG);
+		pk_backend_error_code (backend, PK_ERROR_ENUM_GPG_FAILURE, "Repo signature verification failed");
+	}else{
+		ok = TRUE;
+	}
 
         return ok;
 }
diff --git a/backends/zypp/zypp-utils.h b/backends/zypp/zypp-utils.h
index a4765ad..5fed7dc 100644
--- a/backends/zypp/zypp-utils.h
+++ b/backends/zypp/zypp-utils.h
@@ -33,6 +33,11 @@ typedef enum {
         UPDATE
 } PerformType;
 
+/**
+  * A map to store the signatures which were accepted for each backend
+  */
+extern std::map<PkBackend *, std::vector<std::string> *> _signatures;
+
 zypp::ZYpp::Ptr get_zypp ();
 
 gboolean zypp_is_changeable_media (const zypp::Url &url);


More information about the PackageKit-commit mailing list