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

Richard Hughes hughsient at kemper.freedesktop.org
Thu Mar 6 09:34:40 PST 2008


 backends/zypp/pk-backend-zypp.cpp |   30 +++++++++++++++++++-----------
 backends/zypp/zypp-events.h       |   30 ++++++++++++++++++++++++++++++
 backends/zypp/zypp-utils.cpp      |   35 ++++++++++++++++++++++++++++++-----
 backends/zypp/zypp-utils.h        |    5 +++++
 libpackagekit/pk-common.c         |    4 ++++
 5 files changed, 88 insertions(+), 16 deletions(-)

New commits:
commit 2caa9dd666f7735c5fa9ee1edc5f0bd52a82417f
Author: Stefan Haas <shaas at suse.de>
Date:   Thu Mar 6 16:41:01 2008 +0100

    bugfix for get requires and added test-callback for RepoSignatureRequired

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 1406dde..62e2bbe 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -1453,12 +1453,12 @@ backend_get_requires_thread (PkBackendThread *thread, gpointer data) {
                 for(std::list<zypp::ResolverProblem_Ptr>::iterator it = problems.begin (); it != problems.end (); it++){
                    pk_warning("Solver problem (This should never happen): '%s'", (*it)->description ().c_str ());
                 }
-		/*pk_backend_error_code (backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "Resolution failed");
+		pk_backend_error_code (backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "Resolution failed");
 		pk_package_id_free (pi);
 		g_free (d->package_id);
 		g_free (d);
 		pk_backend_finished (backend);
-		return FALSE;*/
+		return FALSE;
 	}
 
 	pk_backend_set_percentage (backend, 60);
@@ -1480,6 +1480,10 @@ backend_get_requires_thread (PkBackendThread *thread, gpointer data) {
                 }
         }
         
+        // undo the status-change of the package and disable forceResolve
+        package.statusReset ();
+        solver.setForceResolve (false);
+
         pk_package_id_free (pi);
 	g_free (d->package_id);
 	g_free (d);
diff --git a/backends/zypp/zypp-events.h b/backends/zypp/zypp-events.h
index e787e98..1af803c 100644
--- a/backends/zypp/zypp-events.h
+++ b/backends/zypp/zypp-events.h
@@ -257,6 +257,36 @@ struct DownloadProgressReportReceiver : public zypp::callback::ReceiveReport<zyp
 	}
 };
 
+struct KeyRingReceiver : public zypp::callback::ReceiveReport<zypp::KeyRingReport>, ZyppBackendReceiver
+{
+        virtual bool askUserToAcceptUnsignedFile (const std::string &file)
+        {
+                pk_debug("_______askUserToAcceptUnsignedFile_______");
+                return true;
+        }
+
+        virtual bool askUserToAcceptUnknownKey (const std::string &file, const std::string &id)
+        {
+                pk_debug("_______askUserToAcceptUnknownKey_______");
+                return true;
+        }
+
+        virtual bool askUserToTrustKey (const zypp::PublicKey &key)
+        {
+                gboolean ok = zypp_signature_required(_backend, key);
+
+                return ok;
+        }
+
+        virtual bool askUserToImportKey (const zypp::PublicKey &key)
+        {
+                gboolean ok = zypp_signature_required(_backend, key);
+
+                return ok;
+        }
+
+};
+
 }; // namespace ZyppBackend
 
 class EventDirector
diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index 3c56ceb..5af84b3 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -119,9 +119,13 @@ zypp_build_local_pool ()
                         pool.reposErase(it->name ());
         }
 
-        //Add local resolvables
         zypp::ZYpp::Ptr zypp = get_zypp ();
-        zypp->target ()->load ();
+        if (zypp::sat::Pool::instance().reposFind( zypp::sat::Pool::systemRepoName() ) == zypp::Repository::noRepository)
+        {
+                // Add local resolvables
+                zypp::Target_Ptr target = zypp->target ();
+                target->load ();
+        }
 
         return zypp->pool ();
 
@@ -326,6 +330,21 @@ zypp_build_package_id_from_resolvable (zypp::sat::Solvable resolvable)
 	return package_id;
 }
 
