[meego-commits] 14735: Changes to devel:packagemanagement/PackageKit
Zhang Qiang
no_reply at build.meego.com
Mon Mar 14 06:48:09 UTC 2011
Hi,
I have made the following changes to PackageKit in project devel:packagemanagement. Please review and accept ASAP.
Thank You,
Zhang Qiang
[This message was auto-generated]
---
Request #14735:
submit: home:xiaoqiang:branches:devel:packagemanagement/PackageKit(r31)(cleanup) -> devel:packagemanagement/PackageKit
Message:
a
State: new 2011-03-13T23:47:55 xiaoqiang
Comment: None
changes files:
--------------
--- PackageKit.changes
+++ PackageKit.changes
@@ -1,0 +2,9 @@
+- Add 0021-zypp-support-cancel.patch to support Cancel, which
+ help to implement FEA#9356.
+- Add 0022-debuginfo-install.patch to enable pk-debuginfo-install
+ can work well. fix BMC#14237.
+- Add 0023-Add-repo-validation-check.patch to check repo file before
+ using it, which can prevent crash issue when calling modifyrepo.
+ fix BMC#13769.
+
+* Fri Feb 18 2011 Zhang Qiang<qiang.z.zhang at intel.com> - 0.6.11
new:
----
0021-zypp-support-cancel.patch
0022-debuginfo-install.patch
0023-Add-repo-validation-check.patch
spec files:
-----------
--- PackageKit.spec
+++ PackageKit.spec
@@ -33,6 +33,9 @@
Patch18: 0018-set-autoreomove-while-uninstall.patch
Patch19: 0019-remove-online-check-in-refresh.patch
Patch20: 0020-fix-connman-Dbus-Name.patch
+Patch21: 0021-zypp-support-cancel.patch
+Patch22: 0022-debuginfo-install.patch
+Patch23: 0023-Add-repo-validation-check.patch
Requires: PackageKit-zypp = %{version}-%{release}
Requires: shared-mime-info
@@ -272,6 +275,9 @@
%patch18 -p1
%patch19 -p1
%patch20 -p1
+%patch21 -p1
+%patch22 -p1
+%patch23 -p1
%build
%configure \
other changes:
--------------
++++++ 0021-zypp-support-cancel.patch (new)
--- 0021-zypp-support-cancel.patch
+++ 0021-zypp-support-cancel.patch
+diff -uNr PackageKit-0.6.11/backends/zypp/pk-backend-zypp.cpp PackageKit-0.6.11.new/backends/zypp/pk-backend-zypp.cpp
+--- PackageKit-0.6.11/backends/zypp/pk-backend-zypp.cpp 2011-03-09 14:05:27.253394040 +0800
++++ PackageKit-0.6.11.new/backends/zypp/pk-backend-zypp.cpp 2011-03-09 11:20:30.056518822 +0800
+@@ -24,6 +24,8 @@
+ #include <pk-backend.h>
+ #include <pk-backend-spawn.h>
+ #include <unistd.h>
++#include <sys/types.h>
++#include <sys/wait.h>
+ #include <string>
+ #include <set>
+ #include <glib/gi18n.h>
+@@ -80,6 +82,8 @@
+
+ std::map<PkBackend *, std::vector<std::string> *> _signatures;
+
++pid_t m_child_pid;
++int read_from_child_fd;
+ /**
+ * pk_backend_get_description:
+ */
+@@ -1198,7 +1202,7 @@
+ pk_backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
+ {
+ // For now, don't let the user cancel the install once it's started
+- pk_backend_set_allow_cancel (backend, FALSE);
++ pk_backend_set_allow_cancel (backend, TRUE);
+ pk_backend_thread_create (backend, backend_install_packages_thread);
+ }
+
+@@ -2070,12 +2074,23 @@
+ return g_strdup ("application/x-rpm");
+ }
+
++/**
++ * pk_backend_cancel:
++ */
++void
++pk_backend_cancel (PkBackend *backend)
++{
++ if (m_child_pid > 0) {
++ kill (m_child_pid, SIGINT);
++ }
++}
++
+ static gboolean
+ backend_download_packages_thread (PkBackend *backend)
+ {
+ gchar **package_ids;
+ gulong size = 0;
+-
++
+ if (!zypp_refresh_cache (backend, FALSE)) {
+ pk_backend_finished (backend);
+ return FALSE;
+@@ -2091,65 +2106,115 @@
+ package_ids = pk_backend_get_strv (backend, "package_ids");
+ if (!pk_package_ids_check (package_ids)) {
+ return zypp_backend_finished_error (
+- backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
++ backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+ }
+-
+- try
+- {
+- zypp::ResPool pool = zypp_build_pool (backend, FALSE);
+- zypp::PoolItem item;
+
+- pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD);
+- for (guint i = 0; package_ids[i]; i++) {
+- gchar **id_parts = pk_package_id_split (package_ids[i]);
+- std::string name = id_parts[PK_PACKAGE_ID_NAME];
++ int readFromChildFD[2];
++ int writeToChildFD[2];
+
+- for (zypp::ResPool::byName_iterator it = pool.byNameBegin (name); it != pool.byNameEnd (name); it++) {
+- if (zypp_ver_and_arch_equal (it->satSolvable(), id_parts[PK_PACKAGE_ID_VERSION],
+- id_parts[PK_PACKAGE_ID_ARCH])) {
+- size += it->satSolvable().lookupNumAttribute (zypp::sat::SolvAttr::installsize);
+- size += it->satSolvable().lookupNumAttribute (zypp::sat::SolvAttr::downloadsize);
+- item = *it;
+- break;
++ if (pipe(readFromChildFD) < 0 || pipe(writeToChildFD) < 0) {
++ return NULL;
++ }
++
++ m_child_pid = fork();
++
++ if (m_child_pid == -1) {
++ return NULL;
++ }
++
++ if (m_child_pid == 0) {
++ close(0);
++ if (dup2(writeToChildFD[0], 0) != 0) {
++ close(readFromChildFD[1]);
++ close(writeToChildFD[0]);
++ _exit(1);
++ }
++ close (writeToChildFD[0]);
++
++ close (1);
++ if (dup2(readFromChildFD[1], 1) != 1) {
++ close(readFromChildFD[1]);
++ close(writeToChildFD[0]);
++ _exit(1);
++ }
++ read_from_child_fd = readFromChildFD[1];
++
++ signal(SIGINT,SIG_DFL);
++ int ret = 0;
++
++
++ try
++ {
++ zypp::ResPool pool = zypp_build_pool (backend, FALSE);
++ zypp::PoolItem item;
++
++ pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD);
++ for (guint i = 0; package_ids[i]; i++) {
++ gchar **id_parts = pk_package_id_split (package_ids[i]);
++ std::string name = id_parts[PK_PACKAGE_ID_NAME];
++
++ for (zypp::ResPool::byName_iterator it = pool.byNameBegin (name); it != pool.byNameEnd (name); it++) {
++ if (zypp_ver_and_arch_equal (it->satSolvable(), id_parts[PK_PACKAGE_ID_VERSION],
++ id_parts[PK_PACKAGE_ID_ARCH])) {
++ size += it->satSolvable().lookupNumAttribute (zypp::sat::SolvAttr::installsize);
++ size += it->satSolvable().lookupNumAttribute (zypp::sat::SolvAttr::downloadsize);
++ item = *it;
++ break;
++ }
++ }
++
++ struct statfs stat;
++ statfs(pk_backend_get_root (backend), &stat);
++ if (size > stat.f_bavail * 4) {
++ g_strfreev (id_parts);
++ pk_backend_error_code (backend, PK_ERROR_ENUM_NO_SPACE_ON_DEVICE,
++ "Insufficient space in download directory '%s'.", pk_backend_get_root (backend));
++ pk_backend_finished (backend);
++ return FALSE;
+ }
+- }
+
+- struct statfs stat;
+- statfs(pk_backend_get_root (backend), &stat);
+- if (size > stat.f_bavail * 4) {
++ zypp::sat::Solvable solvable = item.resolvable()->satSolvable();
++ zypp::filesystem::Pathname tmp_file;
++ zypp::repo::RepoMediaAccess access;
++ zypp::repo::DeltaCandidates deltas;
++ if (strcmp (id_parts[PK_PACKAGE_ID_ARCH], "source") == 0) {
++ zypp::SrcPackage::constPtr package = zypp::asKind<zypp::SrcPackage>(item.resolvable());
++ zypp::repo::SrcPackageProvider pkgProvider(access);
++ pkgProvider.provideSrcPackage(package);
++ tmp_file = solvable.repository().info().packagesPath()+ package->location().filename();
++
++ } else {
++ zypp::Package::constPtr package = zypp::asKind<zypp::Package>(item.resolvable());
++ zypp::repo::PackageProvider pkgProvider(access, package, deltas);
++ pkgProvider.providePackage();
++ tmp_file = solvable.repository().info().packagesPath()+ package->location().filename();
++ }
++ pk_backend_files (backend, package_ids[i], tmp_file.c_str());
++ zypp_backend_package (backend, PK_INFO_ENUM_DOWNLOADING, solvable, item->summary ().c_str());
++
+ g_strfreev (id_parts);
+- pk_backend_error_code (backend, PK_ERROR_ENUM_NO_SPACE_ON_DEVICE,
+- "Insufficient space in download directory '%s'.", pk_backend_get_root (backend));
+- pk_backend_finished (backend);
+- return FALSE;
+- }
+-
+- zypp::sat::Solvable solvable = item.resolvable()->satSolvable();
+- zypp::filesystem::Pathname tmp_file;
+- zypp::repo::RepoMediaAccess access;
+- zypp::repo::DeltaCandidates deltas;
+- if (strcmp (id_parts[PK_PACKAGE_ID_ARCH], "source") == 0) {
+- zypp::SrcPackage::constPtr package = zypp::asKind<zypp::SrcPackage>(item.resolvable());
+- zypp::repo::SrcPackageProvider pkgProvider(access);
+- pkgProvider.provideSrcPackage(package);
+- tmp_file = solvable.repository().info().packagesPath()+ package->location().filename();
+-
+- } else {
+- zypp::Package::constPtr package = zypp::asKind<zypp::Package>(item.resolvable());
+- zypp::repo::PackageProvider pkgProvider(access, package, deltas);
+- pkgProvider.providePackage();
+- tmp_file = solvable.repository().info().packagesPath()+ package->location().filename();
+ }
+- pk_backend_files (backend, package_ids[i], tmp_file.c_str());
+- zypp_backend_package (backend, PK_INFO_ENUM_DOWNLOADING, solvable, item->summary ().c_str());
+-
+- g_strfreev (id_parts);
++ } catch (const zypp::Exception &ex) {
++ char msg[28];
++ sprintf (msg, "\nTransaction Error:%d:%s\n", PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, ex.asUserString().c_str());
++ write (read_from_child_fd, msg, strlen (msg));
+ }
(412 more lines skipped)
++++++ 0022-debuginfo-install.patch (new)
--- 0022-debuginfo-install.patch
+++ 0022-debuginfo-install.patch
+diff -uNr PackageKit-0.6.11/contrib/debuginfo-install/pk-debuginfo-install.c PackageKit-0.6.11.new/contrib/debuginfo-install/pk-debuginfo-install.c
+--- PackageKit-0.6.11/contrib/debuginfo-install/pk-debuginfo-install.c 2010-10-18 18:45:46.000000000 +0800
++++ PackageKit-0.6.11.new/contrib/debuginfo-install/pk-debuginfo-install.c 2011-03-03 09:48:22.487581627 +0800
+@@ -374,7 +374,7 @@
+
+ /* get depends for them all, not adding dup's */
+ package_ids = pk_ptr_array_to_strv (packages_search);
+- results = pk_client_get_depends (priv->client, PK_FILTER_ENUM_NONE, package_ids, TRUE, NULL, NULL, NULL, &error_local);
++ results = pk_client_get_depends (priv->client, pk_bitfield_value (PK_FILTER_ENUM_NONE), package_ids, TRUE, NULL, NULL, NULL, &error_local);
+ if (results == NULL) {
+ *error = g_error_new (1, 0, "failed to get_depends: %s", error_local->message);
+ g_error_free (error_local);
+@@ -448,7 +448,7 @@
+ gchar *repo_id;
+
+ /* get all repo details */
+- results = pk_client_get_repo_list (priv->client, PK_FILTER_ENUM_NONE, NULL, NULL, NULL, &error_local);
++ results = pk_client_get_repo_list (priv->client, pk_bitfield_value (PK_FILTER_ENUM_NONE), NULL, NULL, NULL, &error_local);
+ if (results == NULL) {
+ *error = g_error_new (1, 0, "failed to get repo list: %s", error_local->message);
+ g_error_free (error_local);
++++++ 0023-Add-repo-validation-check.patch (new)
--- 0023-Add-repo-validation-check.patch
+++ 0023-Add-repo-validation-check.patch
+diff -uNr PackageKit-0.6.11/backends/zypp/pk-backend-zypp.cpp PackageKit-0.6.11.new/backends/zypp/pk-backend-zypp.cpp
+--- PackageKit-0.6.11/backends/zypp/pk-backend-zypp.cpp 2011-03-03 09:42:51.051394187 +0800
++++ PackageKit-0.6.11.new/backends/zypp/pk-backend-zypp.cpp 2011-03-07 18:38:07.223519009 +0800
+@@ -1637,6 +1637,10 @@
+
+ try {
+ repo = manager.getRepositoryInfo (rid);
++ if (!zypp_is_valid_repo (backend, repo)){
++ pk_backend_finished (backend);
++ return;
++ }
+ repo.setEnabled (enabled);
+ manager.modifyRepository (rid, repo);
+ if (!enabled) {
+@@ -1874,6 +1878,13 @@
+
+ try {
+ pk_backend_set_status(backend, PK_STATUS_ENUM_SETUP);
++ if (g_ascii_strcasecmp (parameter, "add") != 0) {
++ repo = manager.getRepositoryInfo (repo_id);
++ if (!zypp_is_valid_repo (backend, repo)){
++ pk_backend_finished (backend);
++ return FALSE;
++ }
++ }
+ // add a new repo
+ if (g_ascii_strcasecmp (parameter, "add") == 0) {
+ repo.setAlias (repo_id);
+@@ -1885,11 +1896,9 @@
+
+ // remove a repo
+ } else if (g_ascii_strcasecmp (parameter, "remove") == 0) {
+- repo = manager.getRepositoryInfo (repo_id);
+ manager.removeRepository (repo);
+ // set autorefresh of a repo true/false
+ } else if (g_ascii_strcasecmp (parameter, "refresh") == 0) {
+- repo = manager.getRepositoryInfo (repo_id);
+
+ if (g_ascii_strcasecmp (value, "true") == 0) {
+ repo.setAutorefresh (TRUE);
+@@ -1902,7 +1911,6 @@
+
+ manager.modifyRepository (repo_id, repo);
+ } else if (g_ascii_strcasecmp (parameter, "keep") == 0) {
+- repo = manager.getRepositoryInfo (repo_id);
+
+ if (g_ascii_strcasecmp (value, "true") == 0) {
+ repo.setKeepPackages (TRUE);
+@@ -1915,15 +1923,12 @@
+
+ manager.modifyRepository (repo_id, repo);
+ } else if (g_ascii_strcasecmp (parameter, "url") == 0) {
+- repo = manager.getRepositoryInfo (repo_id);
+ repo.setBaseUrl (zypp::Url(value));
+ manager.modifyRepository (repo_id, repo);
+ } else if (g_ascii_strcasecmp (parameter, "name") == 0) {
+- repo = manager.getRepositoryInfo (repo_id);
+ repo.setName(value);
+ manager.modifyRepository (repo_id, repo);
+ } else if (g_ascii_strcasecmp (parameter, "prio") == 0) {
+- repo = manager.getRepositoryInfo (repo_id);
+ gint prio = 0;
+ gint length = strlen (value);
+
+diff -uNr PackageKit-0.6.11/backends/zypp/zypp-utils.cpp PackageKit-0.6.11.new/backends/zypp/zypp-utils.cpp
+--- PackageKit-0.6.11/backends/zypp/zypp-utils.cpp 2011-03-03 09:42:51.059456137 +0800
++++ PackageKit-0.6.11.new/backends/zypp/zypp-utils.cpp 2011-03-07 18:32:19.283581591 +0800
+@@ -188,6 +188,23 @@
+ return FALSE;
+ }
+
++gboolean
++zypp_is_valid_repo (PkBackend *backend, zypp::RepoInfo repo)
++{
++
++ if (repo.alias().empty()){
++ pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_CONFIGURATION_ERROR, "Repository has no or invalid repo name defined.\n", repo.alias ().c_str ());
++ return FALSE;
++ }
++
++ if (!repo.url().isValid()){
++ pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_CONFIGURATION_ERROR, "%s: Repository has no or invalid url defined.\n", repo.alias ().c_str ());
++ return FALSE;
++ }
++
++ return TRUE;
++}
++
+ zypp::ResPool
+ zypp_build_pool (PkBackend *backend, gboolean include_local)
+ {
+@@ -518,6 +535,8 @@
+ return TRUE;
+ } catch (const AbortTransactionException &ex) {
+ return FALSE;
++ } catch (const zypp::Exception &e) {
++ return FALSE;
+ }
+ }
+
+@@ -1200,6 +1219,8 @@
+ for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++, i++) {
+ zypp::RepoInfo repo (*it);
+
++ if (!zypp_is_valid_repo (backend, repo))
++ return FALSE;
+ if (pk_backend_get_is_error_set (backend))
+ break;
+
+diff -uNr PackageKit-0.6.11/backends/zypp/zypp-utils.h PackageKit-0.6.11.new/backends/zypp/zypp-utils.h
+--- PackageKit-0.6.11/backends/zypp/zypp-utils.h 2011-03-03 09:42:51.060394111 +0800
++++ PackageKit-0.6.11.new/backends/zypp/zypp-utils.h 2011-03-07 18:14:58.980515752 +0800
+@@ -89,6 +89,7 @@
+
+ gboolean zypp_is_development_repo (PkBackend *backend, zypp::RepoInfo repo);
+
++gboolean zypp_is_valid_repo (PkBackend *backend, zypp::RepoInfo repo);
+ /**
+ * Build and return a ResPool that contains all local resolvables
+ * and ones found in the enabled repositories.
More information about the MeeGo-commits
mailing list