Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Lachu:SystemServices
Lachu-PackageKit
0014-Added-possibility-to-made-transaction-incl...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0014-Added-possibility-to-made-transaction-inclusive.patch of Package Lachu-PackageKit
From ffa6a183e8ddceeb1bd60ed10331ad7a8b3b4f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= <slawek@lach.art.pl> Date: Mon, 19 Oct 2020 13:41:05 +0200 Subject: [PATCH 14/46] - Added possibility to made transaction inclusive - Added method to check if transaction is in dependency solving state and invocation of this method - Make page of dependency solving look better --- helpers/dependency-solving-helper.cpp | 45 ++++++++++++++++++--------- src/pk-scheduler.c | 29 ++++++++++++++++- src/pk-transaction.c | 35 +++++++++++++++++++++ 3 files changed, 94 insertions(+), 15 deletions(-) diff --git a/helpers/dependency-solving-helper.cpp b/helpers/dependency-solving-helper.cpp index 0780cb371..89041c59c 100644 --- a/helpers/dependency-solving-helper.cpp +++ b/helpers/dependency-solving-helper.cpp @@ -146,6 +146,23 @@ static bool show_solutions(int fd, struct reader_info *in_ch_reader) char *prev = buffer; char *curr = buffer; + + while ('\0' != *curr) { + + if ('\n' == *curr) { + + *curr = '\0'; + + text = xmlNewText(BAD_CAST prev); + xmlAddChild(checkbox, text); + text = xmlNewNode(NULL, BAD_CAST "br"); + xmlAddChild(checkbox, text); + prev = curr + 1; + } + + ++curr; + } + text = xmlNewText(BAD_CAST prev); xmlAddChild(checkbox, text); @@ -195,8 +212,21 @@ static bool show_solutions(int fd, struct reader_info *in_ch_reader) } - if (0 == problem) + if (0 == problem) { + + bonsole_reset_document(nullptr); + + a = bonsole_window(nullptr); + root = xmlDocGetRootElement(a); + + text = xmlNewText(BAD_CAST "Done. You can now close this page"); + message = xmlNewNode(NULL, BAD_CAST "message"); + xmlAddChild(message, text); + xmlAddChild(root, message); + bonsole_window_release(nullptr); + bonsole_flush_changes(nullptr); return false; + } bonsole_window_release(nullptr); bonsole_flush_changes(nullptr); @@ -645,12 +675,6 @@ int main(int argc, char **argv) app.error_output = dup_2; app.messages_output = dup_1; -#if 0 -transaction_problems.problems = problems; -transaction_problems.it = problems.begin(); -transaction_problems.resolver = zypp->resolver (); -transaction_problems.solution_list = NULL; -#endif do { bonsole_reset_document(nullptr); if (!show_solutions( input, &i_ch_reader)) { @@ -679,13 +703,6 @@ if (i_ch_reader.buffer) free(i_ch_reader.buffer); reader_info_init(&i_ch_reader); } while (true); -#if 0 -add_resolution_to_zypp(&transaction_problems); - -// Save resolution to file -save_transaction_to_cache("Install", path_to_cache, &transaction_problems, - priv->to_install, priv->to_remove); -#endif exit: dup2(dup_0, 0); dup2(dup_1, 1); diff --git a/src/pk-scheduler.c b/src/pk-scheduler.c index 4980104e7..83d6b145f 100644 --- a/src/pk-scheduler.c +++ b/src/pk-scheduler.c @@ -438,6 +438,31 @@ out: return item; } +static gboolean +pk_scheduler_dependency_solving_exist(PkScheduler *scheduler) +{ + PkSchedulerItem *item = NULL; + guint i; + g_autoptr(GPtrArray) array = NULL; + PkTransactionState state; + + g_return_val_if_fail (PK_IS_SCHEDULER (scheduler), FALSE); + + /* anything running? */ + array = pk_scheduler_get_active_transactions (scheduler); + if (array->len == 0) + return FALSE; + + /* check if we have any running background transaction */ + for (i = 0; i < array->len; i++) { + item = (PkSchedulerItem *) g_ptr_array_index (array, i); + state = pk_transaction_get_state (item->transaction); + if (! pk_transaction_get_backend_job(item->transaction)->done && state == PK_TRANSACTION_STATE_RUNNING) + return TRUE; + } + return FALSE; +} + static void pk_scheduler_commit (PkScheduler *scheduler, const gchar *tid) { @@ -453,6 +478,7 @@ pk_scheduler_commit (PkScheduler *scheduler, const gchar *tid) } /* treat all transactions as exclusive if backend does not support parallelization */ + if (!pk_backend_supports_parallelization (scheduler->priv->backend)) pk_transaction_make_exclusive (item->transaction); @@ -467,8 +493,9 @@ pk_scheduler_commit (PkScheduler *scheduler, const gchar *tid) /* is one of the current running transactions background, and this new * transaction foreground? */ + if (!pk_transaction_get_background (item->transaction) && - pk_scheduler_get_background_running (scheduler)) { + pk_scheduler_get_background_running (scheduler) && !pk_scheduler_dependency_solving_exist(scheduler)) { g_debug ("cancelling running background transactions and instead running %s", item->tid); pk_scheduler_cancel_background (scheduler); diff --git a/src/pk-transaction.c b/src/pk-transaction.c index ef1176b43..d96f632fe 100644 --- a/src/pk-transaction.c +++ b/src/pk-transaction.c @@ -460,6 +460,8 @@ pk_transaction_locked_changed_cb (PkBackendJob *job, /* if backend cache is locked at some time, this transaction is running in exclusive mode */ if (locked) pk_transaction_make_exclusive (transaction); + else + pk_transaction_make_inclusive (transaction); } static void @@ -1015,7 +1017,23 @@ pk_transaction_offline_finished (PkTransaction *transaction) break; } } +#if 0 +// TODO: S.L SL LOOK HERE (pk_transaction_finished_cb) +static gboolean pk_transaction_is_user_interaction_required(PkTransaction *transaction) +{ + g_autoptr(PkError) error_code = NULL; + + g_return_val_if_fail (PK_IS_TRANSACTION (transaction), FALSE); + + error_code = pk_results_get_error_code (transaction->priv->results); + if (error_code != NULL && + pk_error_get_code (error_code) == PK_ERROR_ENUM_LOCK_REQUIRED) { + return TRUE; + } + return FALSE; +} +#endif static void pk_transaction_finished_cb (PkBackendJob *job, PkExitEnum exit_enum, PkTransaction *transaction) { @@ -1037,6 +1055,9 @@ pk_transaction_finished_cb (PkBackendJob *job, PkExitEnum exit_enum, PkTransacti /* save this so we know if the cache is valid */ pk_results_set_exit_code (transaction->priv->results, exit_enum); + + // TODO: S.L SL HERE: Wstawić kod sprawdzający czy nie oczekujemy na odpowiedź i wykonać return + /* don't really finish the transaction if we only completed to wait for lock */ if (pk_transaction_is_finished_with_lock_required (transaction)) { /* finish only for the transaction list */ @@ -1114,6 +1135,8 @@ pk_transaction_finished_cb (PkBackendJob *job, PkExitEnum exit_enum, PkTransacti pk_transaction_db_action_time_reset (transaction->priv->transaction_db, transaction->priv->role); /* did we finish okay? */ + + // TODO: S.L SL HERE if (exit_enum == PK_EXIT_ENUM_SUCCESS) pk_transaction_db_set_finished (transaction->priv->transaction_db, transaction->priv->tid, TRUE, time_ms); else @@ -1634,6 +1657,8 @@ pk_transaction_percentage_cb (PkBackendJob *job, g_variant_new_uint32 (percentage)); } + +// TODO: S.L SL HERE gboolean pk_transaction_run (PkTransaction *transaction) { @@ -1987,6 +2012,16 @@ pk_transaction_make_exclusive (PkTransaction *transaction) transaction->priv->exclusive = TRUE; } +void +pk_transaction_make_inclusive (PkTransaction *transaction) +{ + g_return_if_fail (PK_IS_TRANSACTION (transaction)); + + g_debug ("changing transaction to exclusive mode"); + + transaction->priv->exclusive = FALSE; +} + static void pk_transaction_vanished_cb (GDBusConnection *connection, const gchar *name, -- 2.32.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor