summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Kang <jonathankang@gnome.org>2019-11-06 15:58:28 +0800
committerJonathan Kang <jonathankang@gnome.org>2019-11-13 09:06:32 +0800
commit1b72dfae9a2e36677c549cdf3ba938718e082724 (patch)
tree39fc9d6d4228acf87b8aab0d22202aaf5303906e
parent6dc4d503cfab4c0270924ddf8acfefb4f06d47fa (diff)
zypp: Implement upgrade-system
"pkcon upgrade-system" is now the equivalant of "zypper dup" in openSUSE.
-rw-r--r--backends/zypp/pk-backend-zypp.cpp101
1 files changed, 65 insertions, 36 deletions
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 572c63e02..be8da6fa5 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -100,7 +100,8 @@ using zypp::filesystem::PathInfo;
typedef enum {
INSTALL,
REMOVE,
- UPDATE
+ UPDATE,
+ UPGRADE_SYSTEM
} PerformType;
typedef enum {
@@ -159,9 +160,6 @@ guint _dl_count = 0;
guint _dl_progress = 0;
guint _dl_status = 0;
-/* Timeout id for resetting upgrade mode. */
-static guint upgrade_mode_id = 0;
-
/**
* Build a package_id from the specified resolvable. The returned
* gchar * should be freed with g_free ().
@@ -1249,6 +1247,10 @@ zypp_get_package_updates (string repo, set<PoolItem> &pks)
if (s->hasInstalledObj())
pks.insert(*it);
}
+
+ if (is_tumbleweed ()) {
+ resolver->setUpgradeMode (FALSE);
+ }
}
/**
@@ -1494,6 +1496,7 @@ zypp_perform_execution (PkBackendJob *job, ZYpp::Ptr zypp, PerformType type, gbo
_dl_progress = 0;
break;
case UPDATE:
+ case UPGRADE_SYSTEM:
pk_backend_job_set_status (job, PK_STATUS_ENUM_UPDATE);
pk_backend_job_set_percentage(job, 0);
_dl_progress = 0;
@@ -1520,6 +1523,9 @@ zypp_perform_execution (PkBackendJob *job, ZYpp::Ptr zypp, PerformType type, gbo
if (it->status ().isToBeUninstalledDueToUpgrade () && !zypp->resolver()->upgradeMode())
continue;
break;
+ case UPGRADE_SYSTEM:
+ default:
+ break;
}
if (!zypp_backend_pool_item_notify (job, *it, TRUE))
@@ -2417,18 +2423,6 @@ check_for_self_update (PkBackend *backend, set<PoolItem> *candidates)
return FALSE;
}*/
-static gboolean
-reset_upgrade_mode (gpointer user_data)
-{
- PkBackendJob *job = PK_BACKEND_JOB (user_data);
- ZyppJob zjob (job);
- ZYpp::Ptr zypp = zjob.get_zypp ();
-
- zypp->resolver ()->setUpgradeMode (FALSE);
-
- return G_SOURCE_REMOVE;
-}
-
static void
backend_get_updates_thread (PkBackendJob *job, GVariant *params, gpointer user_data)
{
@@ -2496,22 +2490,6 @@ backend_get_updates_thread (PkBackendJob *job, GVariant *params, gpointer user_d
}
pk_backend_job_set_percentage (job, 100);
-
- /* We only want to set the upgrade mode to TRUE when we're
- * getting available updates and updating the system in
- * Tumbleweed. And we should reset it to FALSE after it's done
- * so that it won't impact other actions which doesn't expect
- * upgrade mode to be TRUE.
- *
- * For get-updates command, we can simply reset upgrade mode
- * when it's done. But the issue is "pkcon update" calls
- * get-updates to get a list of updates and them update those
- * packages(upgrade mode should be kept TRUE in Tumbleweed).
- *
- * To fix that, we can spawn a timeout function to reset upgrade
- * mode. We need cancel the timeout function in
- * backend_update_packages_thread(). */
- upgrade_mode_id = g_timeout_add (1000, reset_upgrade_mode, job);
}
void
@@ -3450,10 +3428,6 @@ backend_update_packages_thread (PkBackendJob *job, GVariant *params, gpointer us
ResPool pool = zypp_build_pool (zypp, TRUE);
PkRestartEnum restart = PK_RESTART_ENUM_NONE;
- if (upgrade_mode_id) {
- g_source_remove (upgrade_mode_id);
- }
-
if ( zypp->resolver()->upgradeMode() ) {
zypp->resolver()->dupSetAllowVendorChange ( ZConfig::instance().solver_dupAllowVendorChange() );
}
@@ -3515,6 +3489,61 @@ pk_backend_update_packages (PkBackend *backend, PkBackendJob *job, PkBitfield tr
}
static void
+backend_upgrade_system_thread (PkBackendJob *job,
+ GVariant *params,
+ gpointer user_data)
+{
+ PkBitfield transaction_flags = 0;
+ ZyppJob zjob (job);
+ set<PoolItem> candidates;
+
+ g_variant_get (params, "(t&su)",
+ &transaction_flags,
+ NULL,
+ NULL);
+
+ ZYpp::Ptr zypp = zjob.get_zypp ();
+ if (zypp == NULL) {
+ return;
+ }
+
+ /* refresh the repos before checking for updates. */
+ if (!zypp_refresh_cache (job, zypp, FALSE)) {
+ return;
+ }
+ zypp_build_pool (zypp, TRUE);
+ zypp_get_updates (job, zypp, candidates);
+ if (candidates.empty ()) {
+ pk_backend_job_error_code (job, PK_ERROR_ENUM_NO_DISTRO_UPGRADE_DATA,
+ "No Distribution Upgrade Available.");
+
+ return;
+ }
+
+ zypp->resolver ()->dupSetAllowVendorChange (ZConfig::instance ().solver_dupAllowVendorChange ());
+ zypp->resolver ()->doUpgrade ();
+
+ PoolStatusSaver saver;
+
+ zypp_perform_execution (job, zypp, UPGRADE_SYSTEM, FALSE, transaction_flags);
+
+ zypp->resolver ()->setUpgradeMode (FALSE);
+}
+
+/**
+ * pk_backend_upgrade_system
+ */
+void
+pk_backend_upgrade_system (PkBackend *backend,
+ PkBackendJob *job,
+ PkBitfield transaction_flags,
+ const gchar *distro_id,
+ PkUpgradeKindEnum upgrade_kind)
+{
+ pk_backend_job_thread_create (job, backend_upgrade_system_thread, NULL, NULL);
+}
+
+static void
backend_repo_set_data_thread (PkBackendJob *job, GVariant *params, gpointer user_data)
{
MIL << endl;