From 8631a4dc21a27dbb077c82a499488e8d9aadee10 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Sat, 22 Sep 2018 13:07:42 -0700 Subject: [PATCH] Backport several more fixes from master for libdnf compat This should fix several bugs, including hopefully the 'runaway' bug recently discussed on test@ list (I'm hoping this is fixed by the 'Adapt for DnfAdvisory changes' patch). --- ...callbacks-on-PkClientHelper-finalize.patch | 276 ++++++++++++++++++ ...e-shut-down-services-cleanly-before-.patch | 79 +++++ ...sage-of-FALSE-when-it-should-be-NULL.patch | 34 +++ ...utdown-the-daemon-on-idle-by-default.patch | 36 +++ ...005-Reflect-latest-changes-in-libdnf.patch | 14 +- ...patch => 0006-Allow-module-filtering.patch | 22 +- ...-update-service-to-run-after-system-.patch | 27 ++ ...rgument-to-the-dnf_sack_filter_modul.patch | 28 ++ 0009-dnf-trivial-Add-missing-include.patch | 26 ++ 0010-dnf-trivial-Fix-whitespace.patch | 25 ++ ...sing-deprecated-hy_goal_downgrade_to.patch | 35 +++ ...or-DnfAdvisory-changes-in-new-libdnf.patch | 55 ++++ ...n-an-interactive-TTY-is-not-availabl.patch | 43 +++ PackageKit.spec | 29 +- 14 files changed, 697 insertions(+), 32 deletions(-) create mode 100644 0001-De-register-callbacks-on-PkClientHelper-finalize.patch create mode 100644 0002-pk-offline-update-shut-down-services-cleanly-before-.patch create mode 100644 0003-Fix-usage-of-FALSE-when-it-should-be-NULL.patch create mode 100644 0004-Shutdown-the-daemon-on-idle-by-default.patch rename 0002-Reflect-latest-changes-in-libdnf.patch => 0005-Reflect-latest-changes-in-libdnf.patch (64%) rename 0001-Allow-module-filtering.patch => 0006-Allow-module-filtering.patch (56%) create mode 100644 0007-Schedule-offline-update-service-to-run-after-system-.patch create mode 100644 0008-Add-additional-argument-to-the-dnf_sack_filter_modul.patch create mode 100644 0009-dnf-trivial-Add-missing-include.patch create mode 100644 0010-dnf-trivial-Fix-whitespace.patch create mode 100644 0011-dnf-Avoid-using-deprecated-hy_goal_downgrade_to.patch create mode 100644 0012-dnf-Adapt-for-DnfAdvisory-changes-in-new-libdnf.patch create mode 100644 0013-Never-assert-when-an-interactive-TTY-is-not-availabl.patch diff --git a/0001-De-register-callbacks-on-PkClientHelper-finalize.patch b/0001-De-register-callbacks-on-PkClientHelper-finalize.patch new file mode 100644 index 0000000..a6da2a3 --- /dev/null +++ b/0001-De-register-callbacks-on-PkClientHelper-finalize.patch @@ -0,0 +1,276 @@ +From 6b08de1e7578e32ec369148ff3f4d7f2e8c884af Mon Sep 17 00:00:00 2001 +From: Robert Ancell +Date: Tue, 15 May 2018 13:07:40 +1200 +Subject: [PATCH 01/13] De-register callbacks on PkClientHelper finalize. + +These could otherwise trigger on a deleted object. +--- + lib/packagekit-glib2/pk-client-helper.c | 83 ++++++++++++++++--------- + 1 file changed, 55 insertions(+), 28 deletions(-) + +diff --git a/lib/packagekit-glib2/pk-client-helper.c b/lib/packagekit-glib2/pk-client-helper.c +index f3240afee..26ee12ec6 100644 +--- a/lib/packagekit-glib2/pk-client-helper.c ++++ b/lib/packagekit-glib2/pk-client-helper.c +@@ -118,12 +118,16 @@ pk_client_helper_stop (PkClientHelper *client_helper, GError **error) + /* stop watching for events */ + if (priv->io_channel_socket_listen_id > 0) + g_source_remove (priv->io_channel_socket_listen_id); ++ priv->io_channel_socket_listen_id = 0; + if (priv->io_channel_child_stdout_listen_id > 0) + g_source_remove (priv->io_channel_child_stdout_listen_id); ++ priv->io_channel_child_stdout_listen_id = 0; + if (priv->io_channel_child_stderr_listen_id > 0) + g_source_remove (priv->io_channel_child_stderr_listen_id); ++ priv->io_channel_child_stderr_listen_id = 0; + if (priv->io_channel_child_stdin_listen_id > 0) + g_source_remove (priv->io_channel_child_stdin_listen_id); ++ priv->io_channel_child_stdin_listen_id = 0; + } + + /* kill process */ +@@ -170,15 +174,16 @@ pk_client_helper_copy_stdout_cb (GIOChannel *source, GIOCondition condition, PkC + /* the helper process exited */ + if ((condition & G_IO_HUP) > 0) { + g_debug ("helper process exited"); ++ priv->io_channel_child_stdout_listen_id = 0; + status = g_io_channel_shutdown (priv->io_channel_child_stdout, FALSE, &error); + if (status != G_IO_STATUS_NORMAL) { + g_warning ("failed to shutdown channel: %s", error->message); +- return FALSE; ++ return G_SOURCE_REMOVE; + } + status = g_io_channel_shutdown (priv->io_channel_child_stderr, FALSE, &error); + if (status != G_IO_STATUS_NORMAL) { + g_warning ("failed to shutdown channel: %s", error->message); +- return FALSE; ++ return G_SOURCE_REMOVE; + } + if (priv->active_conn != NULL) { + ret = g_socket_close (priv->active_conn, &error); +@@ -188,7 +193,7 @@ pk_client_helper_copy_stdout_cb (GIOChannel *source, GIOCondition condition, PkC + g_object_unref (priv->active_conn); + priv->active_conn = NULL; + } +- return FALSE; ++ return G_SOURCE_REMOVE; + } + + /* there is data to read */ +@@ -198,10 +203,11 @@ pk_client_helper_copy_stdout_cb (GIOChannel *source, GIOCondition condition, PkC + status = g_io_channel_read_chars (source, data, 1024, &len, &error); + if (status == G_IO_STATUS_EOF) { + g_warning ("child closed unexpectedly"); +- return FALSE; ++ priv->io_channel_child_stdout_listen_id = 0; ++ return G_SOURCE_REMOVE; + } + if (len == 0) +- return TRUE; ++ return G_SOURCE_CONTINUE; + + /* write to socket */ + data[len] = '\0'; +@@ -209,16 +215,18 @@ pk_client_helper_copy_stdout_cb (GIOChannel *source, GIOCondition condition, PkC + status = g_io_channel_write_chars (priv->io_channel_socket, data, len, &written, &error); + if (status != G_IO_STATUS_NORMAL) { + g_warning ("failed to write to socket: %s", error->message); +- return FALSE; ++ priv->io_channel_child_stdout_listen_id = 0; ++ return G_SOURCE_REMOVE; + } + if (written != len) { + g_warning ("failed to write %" G_GSIZE_FORMAT " bytes, " + "only wrote %" G_GSIZE_FORMAT " bytes", len, written); +- return FALSE; ++ priv->io_channel_child_stdout_listen_id = 0; ++ return G_SOURCE_REMOVE; + } + g_debug ("wrote %" G_GSIZE_FORMAT " bytes to socket", written); + } +- return TRUE; ++ return G_SOURCE_CONTINUE; + } + + /* +@@ -227,10 +235,11 @@ pk_client_helper_copy_stdout_cb (GIOChannel *source, GIOCondition condition, PkC + static gboolean + pk_client_helper_echo_stderr_cb (GIOChannel *source, GIOCondition condition, PkClientHelper *client_helper) + { ++ PkClientHelperPrivate *priv = client_helper->priv; + gchar data[1024]; + gsize len = 0; + GIOStatus status; +- gboolean ret = TRUE; ++ gboolean ret = G_SOURCE_CONTINUE; + + /* there is data to read */ + if ((condition & G_IO_IN) == 0) +@@ -239,7 +248,8 @@ pk_client_helper_echo_stderr_cb (GIOChannel *source, GIOCondition condition, PkC + /* read data */ + status = g_io_channel_read_chars (source, data, 1024, &len, NULL); + if (status == G_IO_STATUS_EOF) { +- ret = FALSE; ++ priv->io_channel_child_stderr_listen_id = 0; ++ ret = G_SOURCE_REMOVE; + goto out; + } + if (len == 0) +@@ -261,33 +271,39 @@ pk_client_helper_copy_conn_cb (GIOChannel *source, GIOCondition condition, PkCli + PkClientHelperPrivate *priv = client_helper->priv; + gchar data[1024]; + gsize len = 0; +- GIOStatus status; + gsize written = 0; +- gboolean ret = TRUE; + g_autoptr(GError) error = NULL; + + /* package manager is done processing a package */ + if ((condition & G_IO_HUP) > 0) { ++ gboolean ret; ++ + g_debug ("socket hung up"); + ret = g_socket_close (priv->active_conn, &error); + if (!ret) + g_warning ("failed to close socket"); + g_object_unref (priv->active_conn); + priv->active_conn = NULL; +- return FALSE; ++ priv->io_channel_child_stdin_listen_id = 0; ++ return G_SOURCE_REMOVE; + } + + /* there is data to read */ + if ((condition & G_IO_IN) > 0) { ++ GIOStatus status; ++ + status = g_io_channel_read_chars (source, data, 1024, &len, &error); +- if (status == G_IO_STATUS_EOF) +- return FALSE; ++ if (status == G_IO_STATUS_EOF) { ++ priv->io_channel_child_stdin_listen_id = 0; ++ return G_SOURCE_REMOVE; ++ } + if (error != NULL) { + g_warning ("failed to read: %s", error->message); +- return FALSE; ++ priv->io_channel_child_stdin_listen_id = 0; ++ return G_SOURCE_REMOVE; + } + if (len == 0) +- return TRUE; ++ return G_SOURCE_CONTINUE; + + /* write to child */ + data[len] = '\0'; +@@ -295,16 +311,18 @@ pk_client_helper_copy_conn_cb (GIOChannel *source, GIOCondition condition, PkCli + status = g_io_channel_write_chars (priv->io_channel_child_stdin, data, len, &written, &error); + if (status != G_IO_STATUS_NORMAL) { + g_warning ("failed to write to stdin: %s", error->message); +- return FALSE; ++ priv->io_channel_child_stdin_listen_id = 0; ++ return G_SOURCE_REMOVE; + } + if (written != len) { + g_warning ("failed to write %" G_GSIZE_FORMAT " bytes, " + "only wrote %" G_GSIZE_FORMAT " bytes", len, written); +- return FALSE; ++ priv->io_channel_child_stdin_listen_id = 0; ++ return G_SOURCE_REMOVE; + } + g_debug ("wrote %" G_GSIZE_FORMAT " bytes to stdin of %s", written, priv->argv[0]); + } +- return TRUE; ++ return G_SOURCE_CONTINUE; + } + + /* +@@ -324,13 +342,13 @@ pk_client_helper_accept_connection_cb (GIOChannel *source, GIOCondition conditio + + /* delaying connection */ + if (priv->active_conn != NULL) +- return TRUE; ++ return G_SOURCE_CONTINUE; + + /* accept the connection request */ + priv->active_conn = g_socket_accept (priv->socket, NULL, &error); + if (priv->active_conn == NULL) { + g_warning ("failed to accept socket: %s", error->message); +- return TRUE; ++ return G_SOURCE_CONTINUE; + } + g_debug ("accepting connection %i for socket %i", + g_socket_get_fd (priv->active_conn), +@@ -341,7 +359,7 @@ pk_client_helper_accept_connection_cb (GIOChannel *source, GIOCondition conditio + &standard_input, &standard_output, &standard_error, &error); + if (!ret) { + g_warning ("failed to spawn: %s", error->message); +- return TRUE; ++ return G_SOURCE_CONTINUE; + } + g_debug ("started process %s with pid %i", priv->argv[0], priv->child_pid); + +@@ -354,7 +372,7 @@ pk_client_helper_accept_connection_cb (GIOChannel *source, GIOCondition conditio + status = g_io_channel_set_encoding (priv->io_channel_child_stdin, NULL, &error); + if (status != G_IO_STATUS_NORMAL) { + g_warning ("failed to set encoding: %s", error->message); +- return TRUE; ++ return G_SOURCE_CONTINUE; + } + g_io_channel_set_buffered (priv->io_channel_child_stdin, FALSE); + +@@ -362,7 +380,7 @@ pk_client_helper_accept_connection_cb (GIOChannel *source, GIOCondition conditio + status = g_io_channel_set_encoding (priv->io_channel_child_stdout, NULL, &error); + if (status != G_IO_STATUS_NORMAL) { + g_warning ("failed to set encoding: %s", error->message); +- return TRUE; ++ return G_SOURCE_CONTINUE; + } + g_io_channel_set_buffered (priv->io_channel_child_stdout, FALSE); + +@@ -370,7 +388,7 @@ pk_client_helper_accept_connection_cb (GIOChannel *source, GIOCondition conditio + status = g_io_channel_set_encoding (priv->io_channel_child_stderr, NULL, &error); + if (status != G_IO_STATUS_NORMAL) { + g_warning ("failed to set encoding: %s", error->message); +- return TRUE; ++ return G_SOURCE_CONTINUE; + } + g_io_channel_set_buffered (priv->io_channel_child_stderr, FALSE); + +@@ -385,7 +403,7 @@ pk_client_helper_accept_connection_cb (GIOChannel *source, GIOCondition conditio + status = g_io_channel_set_encoding (priv->io_channel_socket, NULL, &error); + if (status != G_IO_STATUS_NORMAL) { + g_warning ("failed to set encoding: %s", error->message); +- return TRUE; ++ return G_SOURCE_CONTINUE; + } + g_io_channel_set_buffered (priv->io_channel_socket, FALSE); + +@@ -397,7 +415,7 @@ pk_client_helper_accept_connection_cb (GIOChannel *source, GIOCondition conditio + priv->io_channel_child_stderr_listen_id = + g_io_add_watch_full (priv->io_channel_child_stderr, G_PRIORITY_HIGH_IDLE, G_IO_IN, + (GIOFunc) pk_client_helper_echo_stderr_cb, client_helper, NULL); +- return TRUE; ++ return G_SOURCE_CONTINUE; + } + + /** +@@ -533,6 +551,15 @@ pk_client_helper_finalize (GObject *object) + PkClientHelper *client_helper = PK_CLIENT_HELPER (object); + PkClientHelperPrivate *priv = client_helper->priv; + ++ if (priv->io_channel_socket_listen_id > 0) ++ g_source_remove (priv->io_channel_socket_listen_id); ++ if (priv->io_channel_child_stdout_listen_id > 0) ++ g_source_remove (priv->io_channel_child_stdout_listen_id); ++ if (priv->io_channel_child_stderr_listen_id > 0) ++ g_source_remove (priv->io_channel_child_stderr_listen_id); ++ if (priv->io_channel_child_stdin_listen_id > 0) ++ g_source_remove (priv->io_channel_child_stdin_listen_id); ++ + if (priv->socket_file != NULL) + g_object_unref (priv->socket_file); + if (priv->io_channel_socket != NULL) +-- +2.19.0 + diff --git a/0002-pk-offline-update-shut-down-services-cleanly-before-.patch b/0002-pk-offline-update-shut-down-services-cleanly-before-.patch new file mode 100644 index 0000000..e7d864e --- /dev/null +++ b/0002-pk-offline-update-shut-down-services-cleanly-before-.patch @@ -0,0 +1,79 @@ +From 721249857d6ade6b3cdfd207486c026b1eb6098a Mon Sep 17 00:00:00 2001 +From: Alan Jenkins +Date: Wed, 16 May 2018 10:42:49 +0100 +Subject: [PATCH 02/13] pk-offline-update: shut down services cleanly before + rebooting +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +do not use forced reboot. +https://bugzilla.redhat.com/show_bug.cgi?id=1564462 + +Seconded by Zbigniew Jędrzejewski-Szmek. +"org.freedesktop.systemd1.Manager.Reboot is unnecessarily harsh, and +shutting down normally through StartUnit is much better." + +Having pk-offline-update use a different, harsher shutdown path than is +used in normal operation, is a really no-good idea and can trigger problems +which are harder than necessary to test, reproduce, etc. + +For example, Fedora is not unmounting the root filesystem cleanly! due to a +plymouth bug. In *some* circumstances, the graceful systemd shutdown +will avoid this. Because a graceful shutdown *with an LVM rootfs*, will +transition back into dracut for final shutdown. And dracut includes a +workaround for plymouth or similar very weird processes, which has recently +been modified and hopefully works more reliably now. + +https://unix.stackexchange.com/questions/441511/does-recovering-journal-prove-an-unclean-shutdown-unmount + +https://bugzilla.redhat.com/show_bug.cgi?id=1575376#c10 + +https://github.com/dracutdevs/dracut/commit/df6bb5e959178cba06118493a7c8d019e84d54e7 + +I was able to reproduce the plymouth bug, by downgrading a package and then +running an offline update. I have a systemd-shutdown hook which pauses +before rebooting/entering dracut; this let me see log messages about +failing to remount the root filesystem as read-only, because it was still +busy (for writing) - i.e. by plymouth. + +With this commit applied, the filesystem was clean after the reboot, and +did not require journal recovery. Thanks to the version of dracut which +makes sure to kill plymouth before unmounting the root filesystem. +--- + client/pk-offline-update.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/client/pk-offline-update.c b/client/pk-offline-update.c +index 73f524c1f..9fb248aef 100644 +--- a/client/pk-offline-update.c ++++ b/client/pk-offline-update.c +@@ -214,8 +214,10 @@ pk_offline_update_reboot (void) + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", +- "Reboot", +- NULL, ++ "StartUnit", ++ g_variant_new("(ss)", ++ "reboot.target", ++ "replace-irreversibly"), + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, +@@ -257,8 +259,10 @@ pk_offline_update_power_off (void) + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", +- "PowerOff", +- NULL, ++ "StartUnit", ++ g_variant_new("(ss)", ++ "poweroff.target", ++ "replace-irreversibly"), + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, +-- +2.19.0 + diff --git a/0003-Fix-usage-of-FALSE-when-it-should-be-NULL.patch b/0003-Fix-usage-of-FALSE-when-it-should-be-NULL.patch new file mode 100644 index 0000000..dfb24f1 --- /dev/null +++ b/0003-Fix-usage-of-FALSE-when-it-should-be-NULL.patch @@ -0,0 +1,34 @@ +From 9053bc6809fb009c41799ad95d082af7e4bb29a8 Mon Sep 17 00:00:00 2001 +From: Robert Ancell +Date: Thu, 17 May 2018 14:03:48 +1200 +Subject: [PATCH 03/13] Fix usage of FALSE when it should be NULL + +--- + lib/packagekit-glib2/pk-client.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/lib/packagekit-glib2/pk-client.c b/lib/packagekit-glib2/pk-client.c +index 15f684eed..8a928263c 100644 +--- a/lib/packagekit-glib2/pk-client.c ++++ b/lib/packagekit-glib2/pk-client.c +@@ -1972,7 +1972,7 @@ pk_client_create_helper_socket (PkClientState *state) + + /* no supported frontends available */ + if (!ret) +- return FALSE; ++ return NULL; + + /* create object */ + state->client_helper = pk_client_helper_new (); +@@ -1985,7 +1985,7 @@ pk_client_create_helper_socket (PkClientState *state) + ret = pk_client_helper_start (state->client_helper, socket_filename, argv, envp, &error); + if (!ret) { + g_warning ("failed to open debconf socket: %s", error->message); +- return FALSE; ++ return NULL; + } + + /* success */ +-- +2.19.0 + diff --git a/0004-Shutdown-the-daemon-on-idle-by-default.patch b/0004-Shutdown-the-daemon-on-idle-by-default.patch new file mode 100644 index 0000000..328f4f7 --- /dev/null +++ b/0004-Shutdown-the-daemon-on-idle-by-default.patch @@ -0,0 +1,36 @@ +From 934ced74697a2c2f0a13737318db581302311523 Mon Sep 17 00:00:00 2001 +From: Richard Hughes +Date: Tue, 15 May 2018 17:28:39 +0100 +Subject: [PATCH 04/13] Shutdown the daemon on idle by default + +This reverts commit c6eb3555ec5b41e988c111d276764d55fb83bda3 and means that +the daemon will close after 5 minutes of inactivity. + +The percieved race on shutdown is mitigated by the engine unown-ing the D-Bus +name in finalize. For machines with 2GB of RAM unloading the SAT database is a +big deal. + +The slight downside here is that doing operations on the command line with +dnf or rpm will not trigger an updates_changed signal in GNOME Software if +PackageKit is not running, but the changed event should still be sent when the +the inotify watches of things in the AsStore fire. +--- + src/pk-main.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/pk-main.c b/src/pk-main.c +index f21767734..980be0a99 100644 +--- a/src/pk-main.c ++++ b/src/pk-main.c +@@ -190,6 +190,8 @@ main (int argc, char *argv[]) + + /* after how long do we timeout? */ + exit_idle_time = g_key_file_get_integer (conf, "Daemon", "ShutdownTimeout", NULL); ++ if (exit_idle_time == 0) ++ exit_idle_time = 300; + g_debug ("daemon shutdown set to %i seconds", exit_idle_time); + + /* override the backend name */ +-- +2.19.0 + diff --git a/0002-Reflect-latest-changes-in-libdnf.patch b/0005-Reflect-latest-changes-in-libdnf.patch similarity index 64% rename from 0002-Reflect-latest-changes-in-libdnf.patch rename to 0005-Reflect-latest-changes-in-libdnf.patch index 62e7e34..bc8e100 100644 --- a/0002-Reflect-latest-changes-in-libdnf.patch +++ b/0005-Reflect-latest-changes-in-libdnf.patch @@ -1,7 +1,7 @@ -From 372b746c0cd2fcbf8c695a3a89834e58f55ee2a7 Mon Sep 17 00:00:00 2001 +From 92f26d8965622d4a4ca28bdc952b9d876cb354ce Mon Sep 17 00:00:00 2001 From: Jaroslav Mracek Date: Tue, 6 Mar 2018 14:37:50 +0100 -Subject: [PATCH 2/2] Reflect latest changes in libdnf +Subject: [PATCH 05/13] Reflect latest changes in libdnf Requires: libdnf-0.13.0+ @@ -13,12 +13,10 @@ used instead. 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/dnf/pk-backend-dnf.c b/backends/dnf/pk-backend-dnf.c -index a34c05b799dd2baf2bbd72492b66b3112af386ae..414a13f320a2e4fb3cff4f8ad4ae661c6bcd41b6 100644 +index d997dee67..ddfcd4231 100644 --- a/backends/dnf/pk-backend-dnf.c +++ b/backends/dnf/pk-backend-dnf.c -@@ -851,11 +851,11 @@ dnf_utils_run_query_with_newest_filter (DnfSack *sack, HyQuery query) - g_ptr_array_add (results, g_object_ref (pkg)); - } +@@ -850,7 +850,7 @@ dnf_utils_run_query_with_newest_filter (DnfSack *sack, HyQuery query) hy_query_free (query_tmp); g_ptr_array_unref (results_tmp); @@ -27,8 +25,6 @@ index a34c05b799dd2baf2bbd72492b66b3112af386ae..414a13f320a2e4fb3cff4f8ad4ae661c return results; } - - /** -- -2.17.1 +2.19.0 diff --git a/0001-Allow-module-filtering.patch b/0006-Allow-module-filtering.patch similarity index 56% rename from 0001-Allow-module-filtering.patch rename to 0006-Allow-module-filtering.patch index 37ebb0a..742e6e9 100644 --- a/0001-Allow-module-filtering.patch +++ b/0006-Allow-module-filtering.patch @@ -1,7 +1,7 @@ -From 23a355776d123723ac974afb214a93f1b2ee2f35 Mon Sep 17 00:00:00 2001 +From 1a29475d35d2a054901eaad6f121980577b2c962 Mon Sep 17 00:00:00 2001 From: Jaroslav Mracek Date: Tue, 12 Jun 2018 08:57:54 +0200 -Subject: [PATCH 1/2] Allow module filtering +Subject: [PATCH 06/13] Allow module filtering It should disable packages from disabled modules. @@ -11,12 +11,10 @@ The patch requires libdnf-0.15.0 1 file changed, 3 insertions(+) diff --git a/backends/dnf/pk-backend-dnf.c b/backends/dnf/pk-backend-dnf.c -index d997dee67c7d736a2032f8b6b15bdcb2d1f9e473..1131aa4ab079b82dbe17c97ca6e239a754540f38 100644 +index ddfcd4231..414a13f32 100644 --- a/backends/dnf/pk-backend-dnf.c +++ b/backends/dnf/pk-backend-dnf.c -@@ -37,10 +37,11 @@ - #include - #include +@@ -39,6 +39,7 @@ #include #include #include @@ -24,21 +22,15 @@ index d997dee67c7d736a2032f8b6b15bdcb2d1f9e473..1131aa4ab079b82dbe17c97ca6e239a7 #include #include - #include "dnf-backend-vendor.h" - #include "dnf-backend.h" -@@ -797,10 +798,12 @@ dnf_utils_create_sack_for_filters (PkBackendJob *job, - ret = dnf_state_done (state, error); - if (!ret) +@@ -799,6 +800,8 @@ dnf_utils_create_sack_for_filters (PkBackendJob *job, return NULL; } -+ dnf_sack_filter_modules (sack, dnf_context_get_repos (job_data->context), install_root, NULL); ++ dnf_sack_filter_modules (sack, dnf_context_get_repos (job_data->context), install_root); + /* save in cache */ g_mutex_lock (&priv->sack_mutex); cache_item = g_slice_new (DnfSackCacheItem); - cache_item->key = g_strdup (cache_key); - cache_item->sack = g_object_ref (sack); -- -2.17.1 +2.19.0 diff --git a/0007-Schedule-offline-update-service-to-run-after-system-.patch b/0007-Schedule-offline-update-service-to-run-after-system-.patch new file mode 100644 index 0000000..3116585 --- /dev/null +++ b/0007-Schedule-offline-update-service-to-run-after-system-.patch @@ -0,0 +1,27 @@ +From 63118a587c967ecfc8eeb4155d7f44e0dcf3fe25 Mon Sep 17 00:00:00 2001 +From: Kalev Lember +Date: Tue, 3 Jul 2018 10:44:28 +0200 +Subject: [PATCH 07/13] Schedule offline update service to run after + system-update-pre.target + +https://bugzilla.redhat.com/show_bug.cgi?id=1597659 +--- + data/packagekit-offline-update.service.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/data/packagekit-offline-update.service.in b/data/packagekit-offline-update.service.in +index 55e1f82c9..23096058f 100644 +--- a/data/packagekit-offline-update.service.in ++++ b/data/packagekit-offline-update.service.in +@@ -3,7 +3,7 @@ Description=Update the operating system whilst offline + + DefaultDependencies=no + Requires=sysinit.target dbus.socket +-After=sysinit.target dbus.socket systemd-journald.socket ++After=sysinit.target dbus.socket systemd-journald.socket system-update-pre.target + Before=shutdown.target system-update.target + # See packagekit.service + ConditionPathExists=!/run/ostree-booted +-- +2.19.0 + diff --git a/0008-Add-additional-argument-to-the-dnf_sack_filter_modul.patch b/0008-Add-additional-argument-to-the-dnf_sack_filter_modul.patch new file mode 100644 index 0000000..a785a56 --- /dev/null +++ b/0008-Add-additional-argument-to-the-dnf_sack_filter_modul.patch @@ -0,0 +1,28 @@ +From b62e128b9e068ec4180f3f63cc2e448bcb32802e Mon Sep 17 00:00:00 2001 +From: Daniel Mach +Date: Thu, 2 Aug 2018 13:44:17 +0200 +Subject: [PATCH 08/13] Add additional argument to the + dnf_sack_filter_modules() call. + +Libdnf API has changed and the function takes an additional argument: platformModule. +It's set to NULL to trigger platform module auto-detection based on /etc/os-release. +--- + backends/dnf/pk-backend-dnf.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/backends/dnf/pk-backend-dnf.c b/backends/dnf/pk-backend-dnf.c +index 414a13f32..b6d575737 100644 +--- a/backends/dnf/pk-backend-dnf.c ++++ b/backends/dnf/pk-backend-dnf.c +@@ -800,7 +800,7 @@ dnf_utils_create_sack_for_filters (PkBackendJob *job, + return NULL; + } + +- dnf_sack_filter_modules (sack, dnf_context_get_repos (job_data->context), install_root); ++ dnf_sack_filter_modules (sack, dnf_context_get_repos (job_data->context), install_root, NULL); + + /* save in cache */ + g_mutex_lock (&priv->sack_mutex); +-- +2.19.0 + diff --git a/0009-dnf-trivial-Add-missing-include.patch b/0009-dnf-trivial-Add-missing-include.patch new file mode 100644 index 0000000..8e42308 --- /dev/null +++ b/0009-dnf-trivial-Add-missing-include.patch @@ -0,0 +1,26 @@ +From 5902d7a575cbd33649593f1e9324810ccc5253e6 Mon Sep 17 00:00:00 2001 +From: Kalev Lember +Date: Wed, 12 Sep 2018 14:57:22 +0200 +Subject: [PATCH 09/13] dnf: trivial: Add missing include + +Add missing dnf-db.h for dnf_db_ensure_origin_pkglist() and +dnf_db_ensure_origin_pkg(). +--- + backends/dnf/pk-backend-dnf.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/backends/dnf/pk-backend-dnf.c b/backends/dnf/pk-backend-dnf.c +index b6d575737..e2e4a0a7b 100644 +--- a/backends/dnf/pk-backend-dnf.c ++++ b/backends/dnf/pk-backend-dnf.c +@@ -36,6 +36,7 @@ + #include + #include + #include ++#include + #include + #include + #include +-- +2.19.0 + diff --git a/0010-dnf-trivial-Fix-whitespace.patch b/0010-dnf-trivial-Fix-whitespace.patch new file mode 100644 index 0000000..4078c1a --- /dev/null +++ b/0010-dnf-trivial-Fix-whitespace.patch @@ -0,0 +1,25 @@ +From aaba3baa744936da2fafaf3e89bd74c8f8294eab Mon Sep 17 00:00:00 2001 +From: Kalev Lember +Date: Wed, 12 Sep 2018 15:00:13 +0200 +Subject: [PATCH 10/13] dnf: trivial: Fix whitespace + +--- + backends/dnf/pk-backend-dnf.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/backends/dnf/pk-backend-dnf.c b/backends/dnf/pk-backend-dnf.c +index e2e4a0a7b..7c8465b73 100644 +--- a/backends/dnf/pk-backend-dnf.c ++++ b/backends/dnf/pk-backend-dnf.c +@@ -854,7 +854,7 @@ dnf_utils_run_query_with_newest_filter (DnfSack *sack, HyQuery query) + hy_query_free (query_tmp); + g_ptr_array_unref (results_tmp); + +- dnf_packageset_free(pkgset); ++ dnf_packageset_free (pkgset); + + return results; + } +-- +2.19.0 + diff --git a/0011-dnf-Avoid-using-deprecated-hy_goal_downgrade_to.patch b/0011-dnf-Avoid-using-deprecated-hy_goal_downgrade_to.patch new file mode 100644 index 0000000..f4dfbdc --- /dev/null +++ b/0011-dnf-Avoid-using-deprecated-hy_goal_downgrade_to.patch @@ -0,0 +1,35 @@ +From a3876b538b0bdc20b2c5ec40d73fc2c83457e92f Mon Sep 17 00:00:00 2001 +From: Kalev Lember +Date: Wed, 12 Sep 2018 15:02:59 +0200 +Subject: [PATCH 11/13] dnf: Avoid using deprecated hy_goal_downgrade_to() + +Just use hy_goal_install() that does the exact same thing. +--- + backends/dnf/pk-backend-dnf.c | 10 +++------- + 1 file changed, 3 insertions(+), 7 deletions(-) + +diff --git a/backends/dnf/pk-backend-dnf.c b/backends/dnf/pk-backend-dnf.c +index 7c8465b73..988dd8fcb 100644 +--- a/backends/dnf/pk-backend-dnf.c ++++ b/backends/dnf/pk-backend-dnf.c +@@ -3152,14 +3152,10 @@ pk_backend_install_packages_thread (PkBackendJob *job, GVariant *params, gpointe + "Failed to find %s", package_ids[i]); + return; + } +- if (relations[i] == HY_LT) { +- hy_goal_downgrade_to (job_data->goal, pkg); +- } else { +- if (relations[i] == HY_EQ) { +- dnf_package_set_action (pkg, DNF_STATE_ACTION_REINSTALL); +- } +- hy_goal_install (job_data->goal, pkg); ++ if (relations[i] == HY_EQ) { ++ dnf_package_set_action (pkg, DNF_STATE_ACTION_REINSTALL); + } ++ hy_goal_install (job_data->goal, pkg); + } + + /* run transaction */ +-- +2.19.0 + diff --git a/0012-dnf-Adapt-for-DnfAdvisory-changes-in-new-libdnf.patch b/0012-dnf-Adapt-for-DnfAdvisory-changes-in-new-libdnf.patch new file mode 100644 index 0000000..976d606 --- /dev/null +++ b/0012-dnf-Adapt-for-DnfAdvisory-changes-in-new-libdnf.patch @@ -0,0 +1,55 @@ +From cc2df77b5c60b323539f19002b2d482a4be0079f Mon Sep 17 00:00:00 2001 +From: Kalev Lember +Date: Thu, 20 Sep 2018 15:36:20 +0200 +Subject: [PATCH 12/13] dnf: Adapt for DnfAdvisory changes in new libdnf + +libdnf has some wonky memory management here, and apparently it's +deliberately so. dnf_package_get_advisories() now returns a GPtrArray +that doesn't have a free function set as DnfAdvisory is no longer a +GObject. Instead, the called is supposed to deep free the returned +array. + +This fixes packagekitd spamming logs on F29 with: +(packagekitd:1317): GLib-GObject-CRITICAL **: 19:49:09.741: g_object_ref: assertion 'G_IS_OBJECT (object)' failed +--- + backends/dnf/pk-backend-dnf.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/backends/dnf/pk-backend-dnf.c b/backends/dnf/pk-backend-dnf.c +index 988dd8fcb..ad891adad 100644 +--- a/backends/dnf/pk-backend-dnf.c ++++ b/backends/dnf/pk-backend-dnf.c +@@ -942,8 +942,10 @@ dnf_package_get_advisory (DnfPackage *package) + + advisorylist = dnf_package_get_advisories (package, HY_EQ); + +- if (advisorylist->len > 0) +- advisory = g_object_ref (g_ptr_array_index (advisorylist, 0)); ++ for (guint i = 0; i < advisorylist->len; i++) { ++ dnf_advisory_free (advisory); ++ advisory = g_ptr_array_index (advisorylist, 0); ++ } + g_ptr_array_unref (advisorylist); + + return advisory; +@@ -1115,7 +1117,7 @@ pk_backend_search_thread (PkBackendJob *job, GVariant *params, gpointer user_dat + advisory = dnf_package_get_advisory (pkg); + if (advisory != NULL) { + kind = dnf_advisory_get_kind (advisory); +- g_object_unref (advisory); ++ dnf_advisory_free (advisory); + info_enum = dnf_advisory_kind_to_info_enum (kind); + dnf_package_set_info (pkg, info_enum); + } +@@ -3822,7 +3824,7 @@ pk_backend_get_update_detail_thread (PkBackendJob *job, GVariant *params, gpoint + NULL /* updated */); + + g_ptr_array_unref (references); +- g_object_unref (advisory); ++ dnf_advisory_free (advisory); + } + + /* done */ +-- +2.19.0 + diff --git a/0013-Never-assert-when-an-interactive-TTY-is-not-availabl.patch b/0013-Never-assert-when-an-interactive-TTY-is-not-availabl.patch new file mode 100644 index 0000000..2e2cf94 --- /dev/null +++ b/0013-Never-assert-when-an-interactive-TTY-is-not-availabl.patch @@ -0,0 +1,43 @@ +From 984e7b03e186e71a51476ede965cc6d27179f735 Mon Sep 17 00:00:00 2001 +From: Richard Hughes +Date: Fri, 21 Sep 2018 11:47:00 +0100 +Subject: [PATCH 13/13] Never assert when an interactive TTY is not available + +Also, fd==0 is unlikely, but valid. Do the right thing in finalize(). +--- + lib/packagekit-glib2/pk-progress-bar.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/lib/packagekit-glib2/pk-progress-bar.c b/lib/packagekit-glib2/pk-progress-bar.c +index 3917c2cf2..e75f319e4 100644 +--- a/lib/packagekit-glib2/pk-progress-bar.c ++++ b/lib/packagekit-glib2/pk-progress-bar.c +@@ -58,6 +58,8 @@ pk_progress_bar_console (PkProgressBar *self, const gchar *tmp) + gssize count; + gssize wrote; + count = strlen (tmp) + 1; ++ if (self->priv->tty_fd < 0) ++ return; + wrote = write (self->priv->tty_fd, tmp, count); + if (wrote != count) { + g_warning ("Only wrote %" G_GSSIZE_FORMAT +@@ -366,7 +368,7 @@ pk_progress_bar_finalize (GObject *object) + g_free (self->priv->old_start_text); + if (self->priv->timer_id != 0) + g_source_remove (self->priv->timer_id); +- if (self->priv->tty_fd > 0) ++ if (self->priv->tty_fd >= 0) + close (self->priv->tty_fd); + G_OBJECT_CLASS (pk_progress_bar_parent_class)->finalize (object); + } +@@ -399,7 +401,6 @@ pk_progress_bar_init (PkProgressBar *self) + self->priv->tty_fd = open ("/dev/console", O_RDWR, 0); + if (self->priv->tty_fd < 0) + self->priv->tty_fd = open ("/dev/stdout", O_RDWR, 0); +- g_assert (self->priv->tty_fd > 0); + } + + /** +-- +2.19.0 + diff --git a/PackageKit.spec b/PackageKit.spec index cc1f92a..399e9f6 100644 --- a/PackageKit.spec +++ b/PackageKit.spec @@ -14,7 +14,7 @@ Summary: Package management service Name: PackageKit Version: 1.1.10 -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 @@ -29,8 +29,22 @@ Provides: bundled(libdnf) = 0.7.0 # Fedora-specific: set Vendor.conf up for Fedora. Patch0: PackageKit-0.3.8-Fedora-Vendor.conf.patch -Patch1: 0001-Allow-module-filtering.patch -Patch2: 0002-Reflect-latest-changes-in-libdnf.patch +# Backports from master that fix various bugs and compat issues +# esp. with recent libdnf +Patch1: 0001-De-register-callbacks-on-PkClientHelper-finalize.patch +Patch2: 0002-pk-offline-update-shut-down-services-cleanly-before-.patch +Patch3: 0003-Fix-usage-of-FALSE-when-it-should-be-NULL.patch +Patch4: 0004-Shutdown-the-daemon-on-idle-by-default.patch +Patch5: 0005-Reflect-latest-changes-in-libdnf.patch +Patch6: 0006-Allow-module-filtering.patch +Patch7: 0007-Schedule-offline-update-service-to-run-after-system-.patch +Patch8: 0008-Add-additional-argument-to-the-dnf_sack_filter_modul.patch +Patch9: 0009-dnf-trivial-Add-missing-include.patch +Patch10: 0010-dnf-trivial-Fix-whitespace.patch +Patch11: 0011-dnf-Avoid-using-deprecated-hy_goal_downgrade_to.patch +Patch12: 0012-dnf-Adapt-for-DnfAdvisory-changes-in-new-libdnf.patch +Patch13: 0013-Never-assert-when-an-interactive-TTY-is-not-availabl.patch + BuildRequires: glib2-devel >= %{glib2_version} BuildRequires: xmlto @@ -183,17 +197,13 @@ A simple helper that offers to install new packages on the command line using PackageKit. %prep -%setup -q +%autosetup -p1 %if 0%{?bundled_libdnf} # Extract libdnf archive tar -xf %{S:1} %endif -%patch0 -p1 -b .fedora -%patch1 -p1 -b .modularity -%patch2 -p1 -b .libdnf - %build %if 0%{?bundled_libdnf} mkdir -p libdnf-%{commit1}/build @@ -345,6 +355,9 @@ systemctl disable packagekit-offline-update.service > /dev/null 2>&1 || : %{_datadir}/vala/vapi/packagekit-glib2.vapi %changelog +* Sat Sep 22 2018 Adam Williamson - 1.1.10-5 +- Backport several more fixes from master for libdnf compat + * Tue Jul 24 2018 Stephen Gallagher - 1.1.10-4 - Add patch to support modularity