Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Lachu:SystemServices
Lachu-PackageKit
0033-Nice-dependency-solving-tool-output-format...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0033-Nice-dependency-solving-tool-output-formating.patch of Package Lachu-PackageKit
From 1b68bc5d0468baeeb692c3cb7c015f1bb064b88e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= <slawek@lach.art.pl> Date: Tue, 25 May 2021 15:49:42 +0200 Subject: [PATCH 33/46] - Nice dependency solving tool output formating - Remove bugs in dependency formating tool, causing bad number of checkbox generated and bug causes html code are part of checkbox - Remove bug causing messages do not appear - Add Processing message - Code cleanup - Dependency handling code refactorization - Added message in case, when communication with helper is broken - remove dead code - show message, when nothing to do - partially added code to show message, when some errors ocours on depdendency handling process - reverted change with adding task to do if called from dependnecy-handling-code --- backends/zypp/pk-backend-zypp.cpp | 194 ++++++++++---------------- helpers/dependency-solving-helper.cpp | 111 ++++++++------- 2 files changed, 132 insertions(+), 173 deletions(-) diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp index 9e81f4fc4..685076664 100644 --- a/backends/zypp/pk-backend-zypp.cpp +++ b/backends/zypp/pk-backend-zypp.cpp @@ -592,20 +592,6 @@ class PkBackendZYppPrivate { std::vector<std::string> signatures; EventDirector eventDirector; PkBackendJob *currentJob; -#if 0 - bool isBonsoleInit; - ResolverProblemList::iterator it; - ProblemSolutionList* sol_it; - char *sender; - - - std::list<std::string> to_install; - std::list<std::string> to_remove; - - std::list<struct problem> problems; - bool first_run; - -#endif pthread_mutex_t zypp_mutex; }; @@ -1490,18 +1476,7 @@ zypp_backend_pool_item_notify (PkBackendJob *job, /** * simulate, or perform changes in pool to the system */ -/* LIBXML/LIBXSLT includes - remove unnecessary in future */ -#include <libxml/xmlmemory.h> -#include <libxml/debugXML.h> -#include <libxml/HTMLtree.h> -#include <libxml/xmlIO.h> -#include <libxml/DOCBparser.h> -#include <libxml/xinclude.h> -#include <libxml/catalog.h> -#include <libxslt/xslt.h> -#include <libxslt/xsltInternals.h> -#include <libxslt/transform.h> -#include <libxslt/xsltutils.h> + struct reader_info { char *buffer; int curr_old; @@ -1534,7 +1509,7 @@ static void add_resolution_to_zypp(struct msg_proc_helper *helper) if (NULL == helper) { - return; + return; } std::list<struct problem>::iterator it = helper->problems2->begin(); @@ -1542,9 +1517,9 @@ static void add_resolution_to_zypp(struct msg_proc_helper *helper) for (; it != helper->problems2->end(); ++it) { ResolverProblemList::iterator it2 = helper->problems.begin(); - + for (; it2 != helper->problems.end(); ++it2) { - + if ((*it2)->description() == (*it).kind) { break; @@ -1552,10 +1527,10 @@ static void add_resolution_to_zypp(struct msg_proc_helper *helper) } if (it2 == helper->problems.end()) { - - continue; + + continue; } - +// ProblemSolutionList::const_iterator it3; ResolverProblem problem = **it2; it3 = problem.solutions().begin(); @@ -1977,26 +1952,23 @@ dependency_handle_selection(GIOChannel *source, gpointer data) { + + + struct backend_job_private *msg_proc = (struct backend_job_private*) data; if (G_IO_IN != (G_IO_IN & condition)) { if (G_IO_ERR == (G_IO_ERR & condition) || G_IO_HUP == (G_IO_HUP & condition) || G_IO_NVAL == (G_IO_NVAL & condition)) { + pk_backend_job_error_code (msg_proc->job, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "Error when handling dependency. PIPE problem"); return FALSE; } return TRUE; } - - - #if 0 -helper->problems2.push_back(prob); -#endif -struct backend_job_private *msg_proc = (struct backend_job_private*) data; int fd = g_io_channel_unix_get_fd (source); - //fcntl(fd, F_SETFL, O_NONBLOCK); int flags = fcntl(fd, F_GETFL, 0); fcntl(fd, F_SETFL, flags | O_NONBLOCK); char *buffer ; @@ -2045,7 +2017,6 @@ struct backend_job_private *msg_proc = (struct backend_job_private*) data; it2, solution_number); ProblemSolution solution = **it2; - // msg_proc->msg_proc_helper->solution_list->push_back(*it2); struct problem rproblem; @@ -2069,6 +2040,7 @@ struct backend_job_private *msg_proc = (struct backend_job_private*) data; } else if (0 == strncmp("DONE!", buffer, sizeof("DONE!") - 1)) { /* Save resolution to file */ + add_resolution_to_zypp(msg_proc->msg_proc_helper); save_transaction_to_cache("Install", msg_proc->msg_proc_helper->path_to_cache, msg_proc->msg_proc_helper, msg_proc->to_install, msg_proc->to_remove); @@ -2202,7 +2174,7 @@ zypp_perform_execution (PkBackendJob *job, ZYpp::Ptr zypp, PerformType type, gbo - + struct backend_job_private *rjob = (struct backend_job_private*) pk_backend_job_get_priv_data (job); try { try { if (force) @@ -2218,8 +2190,10 @@ zypp_perform_execution (PkBackendJob *job, ZYpp::Ptr zypp, PerformType type, gbo ResPool pool = ResPool::instance (); test: + if (rjob) + add_resolution_to_zypp(rjob->msg_proc_helper); if (!zypp->resolver ()->resolvePool ()) { - +#if 0 if (! pk_backend_job_get_interactive(job)) { ResolverProblemList problems = zypp->resolver ()->problems (); gchar * emsg = NULL, * tempmsg = NULL; @@ -2247,10 +2221,10 @@ zypp_perform_execution (PkBackendJob *job, ZYpp::Ptr zypp, PerformType type, gbo goto exit; } - +#endif ResolverProblemList list = zypp->resolver()->problems(); - struct backend_job_private *rjob = (struct backend_job_private*) pk_backend_job_get_priv_data (job); + struct msg_proc_helper *transaction_problems; ResolverProblemList problems = zypp->resolver ()->problems (); @@ -2290,11 +2264,15 @@ zypp_perform_execution (PkBackendJob *job, ZYpp::Ptr zypp, PerformType type, gbo transaction_problems = rjob->msg_proc_helper; path_to_cache = transaction_problems->path_to_cache; + + + + } transaction_problems->problems = problems; - rjob->to_install = rjob->to_install_s; //std::list<std::string>(); - rjob->to_remove = rjob->to_remove_s; //std::list<std::string>(); + rjob->to_install = rjob->to_install_s; + rjob->to_remove = rjob->to_remove_s; rjob->problems = std::list<struct problem> (); rjob->to_install_s = std::list<std::string>(); @@ -2422,28 +2400,7 @@ zypp_perform_execution (PkBackendJob *job, ZYpp::Ptr zypp, PerformType type, gbo // Manual intervention required to resolve dependencies // TODO: Figure out what we need to do with PackageKit // to pull off interactive problem solving. -#if 0 - if (changed && NULL == rjob->msg_proc_helper) { - - if (rjob->sol_it) { - - // delete job->sol_it; - } - rjob->problems = std::list<struct problem> (); - - // rjob->sol_it = new ProblemSolutionList(); - rjob->to_install = to_install; - rjob->to_remove = to_remove; - - - add_resolution_to_zypp(transaction_problems); - /* Save resolution to file */ - save_transaction_to_cache("Install", path_to_cache, transaction_problems, - rjob->to_install, rjob->to_remove); - - goto test; - } -#endif + if (changed) { @@ -2571,35 +2528,15 @@ zypp_perform_execution (PkBackendJob *job, ZYpp::Ptr zypp, PerformType type, gbo rjob->interactively_res_init = true; goto exit; } -#if 0 - else if (!second_time) { - -#if 0 - if (! rjob->msg_proc_helper) { - rjob->msg_proc_helper = transaction_problems; - } - second_time = true; - add_resolution_to_zypp(rjob->msg_proc_helper); - goto test; -#else - second_time = true; - add_resolution_to_zypp(transaction_problems); - goto test; -#endif - } -#endif - -#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 + } struct backend_job_private *rjob = (struct backend_job_private*) pk_backend_job_get_priv_data (job); + int empty = zypp->resolver()->getTransaction().actionEmpty(); + if (NULL != rjob) { //cleaning up @@ -2610,24 +2547,26 @@ zypp_perform_execution (PkBackendJob *job, ZYpp::Ptr zypp, PerformType type, gbo close(rjob->output); if (rjob->msg_proc_helper) { - - add_resolution_to_zypp(rjob->msg_proc_helper); - apply_resoultion_from_cache(rjob, &rjob->msg_proc_helper->problems); - // FIXME: Remove cache even if it shold be persist -#if 1 - if (!pk_bitfield_contain (transaction_flags, PK_TRANSACTION_FLAG_ENUM_SIMULATE)) { + + if (!pk_bitfield_contain (transaction_flags, PK_TRANSACTION_FLAG_ENUM_SIMULATE) || empty) { unlink(rjob->msg_proc_helper->path_to_cache); } free(rjob->msg_proc_helper->path_to_cache); free(rjob->msg_proc_helper); -#endif + } } - - job->done = 1; + + + if (empty) { + + pk_backend_job_error_code (job, PK_ERROR_ENUM_INTERNAL_ERROR, "There is nothing to do. Problably action canceled by user" ); + ret = FALSE; + goto exit; + } switch (type) { case INSTALL: pk_backend_job_set_status (job, PK_STATUS_ENUM_INSTALL); @@ -2647,6 +2586,8 @@ zypp_perform_execution (PkBackendJob *job, ZYpp::Ptr zypp, PerformType type, gbo break; } + + if (pk_bitfield_contain (transaction_flags, PK_TRANSACTION_FLAG_ENUM_SIMULATE)) { ret = TRUE; @@ -2720,12 +2661,18 @@ zypp_perform_execution (PkBackendJob *job, ZYpp::Ptr zypp, PerformType type, gbo ZYppCommitResult result = zypp->commit (policy); + if (!result.attemptToModify()) { + pk_backend_job_error_code (job, PK_ERROR_ENUM_INTERNAL_ERROR, "There is nothing to do. Problably action canceled by user" ); + ret = FALSE; + goto exit; + } bool worked = result.allDone(); if (only_download) worked = result.noError(); if ( ! worked ) { + std::ostringstream todolist; char separator = '\0'; @@ -3821,6 +3768,7 @@ backend_install_files_thread (PkBackendJob *job, GVariant *params, gpointer user MIL << "Setting " << *it << " for installation" << endl; PoolItem(*it).status().setToBeInstalled(ResStatus::USER); } + job->started = TRUE; struct backend_job_private *rjob = (struct backend_job_private*) pk_backend_job_get_priv_data (job); if (NULL != rjob) { @@ -3830,7 +3778,6 @@ backend_install_files_thread (PkBackendJob *job, GVariant *params, gpointer user } } - job->started = TRUE; if (!zypp_perform_execution (job, zypp, INSTALL, FALSE, transaction_flags)) { pk_backend_job_error_code (job, PK_ERROR_ENUM_LOCAL_INSTALL_FAILED, "Could not install the rpm-file."); @@ -4068,8 +4015,9 @@ backend_install_packages_thread (PkBackendJob *job, GVariant *params, gpointer u PoolItem item(solvable); // set status to ToBeInstalled if (FALSE == job->started) { - item.status ().setToBeInstalled (ResStatus::USER); - items.push_back (item); + + item.status ().setToBeInstalled (ResStatus::USER); + items.push_back (item); } } @@ -4177,17 +4125,20 @@ backend_remove_packages_thread (PkBackendJob *job, GVariant *params, gpointer us "couldn't find package"); return; } + + PoolItem item(solvable); - if (FALSE == job->started) - if (solvable.isSystem ()) { - item.status ().setToBeUninstalled (ResStatus::USER); - items.push_back (item); - } else { - item.status ().resetTransact (ResStatus::USER); - } - } - job->started = true; - pk_backend_job_set_percentage (job, 40); + if (FALSE == job->started) { + if (solvable.isSystem ()) { + item.status ().setToBeUninstalled (ResStatus::USER); + items.push_back (item); + } else { + item.status ().resetTransact (ResStatus::USER); + } + } + } + pk_backend_job_set_percentage (job, 40); + job->started == TRUE; try { @@ -4694,10 +4645,11 @@ upgrade_system (PkBackendJob *job, } if (FALSE == job->started) { - + zypp->resolver ()->dupSetAllowVendorChange (ZConfig::instance ().solver_dupAllowVendorChange ()); - zypp->resolver ()->doUpgrade (); } + job->started == TRUE; + zypp->resolver ()->doUpgrade (); zypp_perform_execution (job, zypp, UPGRADE_SYSTEM, FALSE, transaction_flags); @@ -4757,12 +4709,10 @@ backend_update_packages_thread (PkBackendJob *job, GVariant *params, gpointer us } } - if (FALSE == job->started) { - item.status ().setToBeInstalled (ResStatus::USER); - Patch::constPtr patch = asKind<Patch>(item.resolvable ()); - zypp_check_restart (&restart, patch); - } - job->started = true; + item.status ().setToBeInstalled (ResStatus::USER); + Patch::constPtr patch = asKind<Patch>(item.resolvable ()); + zypp_check_restart (&restart, patch); + if (restart != PK_RESTART_ENUM_NONE){ pk_backend_job_require_restart (job, restart, package_ids[i]); restart = PK_RESTART_ENUM_NONE; diff --git a/helpers/dependency-solving-helper.cpp b/helpers/dependency-solving-helper.cpp index 1ee1e5ebc..6cb36819c 100644 --- a/helpers/dependency-solving-helper.cpp +++ b/helpers/dependency-solving-helper.cpp @@ -114,7 +114,7 @@ static bool show_solutions(int fd, struct reader_info *in_ch_reader) char *buffer, *prev, *curr, *prev2, *prev3; int length, length2; int problem, solution; - xmlNodePtr root, text, anchor, message, form, checkbox; + xmlNodePtr root, text, anchor, message, form, checkbox, group, header, line, content; xmlDocPtr a = bonsole_window(nullptr); root = xmlDocGetRootElement(a); @@ -127,71 +127,78 @@ static bool show_solutions(int fd, struct reader_info *in_ch_reader) problem = 0; buffer = NULL; + group= xmlNewNode( NULL, BAD_CAST "dl"); + + xmlAddChild(form, group); while ((buffer = get_record(fd, in_ch_reader)) && ('\0' != buffer[0])) { solution = 0; - text = xmlNewText(BAD_CAST buffer); - - xmlAddChild(form, text); - - - text = xmlNewNode(NULL, BAD_CAST "br"); - xmlAddChild(form, text); + text = xmlNewText(BAD_CAST buffer); + + header = xmlNewNode( NULL, BAD_CAST "dt"); + content = xmlNewNode( NULL, BAD_CAST "dd"); + xmlAddChild(header, text); + xmlAddChild(group, header); + xmlAddChild(group, content); + while ((buffer = get_record(fd, in_ch_reader)) && ('\0' != buffer[0])) { - checkbox = xmlNewNode(NULL, BAD_CAST "checkbox"); - char *prev = buffer; - char *curr = buffer; - - - while ('\0' != *curr) { + checkbox = xmlNewNode(NULL, BAD_CAST "checkbox"); + text = xmlNewNode(NULL, BAD_CAST "br"); - if ('\n' == *curr) { - - *curr = '\0'; - - text = xmlNewText(BAD_CAST prev); - xmlAddChild(checkbox, text); + xmlAddChild(content, text); + xmlAddChild(content, checkbox); + + if ('\0' != buffer[0]) { + text = xmlNewText(BAD_CAST buffer); + xmlAddChild(content, text); text = xmlNewNode(NULL, BAD_CAST "br"); - xmlAddChild(checkbox, text); - prev = curr + 1; + xmlAddChild(content, text); } - - ++curr; - } - text = xmlNewText(BAD_CAST prev); - xmlAddChild(checkbox, text); - xmlAddChild(form, checkbox); - - if ((buffer = get_record(fd, in_ch_reader)) && ('\0' != buffer[0])) { + if ((buffer = get_record(fd, in_ch_reader))&& ('\0' != buffer[0])) { + + char *startpos = strdup(buffer); + char *prev = startpos; + char *curr = prev; - char *prev = buffer; - char *curr = buffer; while ('\0' != *curr) { + while ('\0' != *curr + && '\n' != *curr) ++curr; + + if ('\n' == *curr && + '\0' == curr[1]) { - if ('\n' == *curr) { - *curr = '\0'; + curr += 2; + } + else { + *curr = '\0'; + ++curr; + } + + if ('\0' != *curr) { text = xmlNewText(BAD_CAST prev); - xmlAddChild(checkbox, text); + xmlAddChild(content, text); text = xmlNewNode(NULL, BAD_CAST "br"); - xmlAddChild(checkbox, text); - prev = curr + 1; + xmlAddChild(content, text); + prev = curr; } - - ++curr; + + } text = xmlNewText(BAD_CAST prev); - xmlAddChild(checkbox, text); + xmlAddChild(content, text); - } + if (startpos) + free(startpos); + } length = snprintf(NULL, 0, "%d_%d", problem, solution) + 1; buffer = (char*) malloc(length); snprintf(buffer, length, "%d_%d", problem, solution); @@ -199,26 +206,22 @@ static bool show_solutions(int fd, struct reader_info *in_ch_reader) xmlSetProp(checkbox, BAD_CAST "name", BAD_CAST buffer); buffer = NULL; - - ++solution; + + ++solution; + + text = xmlNewNode(NULL, BAD_CAST "br"); + xmlAddChild(content, text); - text = xmlNewNode(NULL, BAD_CAST "br"); - xmlAddChild(form, text); } - text = xmlNewNode(NULL, BAD_CAST "br"); - xmlAddChild(form, text); ++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"); + text = xmlNewText(BAD_CAST "Done. You can close this page."); message = xmlNewNode(NULL, BAD_CAST "message"); xmlAddChild(message, text); xmlAddChild(root, message); @@ -440,6 +443,12 @@ static void message_proc(const char *msg__, intptr_t usr_p) } + + xmlChar *ent = xmlEncodeEntitiesReentrant(a, BAD_CAST "Processing ..."); + + xmlNodeSetContent(app->window.message, ent); + + free(ent); bonsole_window_release(nullptr); bonsole_flush_changes(nullptr); -- 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