Commit 04535a10 authored by guinux's avatar guinux

improve upgrade process

parent 6209bb2b
......@@ -57,6 +57,7 @@ namespace Pamac {
private string[] to_remove;
private string[] to_load;
private string[] to_build;
private bool sysupgrade;
private UpdateInfos[] to_build_infos;
private GLib.List<string> aur_pkgbases_to_build;
private GenericSet<string?> aur_desc_list;
......@@ -831,38 +832,50 @@ namespace Pamac {
return true;
}
private void sysupgrade_prepare () {
private bool trans_sysupgrade () {
current_error = ErrorInfos ();
bool success = trans_init (0);
if (success) {
add_ignorepkgs ();
if (alpm_handle.trans_sysupgrade ((enable_downgrade) ? 1 : 0) == -1) {
Alpm.Errno errno = alpm_handle.errno ();
current_error.errno = (uint) errno;
current_error.message = _("Failed to prepare transaction");
if (errno != 0) {
current_error.details = { Alpm.strerror (errno) };
}
trans_release_private ();
success = false;
} else {
success = trans_prepare_real ();
add_ignorepkgs ();
if (alpm_handle.trans_sysupgrade ((enable_downgrade) ? 1 : 0) == -1) {
Alpm.Errno errno = alpm_handle.errno ();
current_error.errno = (uint) errno;
current_error.message = _("Failed to prepare transaction");
if (errno != 0) {
current_error.details = { Alpm.strerror (errno) };
}
return false;
}
trans_prepare_finished (success);
return true;
}
public void start_sysupgrade_prepare (bool enable_downgrade_, string[] temporary_ignorepkgs_, GLib.BusName sender) throws Error {
public void start_sysupgrade_prepare (bool enable_downgrade_, string[] temporary_ignorepkgs_, string[] to_build_, GLib.BusName sender) throws Error {
if (lock_id != sender) {
trans_prepare_finished (false);
return;
}
enable_downgrade = enable_downgrade_;
temporary_ignorepkgs = temporary_ignorepkgs_;
try {
thread_pool.add (new AlpmAction (sysupgrade_prepare));
} catch (ThreadError e) {
stderr.printf ("Thread Error %s\n", e.message);
sysupgrade = true;
flags = 0;
to_install = {};
to_remove = {};
to_load = {};
to_build = to_build_;
to_build_infos = {};
aur_pkgbases_to_build = new GLib.List<string> ();
if (to_build.length != 0) {
compute_aur_build_list.begin (to_build, (obj, res) => {
try {
thread_pool.add (new AlpmAction (build_prepare));
} catch (ThreadError e) {
stderr.printf ("Thread Error %s\n", e.message);
}
});
} else {
try {
thread_pool.add (new AlpmAction (trans_prepare));
} catch (ThreadError e) {
stderr.printf ("Thread Error %s\n", e.message);
}
}
}
......@@ -1094,6 +1107,10 @@ namespace Pamac {
private void trans_prepare () {
bool success = trans_init (flags);
if (success && sysupgrade) {
// add upgrades to transaction
success = trans_sysupgrade ();
}
if (success) {
foreach (unowned string name in to_install) {
success = trans_add_pkg (name);
......@@ -1101,27 +1118,27 @@ namespace Pamac {
break;
}
}
if (success) {
foreach (unowned string name in to_remove) {
success = trans_remove_pkg (name);
if (!success) {
break;
}
}
if (success) {
foreach (unowned string name in to_remove) {
success = trans_remove_pkg (name);
if (!success) {
break;
}
}
if (success) {
foreach (unowned string path in to_load) {
success = trans_load_pkg (path);
if (!success) {
break;
}
}
if (success) {
foreach (unowned string path in to_load) {
success = trans_load_pkg (path);
if (!success) {
break;
}
}
if (success) {
success = trans_prepare_real ();
} else {
trans_release_private ();
}
}
if (success) {
success = trans_prepare_real ();
} else {
trans_release_private ();
}
trans_prepare_finished (success);
}
......@@ -1322,6 +1339,7 @@ namespace Pamac {
to_build = to_build_;
to_build_infos = {};
aur_pkgbases_to_build = new GLib.List<string> ();
sysupgrade = false;
if (to_build.length != 0) {
compute_aur_build_list.begin (to_build, (obj, res) => {
try {
......
......@@ -68,7 +68,7 @@ namespace Pamac {
public abstract void clean_cache (uint64 keep_nb, bool only_uninstalled) throws Error;
public abstract void start_set_pkgreason (string pkgname, uint reason) throws Error;
public abstract void start_refresh (bool force) throws Error;
public abstract void start_sysupgrade_prepare (bool enable_downgrade, string[] temporary_ignorepkgs) throws Error;
public abstract void start_sysupgrade_prepare (bool enable_downgrade, string[] temporary_ignorepkgs, string[] to_build) throws Error;
public abstract void start_trans_prepare (int transflags, string[] to_install, string[] to_remove, string[] to_load, string[] to_build) throws Error;
public abstract void choose_provider (int provider) throws Error;
public abstract TransactionSummary get_transaction_summary () throws Error;
......@@ -150,7 +150,6 @@ namespace Pamac {
bool sysupgrade_after_trans;
bool enable_downgrade;
bool no_confirm_commit;
bool build_after_sysupgrade;
bool building;
uint64 previous_xfered;
uint64 download_rate;
......@@ -239,7 +238,6 @@ namespace Pamac {
previous_filename = "";
sysupgrade_after_trans = false;
no_confirm_commit = false;
build_after_sysupgrade = false;
building = false;
timer = new Timer ();
success = false;
......@@ -814,9 +812,13 @@ namespace Pamac {
}
}
void sysupgrade_simple (bool enable_downgrade) {
void sysupgrade_real (bool enable_downgrade) {
progress_box.progressbar.fraction = 0;
string[] temporary_ignorepkgs_ = {};
string[] to_build_ = {};
foreach (unowned string name in to_build) {
to_build_ += name;
}
foreach (unowned string pkgname in temporary_ignorepkgs) {
temporary_ignorepkgs_ += pkgname;
}
......@@ -824,7 +826,7 @@ namespace Pamac {
connecting_dbus_signals ();
try {
// this will respond with trans_prepare_finished signal
system_daemon.start_sysupgrade_prepare (enable_downgrade, temporary_ignorepkgs_);
system_daemon.start_sysupgrade_prepare (enable_downgrade, temporary_ignorepkgs_, to_build_);
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
success = false;
......@@ -871,8 +873,7 @@ namespace Pamac {
}
}
if (updates.repos_updates.length != 0) {
build_after_sysupgrade = true;
sysupgrade_simple (enable_downgrade);
sysupgrade_real (enable_downgrade);
} else {
// only aur updates
// run as a standard transaction
......@@ -880,7 +881,7 @@ namespace Pamac {
}
} else {
if (updates.repos_updates.length != 0) {
sysupgrade_simple (enable_downgrade);
sysupgrade_real (enable_downgrade);
} else {
finish_transaction ();
stop_progressbar_pulse ();
......@@ -1733,10 +1734,6 @@ namespace Pamac {
this.success = false;
finish_transaction ();
}
} else if (build_after_sysupgrade) {
// there only AUR packages to build
release ();
on_trans_commit_finished (true);
} else {
//var err = ErrorInfos ();
//err.message = dgettext (null, "Nothing to do") + "\n";
......@@ -1777,11 +1774,6 @@ namespace Pamac {
if (sysupgrade_after_trans) {
sysupgrade_after_trans = false;
sysupgrade (false);
} else if (build_after_sysupgrade) {
build_after_sysupgrade = false;
disconnecting_dbus_signals ();
// build aur updates in to_build
run ();
} else {
unowned string action = dgettext (null, "Transaction successfully finished");
show_in_term (action + ".\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment