Blob Blame History Raw
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
index 491f044..896d32b 100755
--- a/backends/yum/yumBackend.py
+++ b/backends/yum/yumBackend.py
@@ -1787,7 +1787,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
                         return
                     self._show_package(pkg, INFO_UNTRUSTED)
                 try:
-                    self._runYumTransaction(allow_skip_broken=True, only_simulate=TRANSACTION_FLAG_SIMULATE in transaction_flags)
+                    self._runYumTransaction(transaction_flags, allow_skip_broken=True)
                 except PkError, e:
                     self.error(e.code, e.details, exit=False)
             else:
@@ -2020,7 +2020,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
                     return
                 self._show_package(pkg, INFO_UNTRUSTED)
             try:
-                self._runYumTransaction(only_simulate=TRANSACTION_FLAG_SIMULATE in transaction_flags)
+                self._runYumTransaction(transaction_flags)
             except PkError, e:
                 self.error(e.code, e.details, exit=False)
         else:
@@ -2203,7 +2203,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
                 return
 
             try:
-                self._runYumTransaction(only_simulate=TRANSACTION_FLAG_SIMULATE in transaction_flags)
+                self._runYumTransaction(transaction_flags)
             except PkError, e:
                 self.error(e.code, e.details, exit=False)
                 return
@@ -2231,7 +2231,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
                             if not self.yumbase.tsInfo.pkgSack:
                                 self.yumbase.tsInfo.pkgSack = MetaSack()
                             try:
-                                self._runYumTransaction(only_simulate=TRANSACTION_FLAG_SIMULATE in transaction_flags)
+                                self._runYumTransaction(transaction_flags)
                             except PkError, e:
                                 self.error(e.code, e.details, exit=False)
                                 return
@@ -2344,7 +2344,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
                         return
                     self._show_package(pkg, INFO_UNTRUSTED)
                 try:
-                    self._runYumTransaction(allow_skip_broken=True, only_simulate=TRANSACTION_FLAG_SIMULATE in transaction_flags)
+                    self._runYumTransaction(transaction_flags, allow_skip_broken=True)
                 except PkError, e:
                     self.error(e.code, e.details, exit=False)
             else:
@@ -2361,7 +2361,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
                 or (notice and notice.get_metadata().has_key('reboot_suggested') and notice['reboot_suggested'])):
                 self.require_restart(RESTART_SYSTEM, self._pkg_to_id(pkg))
 