+gboolean
+zypp_signature_required (PkBackend *backend, const zypp::PublicKey &key)
+{
+        gboolean ok = pk_backend_repo_signature_required (backend,
+                        "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);
+
+        return ok;
+}
+
 void
 zypp_emit_packages_in_list (PkBackend *backend, std::vector<zypp::sat::Solvable> *v)
 {
diff --git a/backends/zypp/zypp-utils.h b/backends/zypp/zypp-utils.h
index da412ff..02fa813 100644
--- a/backends/zypp/zypp-utils.h
+++ b/backends/zypp/zypp-utils.h
@@ -80,6 +80,11 @@ zypp::sat::Solvable zypp_get_package_by_id (const gchar *package_id);
  */
 gchar * zypp_build_package_id_from_resolvable (zypp::sat::Solvable resolvable);
 
+/**
+  * Ask the User if it is OK to import an GPG-Key for a repo
+  */
+gboolean zypp_signature_required (PkBackend *backend, const zypp::PublicKey &key);
+
 void zypp_emit_packages_in_list (PkBackend *backend, std::vector<zypp::sat::Solvable> *v);
 #endif // _ZYPP_UTILS_H_
 
commit 0c7448543f30d3a0afc412dd2164280952593f39
Merge: 20de882... 76d3d37...
Author: Stefan Haas <shaas at suse.de>
Date:   Thu Mar 6 15:13:06 2008 +0100

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

commit 20de88203c734c038dd48c5ed32511826ca17902
Author: Stefan Haas <shaas at suse.de>
Date:   Thu Mar 6 15:12:36 2008 +0100

    get requires is working now properly

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index fb02030..1406dde 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -48,6 +48,7 @@
 #include <zypp/target/rpm/RpmDb.h>
 #include <zypp/target/rpm/RpmHeader.h>
 #include <zypp/target/rpm/RpmException.h>
+#include <zypp/base/LogControl.h>
 
 #include <zypp/sat/Solvable.h>
 
@@ -119,6 +120,7 @@ static PkBackendThread *thread;
 static void
 backend_initialize (PkBackend *backend)
 {
+        //zypp::base::LogControl::instance ().logfile("/tmp/zypplog");
 	g_return_if_fail (backend != NULL);
 	pk_debug ("zypp_backend_initialize");
 	EventDirector *eventDirector = new EventDirector (backend);
@@ -382,7 +384,6 @@ backend_get_description_thread (PkBackendThread *thread, gpointer data)
 	for (std::vector<zypp::sat::Solvable>::iterator it = v->begin ();
 			it != v->end (); it++) {
 		const char *version = it->edition ().asString ().c_str ();
-                //fprintf (stderr, "\n\n *** comparing versions '%s' == '%s'", pi->version, version);
 		if (strcmp (pi->version, version) == 0) {
 			package = *it;
 			break;
@@ -444,7 +445,6 @@ backend_get_description_thread (PkBackendThread *thread, gpointer data)
                 return FALSE;
         }
 
-                        fprintf(stderr,"\n____________450________________________________\n");
 	pk_package_id_free (pi);
 	g_free (d->package_id);
 	g_free (d);
@@ -729,6 +729,7 @@ backend_refresh_cache_thread (PkBackendThread *thread, gpointer data)
 	int i = 1;
 	int num_of_repos = repos.size ();
 	int percentage_increment = 100 / num_of_repos;
+
 	for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++, i++) {
 		zypp::RepoInfo repo (*it);
 
@@ -1422,8 +1423,10 @@ backend_get_requires_thread (PkBackendThread *thread, gpointer data) {
         gboolean found = FALSE;
         for (zypp::ResPool::byIdent_iterator it = pool.byIdentBegin (zypp::ResKind::package, pi->name);
                         it != pool.byIdentEnd (zypp::ResKind::package, pi->name); it++) {
-                package = (*it);
-                found = TRUE;
+                if (it ->status ().isInstalled ()){
+                        package = (*it);
+                        found = TRUE;
+                }
         }
 
 	if (found == FALSE) {
@@ -1435,7 +1438,7 @@ backend_get_requires_thread (PkBackendThread *thread, gpointer data) {
 		return FALSE;
 	}
 
-        // set Package as to be installed
+        // set Package as to be uninstalled
         package.status ().setToBeUninstalled (zypp::ResStatus::USER);
 
 	pk_backend_set_percentage (backend, 40);
@@ -1443,26 +1446,27 @@ backend_get_requires_thread (PkBackendThread *thread, gpointer data) {
         // solver run
         zypp::Resolver solver(pool);
         
-        // DEBUG https://bugzilla.novell.com/show_bug.cgi?id=363545
-        if (solver.forceResolve () == FALSE) {
+        solver.setForceResolve (true);
+
+        if (solver.resolvePool () == FALSE) {
                 std::list<zypp::ResolverProblem_Ptr> problems = solver.problems ();
                 for(std::list<zypp::ResolverProblem_Ptr>::iterator it = problems.begin (); it != problems.end (); it++){
-                   pk_warning("Solver problem: '%s'", (*it)->description ().c_str ());
+                   pk_warning("Solver problem (This should never happen): '%s'", (*it)->description ().c_str ());
                 }
-		pk_backend_error_code (backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "Resolution failed");
+		/*pk_backend_error_code (backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "Resolution failed");
 		pk_package_id_free (pi);
 		g_free (d->package_id);
 		g_free (d);
 		pk_backend_finished (backend);
-		return FALSE;
+		return FALSE;*/
 	}
 
 	pk_backend_set_percentage (backend, 60);
 
         // look for packages which would be uninstalled
-        for (zypp::ResPool::byIdent_iterator it = pool.byIdentBegin (zypp::ResKind::package, pi->name);
-                        it != pool.byIdentEnd (zypp::ResKind::package, pi->name); it++) {
-                if (it->status () == zypp::ResStatus::toBeUninstalled || it->status () == zypp::ResStatus::toBeUninstalledSoft) {
+        for (zypp::ResPool::byKind_iterator it = pool.byKindBegin (zypp::ResKind::package);
+                        it != pool.byKindEnd (zypp::ResKind::package); it++) {
+                if (it->status ().isToBeUninstalled ()) {
                         gchar *package_id;
                         package_id = pk_package_id_build ( it->resolvable ()->name ().c_str(),
                                                            it->resolvable ()->edition ().asString ().c_str(),
@@ -1475,7 +1479,7 @@ backend_get_requires_thread (PkBackendThread *thread, gpointer data) {
                         g_free (package_id);
                 }
         }
-
+        
         pk_package_id_free (pi);
 	g_free (d->package_id);
 	g_free (d);
diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index 13f485e..3c56ceb 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -89,15 +89,21 @@ zypp_build_pool (gboolean include_local)
 			// skip disabled repos
 			if (repo.enabled () == false)
 				continue;
-                        
+                        // skip not cached repos
+                        if (manager.isCached (repo) == false) {
+                                pk_warning ("%s is not cached! Do a refresh", repo.alias ().c_str ());
+                                continue;
+                        }
                         //FIXME see above, skip already cached repos
                         if (zypp::sat::Pool::instance().reposFind( repo.alias ()) == zypp::Repository::noRepository)
                                 manager.loadFromCache (repo);
 		}
 	} catch (const zypp::repo::RepoNoAliasException &ex) {
-                pk_warning ("Can't figure an alias to look in cache");
+                pk_error ("Can't figure an alias to look in cache");
+        } catch (const zypp::repo::RepoNotCachedException &ex) {
+                pk_error ("The repo has to be cached at first: %s", ex.asUserString ().c_str ());
 	} catch (const zypp::Exception &ex) {
-                pk_warning ("TODO: Handle exceptions: %s", ex.asUserString ().c_str ());
+                pk_error ("TODO: Handle exceptions: %s", ex.asUserString ().c_str ());
 	}
 
 	return zypp->pool ();
commit 76d3d37fd0771a50e23047bc6f87e83b9e32f076
Author: Thomas Wood <thomas at openedhand.com>
Date:   Thu Mar 6 13:00:37 2008 +0000

    protect pk_strsafe against NULL text

diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index 8236449..d0b33ce 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -188,6 +188,10 @@ pk_strsafe (const gchar *text)
 	gchar *text_safe;
 	const gchar *delimiters;
 
+	if (text == NULL) {
+		return NULL;
+	}
+
 	/* rip out any insane characters */
 	delimiters = "\\\f\n\r\t\"'";
 	text_safe = g_strdup (text);



More information about the PackageKit mailing list