Exemplo n.º 1
0
/**
 * pk_plugin_transaction_finished_end:
 */
void
pk_plugin_transaction_finished_end (PkPlugin *plugin,
                                    PkTransaction *transaction)
{
    PkBitfield transaction_flags;
    PkExitEnum exit_enum;
    PkResults *results;
    PkRoleEnum role;

    /* skip simulate actions */
    if (pk_bitfield_contain (pk_transaction_get_transaction_flags (transaction),
                             PK_TRANSACTION_FLAG_ENUM_SIMULATE)) {
        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;

    /* if we're doing only-download then update prepared-updates */
    role = pk_transaction_get_role (transaction);
    transaction_flags = pk_transaction_get_transaction_flags (transaction);
    if (role == PK_ROLE_ENUM_UPDATE_PACKAGES &&
            pk_bitfield_contain (transaction_flags,
                                 PK_TRANSACTION_FLAG_ENUM_ONLY_DOWNLOAD)) {
        pk_plugin_transaction_update_packages (transaction);
        goto out;
    }

    /* if we do get-updates and there's no updates then remove
     * prepared-updates so the UI doesn't display update & reboot */
    if (role == PK_ROLE_ENUM_GET_UPDATES) {
        pk_plugin_transaction_get_updates (transaction);
        goto out;
    }

    /* delete the prepared updates file as it's no longer valid */
    if (role == PK_ROLE_ENUM_UPDATE_PACKAGES ||
            role == PK_ROLE_ENUM_INSTALL_PACKAGES ||
            role == PK_ROLE_ENUM_REMOVE_PACKAGES ||
            role == PK_ROLE_ENUM_REFRESH_CACHE) {
        pk_plugin_state_changed (plugin);
    }
out:
    return;
}
/**
 * pk_plugin_transaction_finished_end:
 */
void
pk_plugin_transaction_finished_end (PkPlugin *plugin,
				    PkTransaction *transaction)
{
	PkBitfield transaction_flags;
	PkExitEnum exit_enum;
	PkResults *results;
	PkRoleEnum role;

/* only do this if we have systemd */
#ifndef PK_BUILD_SYSTEMD
	g_debug ("No systemd, so no PreparedUpdates");
	return;
#endif

	/* skip simulate actions */
	if (pk_bitfield_contain (pk_transaction_get_transaction_flags (transaction),
				 PK_TRANSACTION_FLAG_ENUM_SIMULATE)) {
		goto out;
	}

	/* don't do anything if the method failed */
	results = pk_transaction_get_results (transaction);
	exit_enum = pk_results_get_exit_code (results);
	if (exit_enum != PK_EXIT_ENUM_SUCCESS)
		goto out;

	/* if we're doing UpdatePackages[only-download] then update the
	 * prepared-updates file */
	role = pk_transaction_get_role (transaction);
	transaction_flags = pk_transaction_get_transaction_flags (transaction);
	if (role == PK_ROLE_ENUM_UPDATE_PACKAGES &&
	    pk_bitfield_contain (transaction_flags,
				 PK_TRANSACTION_FLAG_ENUM_ONLY_DOWNLOAD)) {
		pk_plugin_transaction_update_packages (transaction);
		goto out;
	}

	/* if we do get-updates and there's no updates then remove
	 * prepared-updates so the UI doesn't display update & reboot */
	if (role == PK_ROLE_ENUM_GET_UPDATES) {
		pk_plugin_transaction_get_updates (transaction);
		goto out;
	}

	/* delete the prepared updates file as it's no longer valid */
	if (role == PK_ROLE_ENUM_REFRESH_CACHE ||
	    role == PK_ROLE_ENUM_REPO_SET_DATA ||
	    role == PK_ROLE_ENUM_REPO_ENABLE) {
		pk_plugin_state_changed (plugin);
		goto out;
	}

	/* delete the file if the action affected any package already listed in
	 * the prepared updates file */
	if (role == PK_ROLE_ENUM_UPDATE_PACKAGES ||
	    role == PK_ROLE_ENUM_INSTALL_PACKAGES ||
	    role == PK_ROLE_ENUM_REMOVE_PACKAGES) {
		pk_plugin_transaction_action_method (plugin, transaction, results);
	}
out:
	return;
}