-    def _runYumTransaction(self, allow_remove_deps=None, allow_skip_broken=False, only_simulate=False):
+    def _runYumTransaction(self, transaction_flags, allow_remove_deps=None, allow_skip_broken=False):
         '''
         Run the yum Transaction
         This will only work with yum 3.2.4 or higher
@@ -2409,7 +2409,7 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
             raise PkError(ERROR_TRANSACTION_ERROR, message)
 
         # abort now we have the package list
-        if only_simulate:
+        if TRANSACTION_FLAG_SIMULATE in transaction_flags:
             package_list = []
             for txmbr in self.yumbase.tsInfo:
                 if txmbr.output_state in TransactionsInfoMap.keys():
@@ -2421,6 +2421,20 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
             self.percentage(100)
             return
 
+        if TRANSACTION_FLAG_ONLY_DOWNLOAD in transaction_flags:
+            package_list = []
+            for txmbr in self.yumbase.tsInfo:
+                if txmbr.output_state in (TS_UPDATE, TS_INSTALL):
+                    self._show_package(txmbr.po, INFO_DOWNLOADING)
+                    repo = self.yumbase.repos.getRepo(txmbr.po.repoid)
+                    try:
+                        path = repo.getPackage(txmbr.po)
+                    except IOError, e:
+                        self.error(ERROR_PACKAGE_DOWNLOAD_FAILED, "Cannot write to file", exit=False)
+                        return
+            self.percentage(100)
+            return
+
         try:
             rpmDisplay = PackageKitCallback(self)
             callback = ProcessTransPackageKitCallback(self)
@@ -2529,9 +2543,9 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
                         return
             try:
                 if not allowdep:
-                    self._runYumTransaction(allow_remove_deps=False, only_simulate=TRANSACTION_FLAG_SIMULATE in transaction_flags)
+                    self._runYumTransaction(transaction_flags, allow_remove_deps=False)
                 else:
-                    self._runYumTransaction(allow_remove_deps=True, only_simulate=TRANSACTION_FLAG_SIMULATE in transaction_flags)
+                    self._runYumTransaction(transaction_flags, allow_remove_deps=True)
             except PkError, e:
                 self.error(e.code, e.details, exit=False)
         else:
@@ -3173,6 +3187,9 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
         # default to 100% unless method overrides
         self.yumbase.conf.throttle = "90%"
 
+        # do not use parallel downloading
+        self.yumbase.conf.async = False
+
     def _setup_yum(self):
         try:
             # setup Yum Config
@@ -3349,17 +3366,18 @@ class PackageKitCallback(RPMBaseCallback):
                 self.base.message(MESSAGE_BACKEND_ERROR, "The constant '%s' was unknown, please report. details: %s" % (action, _to_unicode(e)))
 
         # set item percentage
-        #if package and te_total > 0:
-        #    val = (te_current*100L)/te_total
-        #    if self.curpkg:
-        #        self.base.item_percentage(self.base._pkg_to_id(self.curpkg), val)
+        if package and te_total > 0:
+            val = (te_current*100L)/te_total
+            if self.curpkg:
+                self.base.item_percentage(self.base._pkg_to_id(self.curpkg), val)
 
-        # find out the offset
+        # find out the start offset
         pct_start = StatusPercentageMap[STATUS_INSTALL]
 
         # do percentage
         if ts_total > 0:
             div = (100 - pct_start) / ts_total
+            val = (te_current*100L)/te_total
             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
+++ b/contrib/systemd-updates/pk-offline-update.c
@@ -27,6 +27,7 @@
 
 #define PK_OFFLINE_UPDATE_RESULTS_GROUP		"PackageKit Offline Update Results"
 #define PK_OFFLINE_UPDATE_RESULTS_FILENAME	"/var/lib/PackageKit/offline-update-competed"
+#define PK_OFFLINE_PREPARED_UPDATE_FILENAME	"/var/lib/PackageKit/prepared-update"
 
 /**
  * pk_offline_update_set_plymouth_msg:
@@ -38,6 +39,9 @@ pk_offline_update_set_plymouth_msg (const gchar *msg)
 	gchar *cmd;
 	GError *error = NULL;
 
+	/* allow testing without sending commands to plymouth */
+	if (g_getenv ("PK_OFFLINE_UPDATE_TEST") != NULL)
+		return;
 	cmd = g_strdup_printf ("plymouth display-message --text=\"%s\"", msg);
 	ret = g_spawn_command_line_async (cmd, &error);
 	if (!ret) {
@@ -59,6 +63,9 @@ pk_offline_update_set_plymouth_mode (const gchar *mode)
 	GError *error = NULL;
 	gchar *cmdline;
 
+	/* allow testing without sending commands to plymouth */
+	if (g_getenv ("PK_OFFLINE_UPDATE_TEST") != NULL)
+		return;
 	cmdline = g_strdup_printf ("plymouth change-mode --%s", mode);
 	ret = g_spawn_command_line_async (cmdline, &error);
 	if (!ret) {
@@ -79,6 +86,9 @@ pk_offline_update_set_plymouth_percentage (guint percentage)
 	GError *error = NULL;
 	gchar *cmdline;
 
+	/* allow testing without sending commands to plymouth */
+	if (g_getenv ("PK_OFFLINE_UPDATE_TEST") != NULL)
+		return;
 	cmdline = g_strdup_printf ("plymouth system-update --progress=%i",
 				   percentage);
 	ret = g_spawn_command_line_async (cmdline, &error);
@@ -128,6 +138,10 @@ pk_offline_update_reboot (void)
 	GError *error = NULL;
 	GVariant *val = NULL;
 
+	/* allow testing without rebooting */
+	if (g_getenv ("PK_OFFLINE_UPDATE_TEST") != NULL)
+		return;
+
 	/* reboot using systemd */
 	pk_offline_update_set_plymouth_mode ("shutdown");
 	pk_offline_update_set_plymouth_msg ("Rebooting after installing updates...");
@@ -299,10 +313,13 @@ out:
 int
 main (int argc, char *argv[])
 {
+	gboolean ret;
+	gchar **package_ids = NULL;
+	gchar *packages_data = NULL;
 	GError *error = NULL;
 	gint retval;
-	PkTask *task = NULL;
 	PkResults *results;
+	PkTask *task = NULL;
 
 	/* setup */
 	g_type_init ();
@@ -314,16 +331,30 @@ main (int argc, char *argv[])
 		goto out;
 	}
 
+	/* get the list of packages to update */
+	ret = g_file_get_contents (PK_OFFLINE_PREPARED_UPDATE_FILENAME,
+				   &packages_data,
+				   NULL,
+				   &error);
+	if (!ret) {
+		retval = EXIT_FAILURE;
+		g_warning ("failed to read: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
 	/* just update the system */
 	task = pk_task_new ();
 	pk_task_set_interactive (task, FALSE);
 	pk_offline_update_set_plymouth_mode ("updates");
-	results = pk_client_update_system (PK_CLIENT (task),
-					   0,
-					   NULL, /* GCancellable */
-					   pk_offline_update_progress_cb,
-					   NULL, /* user_data */
-					   &error);
+	package_ids = g_strsplit (packages_data, "\n", -1);
+	results = pk_client_update_packages (PK_CLIENT (task),
+					     0,
+					     package_ids,
+					     NULL, /* GCancellable */
+					     pk_offline_update_progress_cb,
+					     NULL, /* user_data */
+					     &error);
 	if (results == NULL) {
 		retval = EXIT_FAILURE;
 		pk_offline_update_write_error (error);
@@ -332,11 +363,13 @@ main (int argc, char *argv[])
 		goto out;
 	}
 	pk_offline_update_write_results (results);
-	g_unlink ("/var/lib/PackageKit/prepared-update");
+	g_unlink (PK_OFFLINE_PREPARED_UPDATE_FILENAME);
 	retval = EXIT_SUCCESS;
 out:
 	g_unlink ("/system-update");
 	pk_offline_update_reboot ();
+	g_free (packages_data);
+	g_strfreev (package_ids);
 	if (task != NULL)
 		g_object_unref (task);
 	return retval;
diff --git a/lib/packagekit-glib2/pk-client.c b/lib/packagekit-glib2/pk-client.c
index 5613f3e..4af44a7 100644
--- a/lib/packagekit-glib2/pk-client.c
+++ b/lib/packagekit-glib2/pk-client.c
@@ -1204,7 +1204,7 @@ pk_client_signal_cb (GDBusProxy *proxy,
 	if (g_strcmp0 (signal_name, "Transaction") == 0) {
 		PkTransactionPast *item;
 		g_variant_get (parameters,
-			       "(&o&sb&su&su&s)",
+			       "(&o&sbuu&su&s)",
 			       &tmp_str[0],
 			       &tmp_str[1],
 			       &tmp_bool,
diff --git a/lib/packagekit-glib2/pk-progress.c b/lib/packagekit-glib2/pk-progress.c
index d1b7ff4..aa1b94f 100644
--- a/lib/packagekit-glib2/pk-progress.c
+++ b/lib/packagekit-glib2/pk-progress.c
@@ -266,6 +266,10 @@ pk_progress_set_role (PkProgress *progress, PkRoleEnum role)
 {
 	g_return_val_if_fail (PK_IS_PROGRESS (progress), FALSE);
 
+	/* ignore unknown as we don't want to replace a valid value */
+	if (role == PK_ROLE_ENUM_UNKNOWN)
+		return FALSE;
+
 	/* the same as before? */
 	if (progress->priv->role == role)
 		return FALSE;
diff --git a/src/pk-backend.c b/src/pk-backend.c
index b9ae2b8..477552f 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -1109,6 +1109,8 @@ pk_backend_set_item_progress (PkBackend *backend,
 			      const gchar *package_id,
 			      guint percentage)
 {
+	PkItemProgress *item;
+
 	g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
 	g_return_val_if_fail (backend->priv->loaded, FALSE);
 
@@ -1125,9 +1127,15 @@ pk_backend_set_item_progress (PkBackend *backend,
 	}
 
 	/* emit */
+	item = pk_item_progress_new ();
+	g_object_set (item,
+		      "package-id", package_id,
+		      "percentage", percentage,
+		      NULL);
 	pk_backend_call_vfunc (backend,
 			       PK_BACKEND_SIGNAL_ITEM_PROGRESS,
-			       (gpointer) package_id); //FIXME
+			       item);
+	g_object_unref (item);
 	return TRUE;
 }
 
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index afdd563..1818723 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -689,23 +689,24 @@ pk_transaction_category_cb (PkBackend *backend,
  **/
 static void
 pk_transaction_item_progress_cb (PkBackend *backend,
-				 const gchar *package_id,
-				 guint percentage,
+				 PkItemProgress *item_progress,
 				 PkTransaction *transaction)
 {
 	g_return_if_fail (PK_IS_TRANSACTION (transaction));
 	g_return_if_fail (transaction->priv->tid != NULL);
 
 	/* emit */
-	g_debug ("emitting item-progress %s, %u", package_id, percentage);
+	g_debug ("emitting item-progress %s, %u",
+		 pk_item_progress_get_package_id (item_progress),
+		 pk_item_progress_get_percentage (item_progress));
 	g_dbus_connection_emit_signal (transaction->priv->connection,
 				       NULL,
 				       transaction->priv->tid,
 				       PK_DBUS_INTERFACE_TRANSACTION,
 				       "ItemProgress",
 				       g_variant_new ("(su)",
-						      package_id,
-						      percentage),
+						      pk_item_progress_get_package_id (item_progress),
+						      pk_item_progress_get_percentage (item_progress)),
 				       NULL);
 }
 
@@ -1058,6 +1059,18 @@ pk_transaction_get_package_ids (PkTransaction *transaction)
 }
 
 /**
+ * pk_transaction_get_transaction_flags:
+ *
+ * Returns: transaction flags for the transaction
+ **/
+PkBitfield
+pk_transaction_get_transaction_flags (PkTransaction *transaction)
+{
+	g_return_val_if_fail (PK_IS_TRANSACTION (transaction), 0);
+	return transaction->priv->cached_transaction_flags;
+}
+
+/**
  * pk_transaction_set_package_ids:
  **/
 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 */
-	path = g_build_filename (LOCALSTATEDIR,
-				 "lib",
-				 "PackageKit",
-				 "prepared-update",
-				 NULL);
-	ret = g_file_set_contents (path,
-				   pk_role_enum_to_string (transaction->priv->role),
-				   -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",
-				       g_variant_new ("(osbsusus)",
+				       g_variant_new ("(osbuusus)",
 						      tid,
 						      timespec,
 						      succeeded,
@@ -2880,6 +2852,21 @@ pk_transaction_obtain_authorization (PkTransaction *transaction,
 
 	g_return_val_if_fail (priv->sender != NULL, FALSE);
 
+	/* we don't need to authenticate at all to just download packages */
+	if (pk_bitfield_contain (transaction->priv->cached_transaction_flags,
+				 PK_TRANSACTION_FLAG_ENUM_ONLY_DOWNLOAD)) {
+		g_debug ("No authentication required for only-download");
+		ret = pk_transaction_commit (transaction);
+		if (!ret) {
+			g_set_error_literal (error,
+					     PK_TRANSACTION_ERROR,
+					     PK_TRANSACTION_ERROR_COMMIT_FAILED,
+					     "Could not commit to a transaction object");
+			pk_transaction_release_tid (transaction);
+		}
+		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 +3016,18 @@ pk_transaction_get_role (PkTransaction *transaction)
 }
 
 /**
+ * pk_transaction_set_role:
+ **/
+static void
+pk_transaction_set_role (PkTransaction *transaction, PkRoleEnum role)
+{
+	transaction->priv->role = role;
+	pk_transaction_emit_property_changed (transaction,
+					      "Role",
+					      g_variant_new_uint32 (role));
+}
+
+/**
  * pk_transaction_dbus_return:
  **/
 static void
@@ -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);
-	transaction->priv->role = PK_ROLE_ENUM_ACCEPT_EULA;
 
 	g_variant_get (params, "(&s)",
 		       &eula_id);
@@ -3077,6 +3075,8 @@ pk_transaction_accept_eula (PkTransaction *transaction,
 		goto out;
 	}
 
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_ACCEPT_EULA);
+
 	/* try to get authorization */
 	ret = pk_transaction_obtain_authorization (transaction,
 						   PK_ROLE_ENUM_ACCEPT_EULA,
@@ -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);
-	transaction->priv->role = PK_ROLE_ENUM_DOWNLOAD_PACKAGES;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_DOWNLOAD_PACKAGES);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (transaction);
@@ -3360,7 +3360,7 @@ pk_transaction_get_categories (PkTransaction *transaction,
 		goto out;
 	}
 
-	transaction->priv->role = PK_ROLE_ENUM_GET_CATEGORIES;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_CATEGORIES);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (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;
-	transaction->priv->role = PK_ROLE_ENUM_GET_DEPENDS;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_DEPENDS);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (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);
-	transaction->priv->role = PK_ROLE_ENUM_GET_DETAILS;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_DETAILS);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (transaction);
@@ -3545,7 +3545,7 @@ pk_transaction_get_distro_upgrades (PkTransaction *transaction,
 	}
 
 	/* save so we can run later */
-	transaction->priv->role = PK_ROLE_ENUM_GET_DISTRO_UPGRADES;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_DISTRO_UPGRADES);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (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);
-	transaction->priv->role = PK_ROLE_ENUM_GET_FILES;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_FILES);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (transaction);
@@ -3659,7 +3659,7 @@ pk_transaction_get_packages (PkTransaction *transaction,
 
 	/* save so we can run later */
 	transaction->priv->cached_filters = filter;
-	transaction->priv->role = PK_ROLE_ENUM_GET_PACKAGES;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_PACKAGES);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (transaction);
@@ -3692,7 +3692,7 @@ pk_transaction_get_old_transactions (PkTransaction *transaction,
 
 	g_debug ("GetOldTransactions method called");
 
-	transaction->priv->role = PK_ROLE_ENUM_GET_OLD_TRANSACTIONS;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_OLD_TRANSACTIONS);
 	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 +3731,7 @@ pk_transaction_get_repo_list (PkTransaction *transaction,
 
 	/* save so we can run later */
 	transaction->priv->cached_filters = filter;
-	transaction->priv->role = PK_ROLE_ENUM_GET_REPO_LIST;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_REPO_LIST);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (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;
-	transaction->priv->role = PK_ROLE_ENUM_GET_REQUIRES;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_REQUIRES);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (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);
-	transaction->priv->role = PK_ROLE_ENUM_GET_UPDATE_DETAIL;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_UPDATE_DETAIL);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (transaction);
@@ -4004,7 +4004,7 @@ pk_transaction_get_updates (PkTransaction *transaction,
 
 	/* save so we can run later */
 	transaction->priv->cached_filters = filter;
-	transaction->priv->role = PK_ROLE_ENUM_GET_UPDATES;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_UPDATES);
 
 	/* try and reuse cache */
 	ret = pk_transaction_try_emit_cache (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);
-	transaction->priv->role = PK_ROLE_ENUM_INSTALL_FILES;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_INSTALL_FILES);
 
 	/* try to get authorization */
 	ret = pk_transaction_obtain_authorization (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);
-	transaction->priv->role = PK_ROLE_ENUM_INSTALL_PACKAGES;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_INSTALL_PACKAGES);
 
 	/* try to get authorization */
 	ret = pk_transaction_obtain_authorization (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);
-	transaction->priv->role = PK_ROLE_ENUM_INSTALL_SIGNATURE;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_INSTALL_SIGNATURE);
 
 	/* try to get authorization */
 	ret = pk_transaction_obtain_authorization (transaction,
@@ -4357,7 +4357,7 @@ pk_transaction_refresh_cache (PkTransaction *transaction,
 
 	/* save so we can run later */
 	transaction->priv->cached_force = force;
-	transaction->priv->role = PK_ROLE_ENUM_REFRESH_CACHE;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_REFRESH_CACHE);
 
 	/* try to get authorization */
 	ret = pk_transaction_obtain_authorization (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;
-	transaction->priv->role = PK_ROLE_ENUM_REMOVE_PACKAGES;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_REMOVE_PACKAGES);
 
 	/* try to get authorization */
 	ret = pk_transaction_obtain_authorization (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;
-	transaction->priv->role = PK_ROLE_ENUM_REPO_ENABLE;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_REPO_ENABLE);
 
 	/* try to get authorization */
 	ret = pk_transaction_obtain_authorization (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);
-	transaction->priv->role = PK_ROLE_ENUM_REPO_SET_DATA;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_REPO_SET_DATA);
 
 	/* try to get authorization */
 	ret = pk_transaction_obtain_authorization (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;
-	transaction->priv->role = PK_ROLE_ENUM_RESOLVE;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_RESOLVE);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (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);
-	transaction->priv->role = PK_ROLE_ENUM_SEARCH_DETAILS;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_SEARCH_DETAILS);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (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);
-	transaction->priv->role = PK_ROLE_ENUM_SEARCH_FILE;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_SEARCH_FILE);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (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);
-	transaction->priv->role = PK_ROLE_ENUM_SEARCH_GROUP;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_SEARCH_GROUP);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (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);
-	transaction->priv->role = PK_ROLE_ENUM_SEARCH_NAME;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_SEARCH_NAME);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (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);
-	transaction->priv->role = PK_ROLE_ENUM_UPDATE_PACKAGES;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_UPDATE_PACKAGES);
 
 	/* try to get authorization */
 	ret = pk_transaction_obtain_authorization (transaction,
@@ -5165,7 +5165,7 @@ pk_transaction_update_system (PkTransaction *transaction,
 	}
 
 	transaction->priv->cached_transaction_flags = transaction_flags;
-	transaction->priv->role = PK_ROLE_ENUM_UPDATE_SYSTEM;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_UPDATE_SYSTEM);
 
 	/* try to get authorization */
 	ret = pk_transaction_obtain_authorization (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;
-	transaction->priv->role = PK_ROLE_ENUM_WHAT_PROVIDES;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_WHAT_PROVIDES);
 
 	/* try to commit this */
 	ret = pk_transaction_commit (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;
-	transaction->priv->role = PK_ROLE_ENUM_UPGRADE_SYSTEM;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_UPGRADE_SYSTEM);
 
 	/* try to get authorization */
 	ret = pk_transaction_obtain_authorization (transaction,
@@ -5319,7 +5319,7 @@ pk_transaction_repair_system (PkTransaction *transaction,
 
 	/* save so we can run later */
 	transaction->priv->cached_transaction_flags = transaction_flags;
-	transaction->priv->role = PK_ROLE_ENUM_REPAIR_SYSTEM;
+	pk_transaction_set_role (transaction, PK_ROLE_ENUM_REPAIR_SYSTEM);
 
 	/* 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
+++ b/src/plugins/pk-plugin-clear-firmware-requests.c
@@ -51,6 +51,8 @@ pk_plugin_transaction_finished_end (PkPlugin *plugin,
 
 	/* clear the firmware requests directory */
 	filename = g_build_filename (LOCALSTATEDIR, "run", "PackageKit", "udev", NULL);
+	if (!g_file_test (filename, G_FILE_TEST_EXISTS))
+		goto out;
 	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 <richard@hughsie.com>
+ *
+ * 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 <config.h>
+#include <gio/gio.h>
+#include <pk-plugin.h>
+
+/**
+ * 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;
+}
commit 587b14d08196509ebf93a6bc0d1ab0fe76b6ef89
Author: Richard Hughes <richard@hughsie.com>
Date:   Thu Jul 5 15:23:37 2012 +0100

    Set the exit code before running the plugin finished handlers

diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 814ea5d..2d5e06c 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -1146,6 +1146,9 @@ pk_transaction_finished_cb (PkBackendJob *job, PkExitEnum exit_enum, PkTransacti
 		return;
 	}
 
+	/* save this so we know if the cache is valid */
+	pk_results_set_exit_code (transaction->priv->results, exit_enum);
+
 	/* run the plugins */
 	pk_transaction_plugin_phase (transaction,
 				     PK_PLUGIN_PHASE_TRANSACTION_FINISHED_START);
@@ -1158,9 +1161,6 @@ pk_transaction_finished_cb (PkBackendJob *job, PkExitEnum exit_enum, PkTransacti
 	pk_transaction_plugin_phase (transaction,
 				     PK_PLUGIN_PHASE_TRANSACTION_FINISHED_END);
 
-	/* save this so we know if the cache is valid */
-	pk_results_set_exit_code (transaction->priv->results, exit_enum);
-
 	/* if we did not send this, ensure the GUI has the right state */
 	if (transaction->priv->allow_cancel)
 		pk_transaction_allow_cancel_emit (transaction, FALSE);
commit 031540927b742eb10f52b8baa21ee6c7030b5315
Author: Richard Hughes <richard@hughsie.com>
Date:   Fri Jul 6 09:04:43 2012 +0100

    Only simulate in pkcon if only-download is not set

diff --git a/client/pk-console.c b/client/pk-console.c
index edbe593..b71e70c 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -1429,7 +1429,7 @@ main (int argc, char *argv[])
 	task = pk_task_text_new ();
 	g_object_set (task,
 		      "background", background,
-		      "simulate", !noninteractive,
+		      "simulate", !noninteractive && !only_download,
 		      "interactive", !noninteractive,
 		      "only-download", only_download,
 		      "cache-age", cache_age,
commit acf8f943676b9ee70ffba75264994c83fb2bc935
Author: Matthias Klumpp <matthias@tenstral.net>
Date:   Fri Jul 6 14:31:34 2012 +0200

    Disable package-cache by default
    
    The light-cache will stay enabled. Those who
    need the large cache can re-enable it.

diff --git a/etc/PackageKit.conf.in b/etc/PackageKit.conf.in
index 22eb467..74f0d26 100644
--- a/etc/PackageKit.conf.in
+++ b/etc/PackageKit.conf.in
@@ -133,8 +133,8 @@ ScanDesktopFiles=true
 # NOTE: Don't enable this for backends that are slow doing GetPackages()
 #       or GetDetails()
 #
-# default=true
-UpdatePackageCache=true
+# default=false
+UpdatePackageCache=false
 
 # Update the package list on PackageKit transactions
 #
commit 23704bca2c7efdbc3f4ed1f67dad90bb9eb17de0
Author: Richard Hughes <richard@hughsie.com>
Date:   Sun Jul 8 17:01:10 2012 +0100

    trivial: Print debug messages to the console when using PK_OFFLINE_UPDATE_TEST

diff --git a/contrib/systemd-updates/pk-offline-update.c b/contrib/systemd-updates/pk-offline-update.c
index a6fdaaf..ae40281 100644
--- a/contrib/systemd-updates/pk-offline-update.c
+++ b/contrib/systemd-updates/pk-offline-update.c
@@ -40,8 +40,10 @@ pk_offline_update_set_plymouth_msg (const gchar *msg)
 	GError *error = NULL;
 
 	/* allow testing without sending commands to plymouth */
-	if (g_getenv ("PK_OFFLINE_UPDATE_TEST") != NULL)
+	if (g_getenv ("PK_OFFLINE_UPDATE_TEST") != NULL) {
+		g_print ("TESTING, so not setting message: %s\n", msg);
 		return;
+	}
 	cmd = g_strdup_printf ("plymouth display-message --text=\"%s\"", msg);
 	ret = g_spawn_command_line_async (cmd, &error);
 	if (!ret) {
@@ -64,8 +66,10 @@ pk_offline_update_set_plymouth_mode (const gchar *mode)
 	gchar *cmdline;
 
 	/* allow testing without sending commands to plymouth */
-	if (g_getenv ("PK_OFFLINE_UPDATE_TEST") != NULL)
+	if (g_getenv ("PK_OFFLINE_UPDATE_TEST") != NULL) {
+		g_print ("TESTING, so not switching mode: %s\n", mode);
 		return;
+	}
 	cmdline = g_strdup_printf ("plymouth change-mode --%s", mode);
 	ret = g_spawn_command_line_async (cmdline, &error);
 	if (!ret) {
@@ -87,8 +91,10 @@ pk_offline_update_set_plymouth_percentage (guint percentage)
 	gchar *cmdline;
 
 	/* allow testing without sending commands to plymouth */
-	if (g_getenv ("PK_OFFLINE_UPDATE_TEST") != NULL)
+	if (g_getenv ("PK_OFFLINE_UPDATE_TEST") != NULL) {
+		g_print ("TESTING, so not setting percentage: %i\n", percentage);
 		return;
+	}
 	cmdline = g_strdup_printf ("plymouth system-update --progress=%i",
 				   percentage);
 	ret = g_spawn_command_line_async (cmdline, &error);
@@ -139,8 +145,10 @@ pk_offline_update_reboot (void)
 	GVariant *val = NULL;
 
 	/* allow testing without rebooting */
-	if (g_getenv ("PK_OFFLINE_UPDATE_TEST") != NULL)
+	if (g_getenv ("PK_OFFLINE_UPDATE_TEST") != NULL) {
+		g_print ("TESTING, so not rebooting\n");
 		return;
+	}
 
 	/* reboot using systemd */
 	pk_offline_update_set_plymouth_mode ("shutdown");
commit 8d8454dab3647d19f864fb533f8a7335096343bd
Author: Richard Hughes <richard@hughsie.com>
Date:   Mon Jul 9 13:29:42 2012 +0100

    systemd-updates: If the upgrade tool exits with an error reboot the system

diff --git a/contrib/systemd-updates/packagekit-offline-update.service.in b/contrib/systemd-updates/packagekit-offline-update.service.in
index 4b9440a..bff38d3 100644
--- a/contrib/systemd-updates/packagekit-offline-update.service.in
+++ b/contrib/systemd-updates/packagekit-offline-update.service.in
@@ -1,5 +1,6 @@
 [Unit]
 Description=Updates the operating system whilst offline
+OnFailure=reboot.target
 
 [Install]
 WantedBy=system-update.target
commit 281f0a286ad409c638688b3eb5d5478cf88f3dab
Author: Richard Hughes <richard@hughsie.com>
Date:   Mon Jul 9 13:42:29 2012 +0100

    systemd-updates: Be careful to not get in a reboot loop if the pk-offline-update tool crashes

diff --git a/contrib/systemd-updates/pk-offline-update.c b/contrib/systemd-updates/pk-offline-update.c
index ae40281..36972be 100644
--- a/contrib/systemd-updates/pk-offline-update.c
+++ b/contrib/systemd-updates/pk-offline-update.c
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 
 #define PK_OFFLINE_UPDATE_RESULTS_GROUP		"PackageKit Offline Update Results"
+#define PK_OFFLINE_UPDATE_TRIGGER_FILENAME	"/system-update"
 #define PK_OFFLINE_UPDATE_RESULTS_FILENAME	"/var/lib/PackageKit/offline-update-competed"
 #define PK_OFFLINE_PREPARED_UPDATE_FILENAME	"/var/lib/PackageKit/prepared-update"
 
@@ -339,6 +340,9 @@ main (int argc, char *argv[])
 		goto out;
 	}
 
+	/* always do this first to avoid a loop if this tool segfaults */
+	g_unlink (PK_OFFLINE_UPDATE_TRIGGER_FILENAME);
+
 	/* get the list of packages to update */
 	ret = g_file_get_contents (PK_OFFLINE_PREPARED_UPDATE_FILENAME,
 				   &packages_data,
@@ -374,7 +378,6 @@ main (int argc, char *argv[])
 	g_unlink (PK_OFFLINE_PREPARED_UPDATE_FILENAME);
 	retval = EXIT_SUCCESS;
 out:
-	g_unlink ("/system-update");
 	pk_offline_update_reboot ();
 	g_free (packages_data);
 	g_strfreev (package_ids);