Backport a few more upstream patches

- Add missing locking when accessing sack cache (#1146734)
- Improve parallel kernel installation (#1205649)
This commit is contained in:
Kalev Lember 2015-06-08 14:54:49 +02:00
parent 22c93497ac
commit 5b59122512
4 changed files with 238 additions and 2 deletions

View File

@ -0,0 +1,53 @@
From 7528178aaefb5e827054c32b3a8691c29294bb46 Mon Sep 17 00:00:00 2001
From: Kalev Lember <kalevlember@gmail.com>
Date: Fri, 29 May 2015 17:56:29 +0200
Subject: [PATCH 2/4] hif: Add missing locking when accessing sack cache
Might help with the crash reported at
https://bugzilla.redhat.com/show_bug.cgi?id=1146734
---
backends/hif/pk-backend-hif.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/backends/hif/pk-backend-hif.c b/backends/hif/pk-backend-hif.c
index 5988ab1..48d456a 100644
--- a/backends/hif/pk-backend-hif.c
+++ b/backends/hif/pk-backend-hif.c
@@ -617,19 +617,23 @@ hif_utils_create_sack_for_filters (PkBackendJob *job,
/* do we have anything in the cache */
cache_key = hif_utils_create_cache_key (flags);
- if ((create_flags & HIF_CREATE_SACK_FLAG_USE_CACHE) > 0)
+ if ((create_flags & HIF_CREATE_SACK_FLAG_USE_CACHE) > 0) {
+ g_mutex_lock (&priv->sack_mutex);
cache_item = g_hash_table_lookup (priv->sack_cache, cache_key);
- if (cache_item != NULL && cache_item->sack != NULL) {
- if (cache_item->valid) {
- ret = TRUE;
- g_debug ("using cached sack %s", cache_key);
- sack = cache_item->sack;
- goto out;
- } else {
- /* we have to do this now rather than rely on the
- * callback of the hash table */
- g_hash_table_remove (priv->sack_cache, cache_key);
+ if (cache_item != NULL && cache_item->sack != NULL) {
+ if (cache_item->valid) {
+ ret = TRUE;
+ g_debug ("using cached sack %s", cache_key);
+ sack = cache_item->sack;
+ g_mutex_unlock (&priv->sack_mutex);
+ goto out;
+ } else {
+ /* we have to do this now rather than rely on the
+ * callback of the hash table */
+ g_hash_table_remove (priv->sack_cache, cache_key);
+ }
}
+ g_mutex_unlock (&priv->sack_mutex);
}
/* update status */
--
2.4.2

View File

@ -0,0 +1,40 @@
From 982d33d04f0390f54ad783914f4dc25cf8913b49 Mon Sep 17 00:00:00 2001
From: Kalev Lember <kalevlember@gmail.com>
Date: Fri, 5 Jun 2015 18:49:38 +0200
Subject: [PATCH 3/4] hif: Improve depsolving for parallel kernel installs
Make sure the magic necessary for parallel kernel installs is properly
set up before depsolving an upgrade goal. This ensures that hawkey has
enough information to figure out what to do in more complicated
situations, such as the one described in
https://bugzilla.redhat.com/show_bug.cgi?id=1205649
---
backends/hif/pk-backend-hif.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/backends/hif/pk-backend-hif.c b/backends/hif/pk-backend-hif.c
index 48d456a..4d4151c 100644
--- a/backends/hif/pk-backend-hif.c
+++ b/backends/hif/pk-backend-hif.c
@@ -860,6 +860,7 @@ pk_backend_search_thread (PkBackendJob *job, GVariant *params, gpointer user_dat
HyQuery query = NULL;
HySack sack = NULL;
PkBackendHifJobData *job_data = pk_backend_job_get_user_data (job);
+ PkBackendHifPrivate *priv = pk_backend_get_user_data (job_data->backend);
PkBitfield filters = 0;
_cleanup_error_free_ GError *error = NULL;
_cleanup_strv_free_ gchar **search = NULL;
@@ -947,6 +948,10 @@ pk_backend_search_thread (PkBackendJob *job, GVariant *params, gpointer user_dat
pkglist = hif_utils_run_query_with_filters (job_data->backend, sack, query, filters);
break;
case PK_ROLE_ENUM_GET_UPDATES:
+ /* set up the sack for packages that should only ever be installed, never updated */
+ hy_sack_set_installonly (sack, hif_context_get_installonly_pkgs (priv->context));
+ hy_sack_set_installonly_limit (sack, hif_context_get_installonly_limit (priv->context));
+
job_data->goal = hy_goal_create (sack);
hy_goal_upgrade_all (job_data->goal);
ret = hif_goal_depsolve (job_data->goal, &error);
--
2.4.2

View File

@ -0,0 +1,135 @@
From 5c398820dcf2c3e72da8ce0ee921f3046a9bbaae Mon Sep 17 00:00:00 2001
From: Kalev Lember <kalevlember@gmail.com>
Date: Fri, 5 Jun 2015 18:51:04 +0200
Subject: [PATCH 4/4] hif: Include any packages marked for installation when
doing upgrades
When hawkey has depsolved an upgrade goal, make sure to not only read
back packages marked for update, but also the packages that are marked
for install. This ensures that we don't accidentally exclude a kernel
update just because hawkey has marked it for install, not update.
Also, since we're now including installable packages, this commit
removes a check that verified that all updated packages had an older
version already installed. Depending on a situation, hawkey might want
to install new packages during an update.
This is the other half needed for fixing
https://bugzilla.redhat.com/show_bug.cgi?id=1205649
---
backends/hif/pk-backend-hif.c | 63 +++++++++++--------------------------------
1 file changed, 15 insertions(+), 48 deletions(-)
diff --git a/backends/hif/pk-backend-hif.c b/backends/hif/pk-backend-hif.c
index 4d4151c..8608259 100644
--- a/backends/hif/pk-backend-hif.c
+++ b/backends/hif/pk-backend-hif.c
@@ -856,6 +856,7 @@ pk_backend_search_thread (PkBackendJob *job, GVariant *params, gpointer user_dat
gchar **search_tmp;
HifDb *db;
HifState *state_local;
+ HyPackageList installs = NULL;
HyPackageList pkglist = NULL;
HyQuery query = NULL;
HySack sack = NULL;
@@ -959,7 +960,18 @@ pk_backend_search_thread (PkBackendJob *job, GVariant *params, gpointer user_dat
pk_backend_job_error_code (job, error->code, "%s", error->message);
goto out;
}
+ /* get packages marked for upgrade */
pkglist = hy_goal_list_upgrades (job_data->goal);
+ /* add any packages marked for install */
+ installs = hy_goal_list_installs (job_data->goal);
+ if (installs != NULL) {
+ guint i;
+ HyPackage pkg;
+
+ FOR_PACKAGELIST(pkg, installs, i) {
+ hy_packagelist_push (pkglist, hy_package_link (pkg));
+ }
+ }
break;
default:
g_assert_not_reached ();
@@ -1021,6 +1033,8 @@ pk_backend_search_thread (PkBackendJob *job, GVariant *params, gpointer user_dat
goto out;
}
out:
+ if (installs != NULL)
+ hy_packagelist_free (installs);
if (pkglist != NULL)
hy_packagelist_free (pkglist);
if (query != NULL)
@@ -2550,32 +2564,6 @@ pk_backend_repo_remove (PkBackend *backend,
}
/**
- * hif_is_installed_package_id_name:
- */
-static gboolean
-hif_is_installed_package_id_name (HySack sack, const gchar *package_id)
-{
- gboolean ret;
- HyPackageList pkglist = NULL;
- HyQuery query = NULL;
- _cleanup_strv_free_ gchar **split = NULL;
-
- /* run query */
- query = hy_query_create (sack);
- split = pk_package_id_split (package_id);
- hy_query_filter (query, HY_PKG_NAME, HY_EQ, split[PK_PACKAGE_ID_NAME]);
- hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME);
- pkglist = hy_query_run (query);
-
- /* any matches? */
- ret = hy_packagelist_count (pkglist) > 0;
-
- hy_packagelist_free (pkglist);
- hy_query_free (query);
- return ret;
-}
-
-/**
* hif_is_installed_package_id_name_arch:
*/
static gboolean
@@ -3082,8 +3070,7 @@ pk_backend_update_packages_thread (PkBackendJob *job, GVariant *params, gpointer
/* set state */
ret = hif_state_set_steps (job_data->state, NULL,
- 8, /* add repos */
- 1, /* check installed */
+ 9, /* add repos */
1, /* find packages */
90, /* run transaction */
-1);
@@ -3112,26 +3099,6 @@ pk_backend_update_packages_thread (PkBackendJob *job, GVariant *params, gpointer
return;
}
- /* ensure packages are not already installed */
- for (i = 0; package_ids[i] != NULL; i++) {
- ret = hif_is_installed_package_id_name (sack, package_ids[i]);
- if (!ret) {
- gchar *printable_tmp;
- printable_tmp = pk_package_id_to_printable (package_ids[i]);
- pk_backend_job_error_code (job,
- PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED,
- "cannot update: %s is not already installed",
- printable_tmp);
- g_free (printable_tmp);
- return;
- }
- }
- /* done */
- if (!hif_state_done (job_data->state, &error)) {
- pk_backend_job_error_code (job, error->code, "%s", error->message);
- return;
- }
-
/* find packages */
hash = hif_utils_find_package_ids (sack, package_ids, &error);
if (hash == NULL) {
--
2.4.2

View File

@ -7,7 +7,7 @@
Summary: Package management service
Name: PackageKit
Version: 1.0.6
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv2+ and LGPLv2+
URL: http://www.freedesktop.org/software/PackageKit/
Source0: http://www.freedesktop.org/software/PackageKit/releases/%{name}-%{version}.tar.xz
@ -17,8 +17,11 @@ Source1: cached-metadata.tar
# Fedora-specific: set Vendor.conf up for Fedora.
Patch0: PackageKit-0.3.8-Fedora-Vendor.conf.patch
# Backported upstream patch
# Backported upstream patches
Patch1: 0001-Revert-Make-reboot-the-default-action-for-no-action-.patch
Patch2: 0002-hif-Add-missing-locking-when-accessing-sack-cache.patch
Patch3: 0003-hif-Improve-depsolving-for-parallel-kernel-installs.patch
Patch4: 0004-hif-Include-any-packages-marked-for-installation-whe.patch
Requires: %{name}-glib%{?_isa} = %{version}-%{release}
Requires: shared-mime-info
@ -315,6 +318,11 @@ systemctl disable packagekit-offline-update.service > /dev/null 2>&1 || :
%{_datadir}/gtk-doc/html/PackageKit
%changelog
* Mon Jun 08 2015 Kalev Lember <kalevlember@gmail.com> - 1.0.6-5
- Backport a few more upstream patches:
- Add missing locking when accessing sack cache (#1146734)
- Improve parallel kernel installation (#1205649)
* Wed May 20 2015 Kalev Lember <kalevlember@gmail.com> - 1.0.6-4
- Update cached metadata in preparation for F22 release