diff --git a/PackageKit-0.8.1-master.patch b/PackageKit-0.8.1-master.patch index d486aa8..832e17e 100644 --- a/PackageKit-0.8.1-master.patch +++ b/PackageKit-0.8.1-master.patch @@ -132,6 +132,63 @@ index 491f044..896d32b 100755 pct = div * (ts_current - 1) + pct_start + ((div / 100.0) * val) self.base.percentage(pct) +diff --git a/client/pk-console.c b/client/pk-console.c +index ade188e..edbe593 100644 +--- a/client/pk-console.c ++++ b/client/pk-console.c +@@ -978,6 +978,41 @@ out: + } + + /** ++ * pk_console_update_system: ++ **/ ++static gboolean ++pk_console_update_system (GError **error) ++{ ++ gboolean ret = TRUE; ++ gchar **package_ids = NULL; ++ PkPackageSack *sack = NULL; ++ PkResults *results; ++ ++ /* get the current updates */ ++ results = pk_task_get_updates_sync (PK_TASK (task), 0, cancellable, ++ (PkProgressCallback) pk_console_progress_cb, NULL, ++ error); ++ if (results == NULL) { ++ ret = FALSE; ++ goto out; ++ } ++ ++ /* do the async action */ ++ sack = pk_results_get_package_sack (results); ++ package_ids = pk_package_sack_get_ids (sack); ++ pk_task_update_packages_async (PK_TASK(task), package_ids, cancellable, ++ (PkProgressCallback) pk_console_progress_cb, NULL, ++ (GAsyncReadyCallback) pk_console_finished_cb, NULL); ++out: ++ if (sack != NULL) ++ g_object_unref (sack); ++ if (results != NULL) ++ g_object_unref (results); ++ g_strfreev (package_ids); ++ return ret; ++} ++ ++/** + * pk_console_get_requires: + **/ + static gboolean +@@ -1565,9 +1600,7 @@ main (int argc, char *argv[]) + } else if (strcmp (mode, "update") == 0) { + if (value == NULL) { + /* do the system update */ +- pk_task_update_system_async (PK_TASK(task), cancellable, +- (PkProgressCallback) pk_console_progress_cb, NULL, +- (GAsyncReadyCallback) pk_console_finished_cb, NULL); ++ nowait = !pk_console_update_system (&error); + } else { + nowait = !pk_console_update_packages (argv+2, &error); + } diff --git a/contrib/systemd-updates/pk-offline-update.c b/contrib/systemd-updates/pk-offline-update.c index 5d6604d..a6fdaaf 100644 --- a/contrib/systemd-updates/pk-offline-update.c @@ -311,7 +368,7 @@ index b9ae2b8..477552f 100644 } diff --git a/src/pk-transaction.c b/src/pk-transaction.c -index afdd563..c5a29f1 100644 +index afdd563..1818723 100644 --- a/src/pk-transaction.c +++ b/src/pk-transaction.c @@ -689,23 +689,24 @@ pk_transaction_category_cb (PkBackend *backend, @@ -344,122 +401,81 @@ index afdd563..c5a29f1 100644 NULL); } -@@ -1106,14 +1107,75 @@ pk_transaction_set_full_paths (PkTransaction *transaction, +@@ -1058,6 +1059,18 @@ pk_transaction_get_package_ids (PkTransaction *transaction) } /** -+ * pk_transaction_get_existing_prepared_updates: ++ * pk_transaction_get_transaction_flags: ++ * ++ * Returns: transaction flags for the transaction + **/ -+static GPtrArray * -+pk_transaction_get_existing_prepared_updates (const gchar *filename) ++PkBitfield ++pk_transaction_get_transaction_flags (PkTransaction *transaction) +{ -+ gboolean ret; -+ gchar **package_ids = NULL; -+ gchar *packages_data = NULL; -+ GError *error = NULL; -+ GPtrArray *packages; -+ guint i; -+ -+ /* always return a valid array, even for failure */ -+ packages = g_ptr_array_new_with_free_func (g_free); -+ -+ /* does the file exist ? */ -+ if (!g_file_test (filename, G_FILE_TEST_EXISTS)) -+ goto out; -+ -+ /* get the list of packages to update */ -+ ret = g_file_get_contents (filename, -+ &packages_data, -+ NULL, -+ &error); -+ if (!ret) { -+ g_warning ("failed to read: %s", error->message); -+ g_error_free (error); -+ goto out; -+ } -+ -+ /* add them to the new array */ -+ package_ids = g_strsplit (packages_data, "\n", -1); -+ for (i = 0; package_ids[i] != NULL; i++) -+ g_ptr_array_add (packages, g_strdup (package_ids[i])); -+out: -+ g_free (packages_data); -+ g_strfreev (package_ids); -+ return packages; -+} -+ -+/** -+ * pk_transaction_array_str_exists: -+ **/ -+static gboolean -+pk_transaction_array_str_exists (GPtrArray *array, const gchar *str) -+{ -+ guint i; -+ const gchar *tmp; -+ for (i = 0; i < array->len; i++) { -+ tmp = g_ptr_array_index (array, i); -+ if (g_strcmp0 (tmp, str) == 0) -+ return TRUE; -+ } -+ return FALSE; ++ g_return_val_if_fail (PK_IS_TRANSACTION (transaction), 0); ++ return transaction->priv->cached_transaction_flags; +} + +/** - * pk_transaction_write_prepared_file: + * pk_transaction_set_package_ids: **/ - static void - pk_transaction_write_prepared_file (PkTransaction *transaction) - { - gboolean ret; -+ gchar **package_ids; -+ gchar *packages_str = NULL; - gchar *path; - GError *error = NULL; -+ GPtrArray *packages; -+ guint i; - - /* not interesting to us */ - if (transaction->priv->role != PK_ROLE_ENUM_UPDATE_PACKAGES && -@@ -1121,14 +1183,28 @@ pk_transaction_write_prepared_file (PkTransaction *transaction) - return; - } + void +@@ -1106,40 +1119,6 @@ pk_transaction_set_full_paths (PkTransaction *transaction, + } + /** +- * pk_transaction_write_prepared_file: +- **/ +-static void +-pk_transaction_write_prepared_file (PkTransaction *transaction) +-{ +- gboolean ret; +- gchar *path; +- GError *error = NULL; +- +- /* not interesting to us */ +- if (transaction->priv->role != PK_ROLE_ENUM_UPDATE_PACKAGES && +- transaction->priv->role != PK_ROLE_ENUM_UPDATE_SYSTEM) { +- return; +- } +- - /* write filename */ -+ /* get the existing prepared updates */ - path = g_build_filename (LOCALSTATEDIR, - "lib", - "PackageKit", - "prepared-update", - NULL); -+ packages = pk_transaction_get_existing_prepared_updates (path); -+ -+ /* add any new ones */ -+ package_ids = transaction->priv->cached_package_ids; -+ for (i = 0; package_ids[i] != NULL; i++) { -+ if (!pk_transaction_array_str_exists (packages, package_ids[i])) { -+ g_ptr_array_add (packages, -+ g_strdup (package_ids[i])); -+ } -+ } -+ g_ptr_array_add (packages, NULL); -+ -+ /* write filename */ -+ packages_str = g_strjoinv ("\n", (gchar **) packages->pdata); - ret = g_file_set_contents (path, +- path = g_build_filename (LOCALSTATEDIR, +- "lib", +- "PackageKit", +- "prepared-update", +- NULL); +- ret = g_file_set_contents (path, - pk_role_enum_to_string (transaction->priv->role), -+ packages_str, - -1, - &error); - if (!ret) { -@@ -1136,6 +1212,7 @@ pk_transaction_write_prepared_file (PkTransaction *transaction) - path, error->message); - g_error_free (error); - } -+ g_free (packages_str); - g_free (path); - } - -@@ -1751,7 +1828,7 @@ pk_transaction_transaction_cb (PkTransactionDb *tdb, +- -1, +- &error); +- if (!ret) { +- g_warning ("failed to write %s: %s", +- path, error->message); +- g_error_free (error); +- } +- g_free (path); +-} +- +-/** + * pk_transaction_finished_cb: + **/ + static void +@@ -1244,13 +1223,6 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit_enum, PkTransact + if (exit_enum == PK_EXIT_ENUM_SUCCESS) + pk_transaction_db_action_time_reset (transaction->priv->transaction_db, transaction->priv->role); + +- /* write notification files if anything is pending */ +- if (exit_enum == PK_EXIT_ENUM_SUCCESS && +- pk_bitfield_contain (transaction->priv->cached_transaction_flags, +- PK_TRANSACTION_FLAG_ENUM_ONLY_DOWNLOAD)) { +- pk_transaction_write_prepared_file (transaction); +- } +- + /* did we finish okay? */ + if (exit_enum == PK_EXIT_ENUM_SUCCESS) + pk_transaction_db_set_finished (transaction->priv->transaction_db, transaction->priv->tid, TRUE, time_ms); +@@ -1751,7 +1723,7 @@ pk_transaction_transaction_cb (PkTransactionDb *tdb, transaction->priv->tid, PK_DBUS_INTERFACE_TRANSACTION, "Transaction", @@ -468,7 +484,7 @@ index afdd563..c5a29f1 100644 tid, timespec, succeeded, -@@ -2880,6 +2957,21 @@ pk_transaction_obtain_authorization (PkTransaction *transaction, +@@ -2880,6 +2852,21 @@ pk_transaction_obtain_authorization (PkTransaction *transaction, g_return_val_if_fail (priv->sender != NULL, FALSE); @@ -483,14 +499,14 @@ index afdd563..c5a29f1 100644 + PK_TRANSACTION_ERROR_COMMIT_FAILED, + "Could not commit to a transaction object"); + pk_transaction_release_tid (transaction); -+ goto out; + } ++ goto out; + } + /* we should always have subject */ if (priv->subject == NULL) { g_set_error (error, PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_REFUSED_BY_POLICY, -@@ -3029,6 +3121,18 @@ pk_transaction_get_role (PkTransaction *transaction) +@@ -3029,6 +3016,18 @@ pk_transaction_get_role (PkTransaction *transaction) } /** @@ -509,7 +525,7 @@ index afdd563..c5a29f1 100644 * pk_transaction_dbus_return: **/ static void -@@ -3065,7 +3169,6 @@ pk_transaction_accept_eula (PkTransaction *transaction, +@@ -3065,7 +3064,6 @@ pk_transaction_accept_eula (PkTransaction *transaction, g_return_if_fail (PK_IS_TRANSACTION (transaction)); g_return_if_fail (transaction->priv->tid != NULL); @@ -517,7 +533,7 @@ index afdd563..c5a29f1 100644 g_variant_get (params, "(&s)", &eula_id); -@@ -3077,6 +3180,8 @@ pk_transaction_accept_eula (PkTransaction *transaction, +@@ -3077,6 +3075,8 @@ pk_transaction_accept_eula (PkTransaction *transaction, goto out; } @@ -526,7 +542,7 @@ index afdd563..c5a29f1 100644 /* try to get authorization */ ret = pk_transaction_obtain_authorization (transaction, PK_ROLE_ENUM_ACCEPT_EULA, -@@ -3319,7 +3424,7 @@ pk_transaction_download_packages (PkTransaction *transaction, +@@ -3319,7 +3319,7 @@ pk_transaction_download_packages (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_package_ids = g_strdupv (package_ids); transaction->priv->cached_directory = g_strdup (directory); @@ -535,7 +551,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -3360,7 +3465,7 @@ pk_transaction_get_categories (PkTransaction *transaction, +@@ -3360,7 +3360,7 @@ pk_transaction_get_categories (PkTransaction *transaction, goto out; } @@ -544,7 +560,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -3434,7 +3539,7 @@ pk_transaction_get_depends (PkTransaction *transaction, +@@ -3434,7 +3434,7 @@ pk_transaction_get_depends (PkTransaction *transaction, transaction->priv->cached_filters = filter; transaction->priv->cached_package_ids = g_strdupv (package_ids); transaction->priv->cached_force = recursive; @@ -553,7 +569,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -3504,7 +3609,7 @@ pk_transaction_get_details (PkTransaction *transaction, +@@ -3504,7 +3504,7 @@ pk_transaction_get_details (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_package_ids = g_strdupv (package_ids); @@ -562,7 +578,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -3545,7 +3650,7 @@ pk_transaction_get_distro_upgrades (PkTransaction *transaction, +@@ -3545,7 +3545,7 @@ pk_transaction_get_distro_upgrades (PkTransaction *transaction, } /* save so we can run later */ @@ -571,7 +587,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -3613,7 +3718,7 @@ pk_transaction_get_files (PkTransaction *transaction, +@@ -3613,7 +3613,7 @@ pk_transaction_get_files (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_package_ids = g_strdupv (package_ids); @@ -580,7 +596,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -3659,7 +3764,7 @@ pk_transaction_get_packages (PkTransaction *transaction, +@@ -3659,7 +3659,7 @@ pk_transaction_get_packages (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_filters = filter; @@ -589,7 +605,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -3692,7 +3797,7 @@ pk_transaction_get_old_transactions (PkTransaction *transaction, +@@ -3692,7 +3692,7 @@ pk_transaction_get_old_transactions (PkTransaction *transaction, g_debug ("GetOldTransactions method called"); @@ -598,7 +614,7 @@ index afdd563..c5a29f1 100644 pk_transaction_db_get_list (transaction->priv->transaction_db, number); idle_id = g_idle_add ((GSourceFunc) pk_transaction_finished_idle_cb, transaction); g_source_set_name_by_id (idle_id, "[PkTransaction] finished from get-old-transactions"); -@@ -3731,7 +3836,7 @@ pk_transaction_get_repo_list (PkTransaction *transaction, +@@ -3731,7 +3731,7 @@ pk_transaction_get_repo_list (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_filters = filter; @@ -607,7 +623,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -3806,7 +3911,7 @@ pk_transaction_get_requires (PkTransaction *transaction, +@@ -3806,7 +3806,7 @@ pk_transaction_get_requires (PkTransaction *transaction, transaction->priv->cached_filters = filter; transaction->priv->cached_package_ids = g_strdupv (package_ids); transaction->priv->cached_force = recursive; @@ -616,7 +632,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -3875,7 +3980,7 @@ pk_transaction_get_update_detail (PkTransaction *transaction, +@@ -3875,7 +3875,7 @@ pk_transaction_get_update_detail (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_package_ids = g_strdupv (package_ids); @@ -625,7 +641,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -4004,7 +4109,7 @@ pk_transaction_get_updates (PkTransaction *transaction, +@@ -4004,7 +4004,7 @@ pk_transaction_get_updates (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_filters = filter; @@ -634,7 +650,7 @@ index afdd563..c5a29f1 100644 /* try and reuse cache */ ret = pk_transaction_try_emit_cache (transaction); -@@ -4166,7 +4271,7 @@ pk_transaction_install_files (PkTransaction *transaction, +@@ -4166,7 +4166,7 @@ pk_transaction_install_files (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_transaction_flags = transaction_flags; transaction->priv->cached_full_paths = g_strdupv (full_paths); @@ -643,7 +659,7 @@ index afdd563..c5a29f1 100644 /* try to get authorization */ ret = pk_transaction_obtain_authorization (transaction, -@@ -4239,7 +4344,7 @@ pk_transaction_install_packages (PkTransaction *transaction, +@@ -4239,7 +4239,7 @@ pk_transaction_install_packages (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_transaction_flags = transaction_flags; transaction->priv->cached_package_ids = g_strdupv (package_ids); @@ -652,7 +668,7 @@ index afdd563..c5a29f1 100644 /* try to get authorization */ ret = pk_transaction_obtain_authorization (transaction, -@@ -4309,7 +4414,7 @@ pk_transaction_install_signature (PkTransaction *transaction, +@@ -4309,7 +4309,7 @@ pk_transaction_install_signature (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_package_id = g_strdup (package_id); transaction->priv->cached_key_id = g_strdup (key_id); @@ -661,7 +677,7 @@ index afdd563..c5a29f1 100644 /* try to get authorization */ ret = pk_transaction_obtain_authorization (transaction, -@@ -4357,7 +4462,7 @@ pk_transaction_refresh_cache (PkTransaction *transaction, +@@ -4357,7 +4357,7 @@ pk_transaction_refresh_cache (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_force = force; @@ -670,7 +686,7 @@ index afdd563..c5a29f1 100644 /* try to get authorization */ ret = pk_transaction_obtain_authorization (transaction, -@@ -4435,7 +4540,7 @@ pk_transaction_remove_packages (PkTransaction *transaction, +@@ -4435,7 +4435,7 @@ pk_transaction_remove_packages (PkTransaction *transaction, transaction->priv->cached_package_ids = g_strdupv (package_ids); transaction->priv->cached_allow_deps = allow_deps; transaction->priv->cached_autoremove = autoremove; @@ -679,7 +695,7 @@ index afdd563..c5a29f1 100644 /* try to get authorization */ ret = pk_transaction_obtain_authorization (transaction, -@@ -4491,7 +4596,7 @@ pk_transaction_repo_enable (PkTransaction *transaction, +@@ -4491,7 +4491,7 @@ pk_transaction_repo_enable (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_repo_id = g_strdup (repo_id); transaction->priv->cached_enabled = enabled; @@ -688,7 +704,7 @@ index afdd563..c5a29f1 100644 /* try to get authorization */ ret = pk_transaction_obtain_authorization (transaction, -@@ -4550,7 +4655,7 @@ pk_transaction_repo_set_data (PkTransaction *transaction, +@@ -4550,7 +4550,7 @@ pk_transaction_repo_set_data (PkTransaction *transaction, transaction->priv->cached_repo_id = g_strdup (repo_id); transaction->priv->cached_parameter = g_strdup (parameter); transaction->priv->cached_value = g_strdup (value); @@ -697,7 +713,7 @@ index afdd563..c5a29f1 100644 /* try to get authorization */ ret = pk_transaction_obtain_authorization (transaction, -@@ -4630,7 +4735,7 @@ pk_transaction_resolve (PkTransaction *transaction, +@@ -4630,7 +4630,7 @@ pk_transaction_resolve (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_package_ids = g_strdupv (packages); transaction->priv->cached_filters = filter; @@ -706,7 +722,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -4687,7 +4792,7 @@ pk_transaction_search_details (PkTransaction *transaction, +@@ -4687,7 +4687,7 @@ pk_transaction_search_details (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_filters = filter; transaction->priv->cached_values = g_strdupv (values); @@ -715,7 +731,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -4754,7 +4859,7 @@ pk_transaction_search_files (PkTransaction *transaction, +@@ -4754,7 +4754,7 @@ pk_transaction_search_files (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_filters = filter; transaction->priv->cached_values = g_strdupv (values); @@ -724,7 +740,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -4821,7 +4926,7 @@ pk_transaction_search_groups (PkTransaction *transaction, +@@ -4821,7 +4821,7 @@ pk_transaction_search_groups (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_filters = filter; transaction->priv->cached_values = g_strdupv (values); @@ -733,7 +749,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -4877,7 +4982,7 @@ pk_transaction_search_names (PkTransaction *transaction, +@@ -4877,7 +4877,7 @@ pk_transaction_search_names (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_filters = filter; transaction->priv->cached_values = g_strdupv (values); @@ -742,7 +758,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -5112,7 +5217,7 @@ pk_transaction_update_packages (PkTransaction *transaction, +@@ -5112,7 +5112,7 @@ pk_transaction_update_packages (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_transaction_flags = transaction_flags; transaction->priv->cached_package_ids = g_strdupv (package_ids); @@ -751,7 +767,7 @@ index afdd563..c5a29f1 100644 /* try to get authorization */ ret = pk_transaction_obtain_authorization (transaction, -@@ -5165,7 +5270,7 @@ pk_transaction_update_system (PkTransaction *transaction, +@@ -5165,7 +5165,7 @@ pk_transaction_update_system (PkTransaction *transaction, } transaction->priv->cached_transaction_flags = transaction_flags; @@ -760,7 +776,7 @@ index afdd563..c5a29f1 100644 /* try to get authorization */ ret = pk_transaction_obtain_authorization (transaction, -@@ -5225,7 +5330,7 @@ pk_transaction_what_provides (PkTransaction *transaction, +@@ -5225,7 +5225,7 @@ pk_transaction_what_provides (PkTransaction *transaction, transaction->priv->cached_filters = filter; transaction->priv->cached_values = g_strdupv (values); transaction->priv->cached_provides = provides; @@ -769,7 +785,7 @@ index afdd563..c5a29f1 100644 /* try to commit this */ ret = pk_transaction_commit (transaction); -@@ -5274,7 +5379,7 @@ pk_transaction_upgrade_system (PkTransaction *transaction, +@@ -5274,7 +5274,7 @@ pk_transaction_upgrade_system (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_value = g_strdup (distro_id); transaction->priv->cached_provides = upgrade_kind; @@ -778,7 +794,7 @@ index afdd563..c5a29f1 100644 /* try to get authorization */ ret = pk_transaction_obtain_authorization (transaction, -@@ -5319,7 +5424,7 @@ pk_transaction_repair_system (PkTransaction *transaction, +@@ -5319,7 +5319,7 @@ pk_transaction_repair_system (PkTransaction *transaction, /* save so we can run later */ transaction->priv->cached_transaction_flags = transaction_flags; @@ -787,6 +803,42 @@ index afdd563..c5a29f1 100644 /* try to get authorization */ ret = pk_transaction_obtain_authorization (transaction, +diff --git a/src/pk-transaction.h b/src/pk-transaction.h +index 4f247b3..79c68a5 100644 +--- a/src/pk-transaction.h ++++ b/src/pk-transaction.h +@@ -82,6 +82,7 @@ void pk_transaction_set_backend (PkTransaction *transaction, + PkBackend *backend); + PkResults *pk_transaction_get_results (PkTransaction *transaction); + gchar **pk_transaction_get_package_ids (PkTransaction *transaction); ++PkBitfield pk_transaction_get_transaction_flags (PkTransaction *transaction); + void pk_transaction_set_package_ids (PkTransaction *transaction, + gchar **package_ids); + gchar **pk_transaction_get_values (PkTransaction *transaction); +diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am +index c1bf30d..f693c2c 100644 +--- a/src/plugins/Makefile.am ++++ b/src/plugins/Makefile.am +@@ -58,6 +58,7 @@ plugin_LTLIBRARIES = \ + libpk_plugin-update-package-cache.la \ + libpk_plugin-no-update-process.la \ + libpk_plugin-scan-desktop-files.la \ ++ libpk_plugin-systemd-updates.la \ + libpk_plugin-update-check-processes.la \ + libpk_plugin-check-shared-libraries-in-use.la \ + libpk_plugin-clear-system-update.la \ +@@ -68,6 +69,11 @@ libpk_plugin_example_la_LIBADD = $(PK_PLUGIN_LIBS) + libpk_plugin_example_la_LDFLAGS = -module -avoid-version + libpk_plugin_example_la_CFLAGS = $(PK_PLUGIN_CFLAGS) $(WARNINGFLAGS_C) + ++libpk_plugin_systemd_updates_la_SOURCES = pk-plugin-systemd-updates.c ++libpk_plugin_systemd_updates_la_LIBADD = $(PK_PLUGIN_LIBS) ++libpk_plugin_systemd_updates_la_LDFLAGS = -module -avoid-version ++libpk_plugin_systemd_updates_la_CFLAGS = $(PK_PLUGIN_CFLAGS) $(WARNINGFLAGS_C) ++ + libpk_plugin_scripts_la_SOURCES = pk-plugin-scripts.c + libpk_plugin_scripts_la_LIBADD = $(PK_PLUGIN_LIBS) + libpk_plugin_scripts_la_LDFLAGS = -module -avoid-version diff --git a/src/plugins/pk-plugin-clear-firmware-requests.c b/src/plugins/pk-plugin-clear-firmware-requests.c index 8b4216a..f9326f4 100644 --- a/src/plugins/pk-plugin-clear-firmware-requests.c @@ -800,3 +852,171 @@ index 8b4216a..f9326f4 100644 g_debug ("clearing udev firmware requests at %s", filename); ret = pk_directory_remove_contents (filename); if (!ret) +diff --git a/src/plugins/pk-plugin-systemd-updates.c b/src/plugins/pk-plugin-systemd-updates.c +new file mode 100644 +index 0000000..b0abc8d +--- /dev/null ++++ b/src/plugins/pk-plugin-systemd-updates.c +@@ -0,0 +1,162 @@ ++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- ++ * ++ * Copyright (C) 2012 Richard Hughes ++ * ++ * Licensed under the GNU General Public License Version 2 ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ */ ++ ++#include ++#include ++#include ++ ++/** ++ * pk_plugin_get_description: ++ */ ++const gchar * ++pk_plugin_get_description (void) ++{ ++ return "A plugin to write the prepared-updates file"; ++} ++ ++/** ++ * pk_plugin_get_existing_prepared_updates: ++ **/ ++static GPtrArray * ++pk_plugin_get_existing_prepared_updates (const gchar *filename) ++{ ++ gboolean ret; ++ gchar **package_ids = NULL; ++ gchar *packages_data = NULL; ++ GError *error = NULL; ++ GPtrArray *packages; ++ guint i; ++ ++ /* always return a valid array, even for failure */ ++ packages = g_ptr_array_new_with_free_func (g_free); ++ ++ /* does the file exist ? */ ++ if (!g_file_test (filename, G_FILE_TEST_EXISTS)) ++ goto out; ++ ++ /* get the list of packages to update */ ++ ret = g_file_get_contents (filename, ++ &packages_data, ++ NULL, ++ &error); ++ if (!ret) { ++ g_warning ("failed to read: %s", error->message); ++ g_error_free (error); ++ goto out; ++ } ++ ++ /* add them to the new array */ ++ package_ids = g_strsplit (packages_data, "\n", -1); ++ for (i = 0; package_ids[i] != NULL; i++) ++ g_ptr_array_add (packages, g_strdup (package_ids[i])); ++out: ++ g_free (packages_data); ++ g_strfreev (package_ids); ++ return packages; ++} ++ ++/** ++ * pk_plugin_array_str_exists: ++ **/ ++static gboolean ++pk_plugin_array_str_exists (GPtrArray *array, const gchar *str) ++{ ++ guint i; ++ const gchar *tmp; ++ for (i = 0; i < array->len; i++) { ++ tmp = g_ptr_array_index (array, i); ++ if (g_strcmp0 (tmp, str) == 0) ++ return TRUE; ++ } ++ return FALSE; ++} ++ ++/** ++ * pk_plugin_transaction_finished_end: ++ */ ++void ++pk_plugin_transaction_finished_end (PkPlugin *plugin, ++ PkTransaction *transaction) ++{ ++ gboolean ret; ++ gchar **package_ids; ++ gchar *packages_str = NULL; ++ gchar *path = NULL; ++ GError *error = NULL; ++ GPtrArray *packages; ++ guint i; ++ PkBitfield transaction_flags; ++ PkExitEnum exit_enum; ++ PkResults *results; ++ PkRoleEnum role; ++ ++ /* check the role */ ++ role = pk_transaction_get_role (transaction); ++ if (role != PK_ROLE_ENUM_UPDATE_PACKAGES) ++ goto out; ++ ++ /* check for success */ ++ results = pk_transaction_get_results (transaction); ++ exit_enum = pk_results_get_exit_code (results); ++ if (exit_enum != PK_EXIT_ENUM_SUCCESS) ++ goto out; ++ ++ /* only write the file for only-download */ ++ transaction_flags = pk_transaction_get_transaction_flags (transaction); ++ if (!pk_bitfield_contain (transaction_flags, ++ PK_TRANSACTION_FLAG_ENUM_ONLY_DOWNLOAD)) ++ return; ++ ++ /* get the existing prepared updates */ ++ path = g_build_filename (LOCALSTATEDIR, ++ "lib", ++ "PackageKit", ++ "prepared-update", ++ NULL); ++ packages = pk_plugin_get_existing_prepared_updates (path); ++ ++ /* add any new ones */ ++ package_ids = pk_transaction_get_package_ids (transaction); ++ for (i = 0; package_ids[i] != NULL; i++) { ++ if (!pk_plugin_array_str_exists (packages, package_ids[i])) { ++ g_ptr_array_add (packages, ++ g_strdup (package_ids[i])); ++ } ++ } ++ g_ptr_array_add (packages, NULL); ++ ++ /* write filename */ ++ packages_str = g_strjoinv ("\n", (gchar **) packages->pdata); ++ ret = g_file_set_contents (path, ++ packages_str, ++ -1, ++ &error); ++ if (!ret) { ++ g_warning ("failed to write %s: %s", ++ path, error->message); ++ g_error_free (error); ++ goto out; ++ } ++out: ++ g_free (packages_str); ++ g_free (path); ++ return; ++} diff --git a/PackageKit.spec b/PackageKit.spec index 088c147..81e4cdd 100644 --- a/PackageKit.spec +++ b/PackageKit.spec @@ -3,7 +3,7 @@ Summary: Package management service Name: PackageKit Version: 0.8.1 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2+ and LGPLv2+ URL: http://www.packagekit.org Source0: http://www.packagekit.org/releases/%{name}-%{version}.tar.xz @@ -472,6 +472,9 @@ update-mime-database %{_datadir}/mime &> /dev/null || : %{_libdir}/pkgconfig/packagekit-plugin.pc %changelog +* Mon Jul 02 2012 Richard Hughes - 0.8.1-4 +- Fix several reported problems with the offline-update funtionality. + * Fri Jun 29 2012 Richard Hughes - 0.8.1-3 - Fix several reported problems with the offline-update funtionality.