2014-10-22 13:44:02 -03:00
|
|
|
/*
|
|
|
|
* pamac-vala
|
|
|
|
*
|
2015-03-04 11:55:36 -03:00
|
|
|
* Copyright (C) 2014-2015 Guillaume Benoit <guillaume@manjaro.org>
|
2014-10-22 13:44:02 -03:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a get of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Pamac {
|
|
|
|
[DBus (name = "org.manjaro.pamac")]
|
|
|
|
public interface Daemon : Object {
|
2015-03-04 11:55:36 -03:00
|
|
|
public abstract void start_write_pamac_config (HashTable<string,Variant> new_pamac_conf) throws IOError;
|
|
|
|
public abstract void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf) throws IOError;
|
|
|
|
public abstract void start_write_mirrors_config (HashTable<string,Variant> new_mirrors_conf) throws IOError;
|
|
|
|
public abstract void start_set_pkgreason (string pkgname, uint reason) throws IOError;
|
2015-04-11 13:00:49 -03:00
|
|
|
public abstract void start_refresh (int force) throws IOError;
|
2015-03-04 11:55:36 -03:00
|
|
|
public abstract bool get_checkspace () throws IOError;
|
|
|
|
public abstract string get_syncfirst () throws IOError;
|
|
|
|
public abstract string get_ignorepkg () throws IOError;
|
2015-04-11 13:00:49 -03:00
|
|
|
public abstract void add_ignorepkg (string pkgname) throws IOError;
|
|
|
|
public abstract void remove_ignorepkg (string pkgname) throws IOError;
|
2015-03-04 11:55:36 -03:00
|
|
|
public abstract bool should_hold (string pkgname) throws IOError;
|
|
|
|
public abstract async Pamac.Package[] get_all_pkgs () throws IOError;
|
|
|
|
public abstract async Pamac.Package[] get_installed_pkgs () throws IOError;
|
|
|
|
public abstract async Pamac.Package[] get_local_pkgs () throws IOError;
|
|
|
|
public abstract async Pamac.Package[] get_orphans () throws IOError;
|
|
|
|
public abstract Pamac.Package find_local_pkg (string pkgname) throws IOError;
|
|
|
|
public abstract Pamac.Package find_sync_pkg (string pkgname) throws IOError;
|
2015-03-07 06:43:44 -03:00
|
|
|
public abstract async Pamac.Package[] search_pkgs (string search_string, bool search_from_aur) throws IOError;
|
2015-03-04 11:55:36 -03:00
|
|
|
public abstract string[] get_repos_names () throws IOError;
|
|
|
|
public abstract async Pamac.Package[] get_repo_pkgs (string repo) throws IOError;
|
|
|
|
public abstract string[] get_groups_names () throws IOError;
|
|
|
|
public abstract async Pamac.Package[] get_group_pkgs (string group_name) throws IOError;
|
|
|
|
public abstract string[] get_pkg_files (string pkgname) throws IOError;
|
|
|
|
public abstract string[] get_pkg_uninstalled_optdeps (string pkgname) throws IOError;
|
|
|
|
public abstract PackageDeps get_pkg_deps (string pkgname) throws IOError;
|
|
|
|
public abstract PackageDetails get_pkg_details (string pkgname) throws IOError;
|
2015-03-07 06:43:44 -03:00
|
|
|
public abstract async Updates get_updates (bool enable_aur) throws IOError;
|
2015-03-04 11:55:36 -03:00
|
|
|
public abstract ErrorInfos trans_init (Alpm.TransFlag transflags) throws IOError;
|
2014-10-22 13:44:02 -03:00
|
|
|
public abstract ErrorInfos trans_sysupgrade (int enable_downgrade) throws IOError;
|
|
|
|
public abstract ErrorInfos trans_add_pkg (string pkgname) throws IOError;
|
|
|
|
public abstract ErrorInfos trans_remove_pkg (string pkgname) throws IOError;
|
|
|
|
public abstract ErrorInfos trans_load_pkg (string pkgpath) throws IOError;
|
2015-03-04 11:55:36 -03:00
|
|
|
public abstract void start_trans_prepare () throws IOError;
|
2014-10-22 13:44:02 -03:00
|
|
|
public abstract void choose_provider (int provider) throws IOError;
|
2015-03-04 11:55:36 -03:00
|
|
|
public abstract UpdateInfos[] trans_to_add () throws IOError;
|
|
|
|
public abstract UpdateInfos[] trans_to_remove () throws IOError;
|
|
|
|
public abstract void start_trans_commit () throws IOError;
|
|
|
|
public abstract int trans_release () throws IOError;
|
2014-10-22 13:44:02 -03:00
|
|
|
public abstract void trans_cancel () throws IOError;
|
|
|
|
[DBus (no_reply = true)]
|
|
|
|
public abstract void quit () throws IOError;
|
2014-12-03 12:02:14 -03:00
|
|
|
public signal void emit_event (uint primary_event, uint secondary_event, string[] details);
|
2014-10-22 13:44:02 -03:00
|
|
|
public signal void emit_providers (string depend, string[] providers);
|
2014-10-26 08:30:04 -03:00
|
|
|
public signal void emit_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target);
|
2014-10-22 13:44:02 -03:00
|
|
|
public signal void emit_download (string filename, uint64 xfered, uint64 total);
|
|
|
|
public signal void emit_totaldownload (uint64 total);
|
|
|
|
public signal void emit_log (uint level, string msg);
|
2015-03-04 11:55:36 -03:00
|
|
|
public signal void set_pkgreason_finished ();
|
|
|
|
public signal void refresh_finished (ErrorInfos error);
|
|
|
|
public signal void trans_prepare_finished (ErrorInfos error);
|
|
|
|
public signal void trans_commit_finished (ErrorInfos error);
|
|
|
|
public signal void write_pamac_config_finished (int refresh_period, bool enable_aur, bool recurse);
|
|
|
|
public signal void write_alpm_config_finished ();
|
|
|
|
public signal void write_mirrors_config_finished ();
|
|
|
|
public signal void generate_mirrorlist_start ();
|
|
|
|
public signal void generate_mirrorlist_data (string line);
|
|
|
|
public signal void generate_mirrorlist_finished ();
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
2015-01-03 10:52:26 -03:00
|
|
|
public enum TransactionType {
|
|
|
|
STANDARD = (1 << 0),
|
|
|
|
UPDATE = (1 << 1),
|
|
|
|
BUILD = (1 << 2)
|
|
|
|
}
|
|
|
|
|
2014-10-22 13:44:02 -03:00
|
|
|
public class Transaction: Object {
|
|
|
|
public Daemon daemon;
|
|
|
|
|
2014-10-30 10:44:09 -03:00
|
|
|
public Alpm.TransFlag flags;
|
|
|
|
// those hashtables will be used as set
|
2015-04-11 13:00:49 -03:00
|
|
|
public GenericSet<string?> to_add;
|
|
|
|
public GenericSet<string?> to_remove;
|
|
|
|
public GenericSet<string?> to_load;
|
|
|
|
public GenericSet<string?> to_build;
|
|
|
|
public GenericSet<string?> special_ignorepkgs;
|
2014-10-30 10:44:09 -03:00
|
|
|
|
2014-10-22 13:44:02 -03:00
|
|
|
public Mode mode;
|
|
|
|
|
|
|
|
uint64 total_download;
|
|
|
|
uint64 already_downloaded;
|
|
|
|
string previous_label;
|
|
|
|
string previous_textbar;
|
|
|
|
double previous_percent;
|
|
|
|
string previous_filename;
|
2014-12-30 11:04:40 -03:00
|
|
|
uint pulse_timeout_id;
|
2014-10-22 13:44:02 -03:00
|
|
|
bool sysupgrade_after_trans;
|
2014-10-26 08:30:04 -03:00
|
|
|
int build_status;
|
2014-11-08 13:50:35 -03:00
|
|
|
int enable_downgrade;
|
2014-10-22 13:44:02 -03:00
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
Vte.Terminal term;
|
|
|
|
Vte.Pty pty;
|
2014-10-22 13:44:02 -03:00
|
|
|
|
|
|
|
//dialogs
|
|
|
|
TransactionSumDialog transaction_sum_dialog;
|
|
|
|
TransactionInfoDialog transaction_info_dialog;
|
2014-10-30 10:44:09 -03:00
|
|
|
ProgressDialog progress_dialog;
|
2014-10-22 13:44:02 -03:00
|
|
|
//parent window
|
2015-03-04 11:55:36 -03:00
|
|
|
Gtk.ApplicationWindow? window;
|
2014-10-22 13:44:02 -03:00
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public signal void finished (bool with_error);
|
|
|
|
public signal void enable_aur (bool enable);
|
2014-10-22 13:44:02 -03:00
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public Transaction (Gtk.ApplicationWindow? window) {
|
2014-10-30 10:44:09 -03:00
|
|
|
flags = Alpm.TransFlag.CASCADE;
|
2015-04-11 13:00:49 -03:00
|
|
|
to_add = new GenericSet<string?> (str_hash, str_equal);
|
|
|
|
to_remove = new GenericSet<string?> (str_hash, str_equal);
|
|
|
|
to_load = new GenericSet<string?> (str_hash, str_equal);
|
|
|
|
to_build = new GenericSet<string?> (str_hash, str_equal);
|
|
|
|
special_ignorepkgs = new GenericSet<string?> (str_hash, str_equal);
|
2014-10-22 13:44:02 -03:00
|
|
|
connecting_dbus_signals ();
|
|
|
|
//creating dialogs
|
|
|
|
this.window = window;
|
|
|
|
transaction_sum_dialog = new TransactionSumDialog (window);
|
|
|
|
transaction_info_dialog = new TransactionInfoDialog (window);
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog = new ProgressDialog (this, window);
|
2014-10-22 13:44:02 -03:00
|
|
|
//creating terminal
|
2015-03-04 11:55:36 -03:00
|
|
|
term = new Vte.Terminal ();
|
2014-10-22 13:44:02 -03:00
|
|
|
term.scroll_on_output = false;
|
|
|
|
term.expand = true;
|
|
|
|
term.height_request = 200;
|
|
|
|
term.set_visible (true);
|
2014-10-24 10:29:39 -03:00
|
|
|
// creating pty for term
|
|
|
|
try {
|
2015-03-04 11:55:36 -03:00
|
|
|
pty = term.pty_new_sync (Vte.PtyFlags.NO_HELPER);
|
2014-10-24 10:29:39 -03:00
|
|
|
} catch (Error e) {
|
|
|
|
stderr.printf ("Error: %s\n", e.message);
|
|
|
|
}
|
|
|
|
// connect to child_exited signal which will only be emit after a call to watch_child
|
|
|
|
term.child_exited.connect (on_term_child_exited);
|
2014-10-22 13:44:02 -03:00
|
|
|
// add term in a grid with a scrollbar
|
2015-03-04 11:55:36 -03:00
|
|
|
var grid = new Gtk.Grid ();
|
2014-10-22 13:44:02 -03:00
|
|
|
grid.expand = true;
|
|
|
|
grid.set_visible (true);
|
2015-03-04 11:55:36 -03:00
|
|
|
var sb = new Gtk.Scrollbar (Gtk.Orientation.VERTICAL, term.vadjustment);
|
2014-10-22 13:44:02 -03:00
|
|
|
sb.set_visible (true);
|
|
|
|
grid.attach (term, 0, 0, 1, 1);
|
|
|
|
grid.attach (sb, 1, 0, 1, 1);
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.expander.add (grid);
|
2014-10-22 13:44:02 -03:00
|
|
|
// progress data
|
|
|
|
total_download = 0;
|
|
|
|
already_downloaded = 0;
|
|
|
|
previous_label = "";
|
|
|
|
previous_textbar = "";
|
|
|
|
previous_percent = 0.0;
|
|
|
|
previous_filename = "";
|
|
|
|
sysupgrade_after_trans = false;
|
2014-10-26 08:30:04 -03:00
|
|
|
build_status = 0;
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public void start_write_pamac_config (HashTable<string,Variant> new_pamac_conf) {
|
2014-10-22 13:44:02 -03:00
|
|
|
try {
|
2015-03-04 11:55:36 -03:00
|
|
|
daemon.start_write_pamac_config (new_pamac_conf);
|
2014-12-30 11:04:40 -03:00
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf) {
|
2014-12-30 11:04:40 -03:00
|
|
|
try {
|
2015-03-04 11:55:36 -03:00
|
|
|
daemon.start_write_alpm_config (new_alpm_conf);
|
2014-12-30 11:04:40 -03:00
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public void start_write_mirrors_config (HashTable<string,Variant> new_mirrors_conf) {
|
2014-12-30 11:04:40 -03:00
|
|
|
try {
|
2015-03-04 11:55:36 -03:00
|
|
|
daemon.start_write_mirrors_config (new_mirrors_conf);
|
2014-11-08 13:50:35 -03:00
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public void start_set_pkgreason (string pkgname, Alpm.Package.Reason reason) {
|
2014-11-08 13:50:35 -03:00
|
|
|
try {
|
2015-03-04 11:55:36 -03:00
|
|
|
daemon.start_set_pkgreason (pkgname, (uint) reason);
|
2014-10-22 13:44:02 -03:00
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public void start_refresh (int force) {
|
2014-10-26 08:30:04 -03:00
|
|
|
string action = dgettext (null, "Synchronizing package databases") + "...";
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", action});
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (action);
|
|
|
|
progress_dialog.progressbar.set_fraction (0);
|
|
|
|
progress_dialog.progressbar.set_text ("");
|
|
|
|
progress_dialog.cancel_button.set_visible (true);
|
|
|
|
progress_dialog.close_button.set_visible (false);
|
|
|
|
progress_dialog.show ();
|
2015-03-04 11:55:36 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-11-08 13:50:35 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
|
|
|
try {
|
2015-04-11 13:00:49 -03:00
|
|
|
daemon.start_refresh (force);
|
2015-03-04 11:55:36 -03:00
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool get_checkspace () {
|
|
|
|
bool checkspace = false;
|
|
|
|
try {
|
|
|
|
checkspace = daemon.get_checkspace ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return checkspace;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string get_syncfirst () {
|
|
|
|
string syncfirst = "";
|
|
|
|
try {
|
|
|
|
syncfirst = daemon.get_syncfirst ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return syncfirst;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string get_ignorepkg () {
|
|
|
|
string ignorepkg = "";
|
|
|
|
try {
|
|
|
|
ignorepkg = daemon.get_ignorepkg ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return ignorepkg;
|
|
|
|
}
|
|
|
|
|
2015-04-11 13:00:49 -03:00
|
|
|
public void add_ignorepkg (string pkgname) {
|
|
|
|
try {
|
|
|
|
daemon.add_ignorepkg (pkgname);
|
|
|
|
special_ignorepkgs.add (pkgname);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void remove_ignorepkg (string pkgname) {
|
|
|
|
try {
|
|
|
|
daemon.remove_ignorepkg (pkgname);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public bool should_hold (string pkgname) {
|
|
|
|
bool should_hold = false;
|
|
|
|
try {
|
|
|
|
should_hold = daemon.should_hold (pkgname);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return should_hold;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Pamac.Package[] get_all_pkgs () {
|
|
|
|
Pamac.Package[] pkgs = {};
|
|
|
|
try {
|
|
|
|
pkgs = yield daemon.get_all_pkgs ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return pkgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Pamac.Package[] get_installed_pkgs () {
|
|
|
|
Pamac.Package[] pkgs = {};
|
|
|
|
try {
|
|
|
|
pkgs = yield daemon.get_installed_pkgs ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return pkgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Pamac.Package[] get_local_pkgs () {
|
|
|
|
Pamac.Package[] pkgs = {};
|
|
|
|
try {
|
|
|
|
pkgs = yield daemon.get_local_pkgs ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return pkgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Pamac.Package[] get_orphans () {
|
|
|
|
Pamac.Package[] pkgs = {};
|
|
|
|
try {
|
|
|
|
pkgs = yield daemon.get_orphans ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return pkgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Pamac.Package find_local_pkg (string pkgname) {
|
|
|
|
var pkg = Pamac.Package (null, null);
|
|
|
|
try {
|
|
|
|
pkg = daemon.find_local_pkg (pkgname);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return pkg;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Pamac.Package find_sync_pkg (string pkgname) {
|
|
|
|
var pkg = Pamac.Package (null, null);
|
|
|
|
try {
|
|
|
|
pkg = daemon.find_sync_pkg (pkgname);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return pkg;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Pamac.Package[] search_pkgs (string search_string, bool search_aur) {
|
|
|
|
Pamac.Package[] pkgs = {};
|
|
|
|
try {
|
|
|
|
pkgs = yield daemon.search_pkgs (search_string, search_aur);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return pkgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string[] get_repos_names () {
|
|
|
|
string[] repos_names = {};
|
|
|
|
try {
|
|
|
|
repos_names = daemon.get_repos_names ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return repos_names;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Pamac.Package[] get_repo_pkgs (string repo) {
|
|
|
|
Pamac.Package[] pkgs = {};
|
|
|
|
try {
|
|
|
|
pkgs = yield daemon.get_repo_pkgs (repo);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return pkgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string[] get_groups_names () {
|
|
|
|
string[] groups_names = {};
|
|
|
|
try {
|
|
|
|
groups_names = daemon.get_groups_names ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return groups_names;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Pamac.Package[] get_group_pkgs (string group_name) {
|
|
|
|
Pamac.Package[] pkgs = {};
|
|
|
|
try {
|
|
|
|
pkgs = yield daemon.get_group_pkgs (group_name);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return pkgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string[] get_pkg_files (string pkgname) {
|
|
|
|
string[] files = {};
|
|
|
|
try {
|
|
|
|
files = daemon.get_pkg_files (pkgname);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string[] get_pkg_uninstalled_optdeps (string pkgname) {
|
|
|
|
string[] optdeps = {};
|
|
|
|
try {
|
|
|
|
optdeps = daemon.get_pkg_uninstalled_optdeps (pkgname);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return optdeps;
|
|
|
|
}
|
|
|
|
|
|
|
|
public PackageDeps get_pkg_deps (string pkgname) {
|
|
|
|
var deps = PackageDeps ();
|
|
|
|
try {
|
|
|
|
deps = daemon.get_pkg_deps (pkgname);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return deps;
|
|
|
|
}
|
|
|
|
|
|
|
|
public PackageDetails get_pkg_details (string pkgname) {
|
|
|
|
var details = PackageDetails ();
|
2014-10-30 10:44:09 -03:00
|
|
|
try {
|
2015-03-04 11:55:36 -03:00
|
|
|
details = daemon.get_pkg_details (pkgname);
|
2014-10-30 10:44:09 -03:00
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2015-03-04 11:55:36 -03:00
|
|
|
return details;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Updates get_updates () {
|
|
|
|
var updates = Updates ();
|
2015-03-07 06:43:44 -03:00
|
|
|
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
2015-03-04 11:55:36 -03:00
|
|
|
try {
|
2015-03-07 06:43:44 -03:00
|
|
|
updates = yield daemon.get_updates (pamac_config.enable_aur);
|
2015-03-04 11:55:36 -03:00
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
return updates;
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
2015-04-11 13:00:49 -03:00
|
|
|
public ErrorInfos init () {
|
2015-03-07 06:43:44 -03:00
|
|
|
var err = ErrorInfos ();
|
2015-04-11 13:00:49 -03:00
|
|
|
foreach (string pkgname in special_ignorepkgs) {
|
|
|
|
add_ignorepkg (pkgname);
|
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
try {
|
|
|
|
err = daemon.trans_init (0);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2015-04-11 13:00:49 -03:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void sysupgrade_simple (int enable_downgrade) {
|
|
|
|
progress_dialog.progressbar.set_fraction (0);
|
|
|
|
progress_dialog.cancel_button.set_visible (true);
|
|
|
|
var err = init ();
|
2015-03-07 06:43:44 -03:00
|
|
|
if (err.message != "") {
|
2014-10-22 13:44:02 -03:00
|
|
|
finished (true);
|
|
|
|
handle_error (err);
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
err = daemon.trans_sysupgrade (enable_downgrade);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2015-03-07 06:43:44 -03:00
|
|
|
if (err.message == "") {
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.show ();
|
2015-03-18 12:07:18 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-10-22 13:44:02 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-30 10:44:09 -03:00
|
|
|
try {
|
2015-03-04 11:55:36 -03:00
|
|
|
daemon.start_trans_prepare ();
|
2014-10-30 10:44:09 -03:00
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
} else {
|
|
|
|
release ();
|
|
|
|
finished (true);
|
|
|
|
handle_error (err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void sysupgrade (int enable_downgrade) {
|
2014-11-08 13:50:35 -03:00
|
|
|
this.enable_downgrade = enable_downgrade;
|
2014-10-26 08:30:04 -03:00
|
|
|
string action = dgettext (null, "Starting full system upgrade") + "...";
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", action});
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (action);
|
|
|
|
progress_dialog.progressbar.set_fraction (0);
|
|
|
|
progress_dialog.progressbar.set_text ("");
|
|
|
|
progress_dialog.cancel_button.set_visible (true);
|
|
|
|
progress_dialog.close_button.set_visible (false);
|
2015-03-04 11:55:36 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-10-22 13:44:02 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
// sysupgrade
|
2015-03-04 11:55:36 -03:00
|
|
|
get_updates.begin ((obj, res) => {
|
|
|
|
Updates updates = get_updates.end (res);
|
|
|
|
// get syncfirst updates
|
|
|
|
if (updates.is_syncfirst) {
|
|
|
|
clear_lists ();
|
|
|
|
if (mode == Mode.MANAGER) {
|
|
|
|
sysupgrade_after_trans = true;
|
|
|
|
}
|
|
|
|
foreach (UpdateInfos infos in updates.repos_updates) {
|
2015-04-11 13:00:49 -03:00
|
|
|
to_add.add (infos.name);
|
2014-11-16 07:31:44 -03:00
|
|
|
}
|
2015-03-04 11:55:36 -03:00
|
|
|
// run as a standard transaction
|
|
|
|
run ();
|
|
|
|
} else {
|
|
|
|
if (updates.aur_updates.length != 0) {
|
2014-10-22 13:44:02 -03:00
|
|
|
clear_lists ();
|
2015-03-04 11:55:36 -03:00
|
|
|
foreach (UpdateInfos infos in updates.aur_updates) {
|
2015-04-13 04:41:30 -03:00
|
|
|
if ((infos.name in special_ignorepkgs) == false) {
|
|
|
|
to_build.add (infos.name);
|
|
|
|
}
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (updates.repos_updates.length != 0) {
|
|
|
|
sysupgrade_simple (enable_downgrade);
|
|
|
|
} else {
|
|
|
|
progress_dialog.show ();
|
|
|
|
while (Gtk.events_pending ()) {
|
|
|
|
Gtk.main_iteration ();
|
|
|
|
}
|
2015-03-07 06:43:44 -03:00
|
|
|
var err = ErrorInfos ();
|
2015-03-04 11:55:36 -03:00
|
|
|
on_trans_prepare_finished (err);
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
}
|
2015-03-04 11:55:36 -03:00
|
|
|
});
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void clear_lists () {
|
2015-04-11 13:00:49 -03:00
|
|
|
to_add.remove_all ();
|
|
|
|
to_remove.remove_all ();
|
|
|
|
to_build.remove_all ();
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void run () {
|
|
|
|
string action = dgettext (null,"Preparing") + "...";
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", action});
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (action);
|
|
|
|
progress_dialog.progressbar.set_fraction (0);
|
|
|
|
progress_dialog.progressbar.set_text ("");
|
|
|
|
progress_dialog.cancel_button.set_visible (true);
|
|
|
|
progress_dialog.close_button.set_visible (false);
|
|
|
|
progress_dialog.show ();
|
2015-03-18 12:07:18 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-10-22 13:44:02 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
// run
|
2015-03-07 06:43:44 -03:00
|
|
|
var err = ErrorInfos ();
|
2015-04-11 13:00:49 -03:00
|
|
|
if (to_add.length == 0
|
|
|
|
&& to_remove.length == 0
|
|
|
|
&& to_load.length == 0
|
|
|
|
&& to_build.length != 0) {
|
2014-10-22 13:44:02 -03:00
|
|
|
// there only AUR packages to build so no need to prepare transaction
|
2015-03-04 11:55:36 -03:00
|
|
|
on_trans_prepare_finished (err);
|
2014-10-22 13:44:02 -03:00
|
|
|
} else {
|
|
|
|
try {
|
2014-10-30 10:44:09 -03:00
|
|
|
err = daemon.trans_init (flags);
|
2014-10-22 13:44:02 -03:00
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2015-03-07 06:43:44 -03:00
|
|
|
if (err.message != "") {
|
2014-10-22 13:44:02 -03:00
|
|
|
finished (true);
|
|
|
|
handle_error (err);
|
|
|
|
} else {
|
2015-04-11 13:00:49 -03:00
|
|
|
foreach (string name in to_add) {
|
2014-10-22 13:44:02 -03:00
|
|
|
try {
|
|
|
|
err = daemon.trans_add_pkg (name);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2015-03-18 12:07:18 -03:00
|
|
|
if (err.message != "") {
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
2015-04-11 13:00:49 -03:00
|
|
|
foreach (string name in to_remove) {
|
2014-10-22 13:44:02 -03:00
|
|
|
try {
|
|
|
|
err = daemon.trans_remove_pkg (name);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2015-03-18 12:07:18 -03:00
|
|
|
if (err.message != "") {
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
2015-04-11 13:00:49 -03:00
|
|
|
foreach (string path in to_load) {
|
2014-10-22 13:44:02 -03:00
|
|
|
try {
|
|
|
|
err = daemon.trans_load_pkg (path);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2015-03-18 12:07:18 -03:00
|
|
|
if (err.message != "") {
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
2015-03-07 06:43:44 -03:00
|
|
|
if (err.message == "") {
|
2014-10-30 10:44:09 -03:00
|
|
|
try {
|
2015-03-04 11:55:36 -03:00
|
|
|
daemon.start_trans_prepare ();
|
2014-10-30 10:44:09 -03:00
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
} else {
|
|
|
|
release ();
|
|
|
|
finished (true);
|
|
|
|
handle_error (err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void choose_provider (string depend, string[] providers) {
|
|
|
|
int len = providers.length;
|
2014-11-08 13:50:35 -03:00
|
|
|
var choose_provider_dialog = new ChooseProviderDialog (window);
|
2014-10-26 08:30:04 -03:00
|
|
|
choose_provider_dialog.label.set_markup ("<b>%s</b>".printf (dgettext (null, "Choose a provider for %s").printf (depend, len)));
|
2014-10-22 13:44:02 -03:00
|
|
|
choose_provider_dialog.comboboxtext.remove_all ();
|
2015-04-11 13:00:49 -03:00
|
|
|
foreach (string provider in providers) {
|
2014-10-22 13:44:02 -03:00
|
|
|
choose_provider_dialog.comboboxtext.append_text (provider);
|
2015-04-11 13:00:49 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
choose_provider_dialog.comboboxtext.active = 0;
|
|
|
|
choose_provider_dialog.run ();
|
|
|
|
try {
|
|
|
|
daemon.choose_provider (choose_provider_dialog.comboboxtext.active);
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2015-04-11 13:00:49 -03:00
|
|
|
choose_provider_dialog.destroy ();
|
|
|
|
while (Gtk.events_pending ()) {
|
|
|
|
Gtk.main_iteration ();
|
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
2015-01-03 10:52:26 -03:00
|
|
|
public TransactionType set_transaction_sum () {
|
2015-01-02 18:29:04 -03:00
|
|
|
// return 0 if transaction_sum is empty, 2, if there are only aur updates, 1 otherwise
|
2015-01-03 10:52:26 -03:00
|
|
|
TransactionType type = 0;
|
2014-10-22 13:44:02 -03:00
|
|
|
uint64 dsize = 0;
|
2015-03-04 11:55:36 -03:00
|
|
|
UpdateInfos[] prepared_to_add = {};
|
|
|
|
UpdateInfos[] prepared_to_remove = {};
|
2014-10-22 13:44:02 -03:00
|
|
|
string[] to_downgrade = {};
|
|
|
|
string[] to_install = {};
|
|
|
|
string[] to_reinstall = {};
|
|
|
|
string[] to_update = {};
|
2014-10-30 10:44:09 -03:00
|
|
|
string[] _to_build = {};
|
2015-03-04 11:55:36 -03:00
|
|
|
Gtk.TreeIter iter;
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_sum_dialog.top_label.set_markup ("<big><b>%s</b></big>".printf (dgettext (null, "Transaction Summary")));
|
|
|
|
transaction_sum_dialog.sum_list.clear ();
|
|
|
|
try {
|
|
|
|
prepared_to_add = daemon.trans_to_add ();
|
|
|
|
prepared_to_remove = daemon.trans_to_remove ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2015-03-04 11:55:36 -03:00
|
|
|
foreach (UpdateInfos pkg_info in prepared_to_add) {
|
2014-10-22 13:44:02 -03:00
|
|
|
dsize += pkg_info.download_size;
|
2015-03-04 11:55:36 -03:00
|
|
|
Pamac.Package local_pkg = find_local_pkg (pkg_info.name);
|
|
|
|
if (local_pkg.name == "") {
|
2014-10-22 13:44:02 -03:00
|
|
|
to_install += "%s %s".printf (pkg_info.name, pkg_info.version);
|
|
|
|
} else {
|
2015-03-04 11:55:36 -03:00
|
|
|
int cmp = Alpm.pkg_vercmp (pkg_info.version, local_pkg.version);
|
|
|
|
if (cmp == 1) {
|
2014-10-22 13:44:02 -03:00
|
|
|
to_update += "%s %s".printf (pkg_info.name, pkg_info.version);
|
2015-03-04 11:55:36 -03:00
|
|
|
} else if (cmp == 0) {
|
2014-10-22 13:44:02 -03:00
|
|
|
to_reinstall += "%s %s".printf (pkg_info.name, pkg_info.version);
|
2015-03-04 11:55:36 -03:00
|
|
|
} else {
|
2014-10-22 13:44:02 -03:00
|
|
|
to_downgrade += "%s %s".printf (pkg_info.name, pkg_info.version);
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
}
|
2015-04-11 13:00:49 -03:00
|
|
|
foreach (string name in to_build) {
|
2014-10-30 10:44:09 -03:00
|
|
|
_to_build += name;
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
int len = prepared_to_remove.length;
|
|
|
|
int i;
|
|
|
|
if (len != 0) {
|
2015-01-03 10:52:26 -03:00
|
|
|
type |= TransactionType.STANDARD;
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
|
|
|
0, dgettext (null, "To remove") + ":",
|
|
|
|
1, "%s %s".printf (prepared_to_remove[0].name, prepared_to_remove[0].version));
|
|
|
|
i = 1;
|
|
|
|
while (i < len) {
|
|
|
|
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
|
|
|
1, "%s %s".printf (prepared_to_remove[i].name, prepared_to_remove[i].version));
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
len = to_downgrade.length;
|
|
|
|
if (len != 0) {
|
2015-01-03 10:52:26 -03:00
|
|
|
type |= TransactionType.STANDARD;
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
|
|
|
0, dgettext (null, "To downgrade") + ":",
|
|
|
|
1, to_downgrade[0]);
|
|
|
|
i = 1;
|
|
|
|
while (i < len) {
|
|
|
|
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
|
|
|
1, to_downgrade[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2014-10-30 10:44:09 -03:00
|
|
|
len = _to_build.length;
|
2014-10-22 13:44:02 -03:00
|
|
|
if (len != 0) {
|
2015-01-03 10:52:26 -03:00
|
|
|
type |= TransactionType.BUILD;
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
|
|
|
0, dgettext (null, "To build") + ":",
|
2014-10-30 10:44:09 -03:00
|
|
|
1, _to_build[0]);
|
2014-10-22 13:44:02 -03:00
|
|
|
i = 1;
|
|
|
|
while (i < len) {
|
|
|
|
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
2014-10-30 10:44:09 -03:00
|
|
|
1, _to_build[i]);
|
2014-10-22 13:44:02 -03:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
len = to_install.length;
|
|
|
|
if (len != 0) {
|
2015-01-03 10:52:26 -03:00
|
|
|
type |= TransactionType.STANDARD;
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
|
|
|
0, dgettext (null, "To install") + ":",
|
|
|
|
1, to_install[0]);
|
|
|
|
i = 1;
|
|
|
|
while (i < len) {
|
|
|
|
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
|
|
|
1, to_install[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
len = to_reinstall.length;
|
|
|
|
if (len != 0) {
|
2015-01-03 10:52:26 -03:00
|
|
|
type |= TransactionType.STANDARD;
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
|
|
|
0, dgettext (null, "To reinstall") + ":",
|
|
|
|
1, to_reinstall[0]);
|
|
|
|
i = 1;
|
|
|
|
while (i < len) {
|
|
|
|
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
|
|
|
1, to_reinstall[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2015-01-02 18:29:04 -03:00
|
|
|
len = to_update.length;
|
|
|
|
if (len != 0) {
|
2015-01-03 10:52:26 -03:00
|
|
|
type |= TransactionType.UPDATE;
|
|
|
|
if (mode != Mode.UPDATER) {
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
|
|
|
0, dgettext (null, "To update") + ":",
|
|
|
|
1, to_update[0]);
|
|
|
|
i = 1;
|
|
|
|
while (i < len) {
|
|
|
|
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
|
|
|
1, to_update[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-04 11:55:36 -03:00
|
|
|
if (dsize == 0) {
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_sum_dialog.bottom_label.set_visible (false);
|
2015-03-04 11:55:36 -03:00
|
|
|
} else {
|
2014-10-26 08:30:04 -03:00
|
|
|
transaction_sum_dialog.bottom_label.set_markup ("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size (dsize)));
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_sum_dialog.bottom_label.set_visible (true);
|
|
|
|
}
|
2015-01-03 10:52:26 -03:00
|
|
|
return type;
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public void start_commit () {
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.cancel_button.set_visible (false);
|
|
|
|
try {
|
2015-03-04 11:55:36 -03:00
|
|
|
daemon.start_trans_commit ();
|
2014-10-30 10:44:09 -03:00
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void build_aur_packages () {
|
|
|
|
string action = dgettext (null,"Building packages") + "...";
|
2015-01-28 12:40:05 -03:00
|
|
|
spawn_in_term ({"echo", action});
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (action);
|
|
|
|
progress_dialog.progressbar.set_fraction (0);
|
|
|
|
progress_dialog.progressbar.set_text ("");
|
|
|
|
progress_dialog.cancel_button.set_visible (false);
|
|
|
|
progress_dialog.close_button.set_visible (false);
|
|
|
|
progress_dialog.expander.set_expanded (true);
|
|
|
|
progress_dialog.width_request = 700;
|
2014-10-22 13:44:02 -03:00
|
|
|
term.grab_focus ();
|
2014-12-30 11:04:40 -03:00
|
|
|
pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse);
|
|
|
|
string[] cmds = {"yaourt", "-S"};
|
2015-04-11 13:00:49 -03:00
|
|
|
foreach (string name in to_build) {
|
2014-10-24 10:29:39 -03:00
|
|
|
cmds += name;
|
2015-04-11 13:00:49 -03:00
|
|
|
}
|
2014-10-24 10:29:39 -03:00
|
|
|
Pid child_pid;
|
|
|
|
spawn_in_term (cmds, out child_pid);
|
|
|
|
// watch_child is needed in order to have the child_exited signal emitted
|
|
|
|
term.watch_child (child_pid);
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void cancel () {
|
|
|
|
try {
|
|
|
|
daemon.trans_cancel ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void release () {
|
|
|
|
try {
|
|
|
|
daemon.trans_release ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
2015-04-11 13:00:49 -03:00
|
|
|
foreach (string pkgname in special_ignorepkgs) {
|
|
|
|
remove_ignorepkg (pkgname);
|
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void stop_daemon () {
|
|
|
|
try {
|
|
|
|
daemon.quit ();
|
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-24 17:34:23 -03:00
|
|
|
public void spawn_in_term (string[] args, out Pid child_pid = null) {
|
|
|
|
Pid intern_pid;
|
2014-10-24 10:29:39 -03:00
|
|
|
try {
|
2015-01-02 18:29:04 -03:00
|
|
|
Process.spawn_async (null, args, null, SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD, pty.child_setup, out intern_pid);
|
2014-10-24 10:29:39 -03:00
|
|
|
} catch (SpawnError e) {
|
|
|
|
stderr.printf ("SpawnError: %s\n", e.message);
|
|
|
|
}
|
2014-11-24 17:34:23 -03:00
|
|
|
child_pid = intern_pid;
|
2014-10-24 10:29:39 -03:00
|
|
|
term.set_pty (pty);
|
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public async void run_preferences_dialog () {
|
|
|
|
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
|
|
|
var mirrors_config = new Alpm.MirrorsConfig ("/etc/pacman-mirrors.conf");
|
2015-04-11 13:00:49 -03:00
|
|
|
var preferences_dialog = new PreferencesDialog (window);
|
2014-12-30 11:04:40 -03:00
|
|
|
bool enable_aur = pamac_config.enable_aur;
|
|
|
|
bool recurse = pamac_config.recurse;
|
|
|
|
int refresh_period = pamac_config.refresh_period;
|
2015-03-04 11:55:36 -03:00
|
|
|
bool checkspace = get_checkspace ();
|
|
|
|
string syncfirst = get_syncfirst ();
|
|
|
|
string ignorepkg = get_ignorepkg ();
|
2014-12-30 11:04:40 -03:00
|
|
|
string choosen_generation_method = mirrors_config.choosen_generation_method;
|
|
|
|
string choosen_country = mirrors_config.choosen_country;
|
|
|
|
preferences_dialog.enable_aur_button.set_active (enable_aur);
|
|
|
|
preferences_dialog.remove_unrequired_deps_button.set_active (recurse);
|
|
|
|
preferences_dialog.refresh_period_spin_button.set_value (refresh_period);
|
2015-03-04 11:55:36 -03:00
|
|
|
preferences_dialog.check_space_button.set_active (checkspace);
|
2014-12-30 11:04:40 -03:00
|
|
|
preferences_dialog.syncfirst_entry.set_text (syncfirst);
|
|
|
|
preferences_dialog.ignore_upgrade_entry.set_text (ignorepkg);
|
|
|
|
preferences_dialog.mirrors_country_comboboxtext.remove_all ();
|
|
|
|
preferences_dialog.mirrors_country_comboboxtext.append_text (dgettext (null, "Worldwide"));
|
|
|
|
preferences_dialog.mirrors_country_comboboxtext.active = 0;
|
|
|
|
int index = 1;
|
|
|
|
mirrors_config.get_countrys ();
|
|
|
|
foreach (string country in mirrors_config.countrys) {
|
|
|
|
preferences_dialog.mirrors_country_comboboxtext.append_text (country);
|
2015-03-04 11:55:36 -03:00
|
|
|
if (country == choosen_country) {
|
2014-12-30 11:04:40 -03:00
|
|
|
preferences_dialog.mirrors_country_comboboxtext.active = index;
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
2014-12-30 11:04:40 -03:00
|
|
|
index += 1;
|
|
|
|
}
|
|
|
|
preferences_dialog.mirrorlist_generation_method_comboboxtext.remove_all ();
|
|
|
|
preferences_dialog.mirrorlist_generation_method_comboboxtext.append_text (dgettext (null, "speed"));
|
|
|
|
preferences_dialog.mirrorlist_generation_method_comboboxtext.append_text (dgettext (null, "random"));
|
2015-03-04 11:55:36 -03:00
|
|
|
if (choosen_generation_method == "rank") {
|
2014-12-30 11:04:40 -03:00
|
|
|
preferences_dialog.mirrorlist_generation_method_comboboxtext.active = 0;
|
2015-03-04 11:55:36 -03:00
|
|
|
} else {
|
2014-12-30 11:04:40 -03:00
|
|
|
preferences_dialog.mirrorlist_generation_method_comboboxtext.active = 1;
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
2015-04-11 13:00:49 -03:00
|
|
|
if (preferences_dialog.run () == Gtk.ResponseType.OK) {
|
|
|
|
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
|
|
|
var new_alpm_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
|
|
|
var new_mirrors_conf = new HashTable<string,Variant> (str_hash, str_equal);
|
2014-12-30 11:04:40 -03:00
|
|
|
enable_aur = preferences_dialog.enable_aur_button.get_active ();
|
|
|
|
recurse = preferences_dialog.remove_unrequired_deps_button.get_active ();
|
|
|
|
refresh_period = preferences_dialog.refresh_period_spin_button.get_value_as_int ();
|
2015-03-04 11:55:36 -03:00
|
|
|
checkspace = preferences_dialog.check_space_button.get_active ();
|
2014-12-30 11:04:40 -03:00
|
|
|
syncfirst = preferences_dialog.syncfirst_entry.get_text ();
|
|
|
|
ignorepkg = preferences_dialog.ignore_upgrade_entry.get_text ();
|
|
|
|
choosen_country = preferences_dialog.mirrors_country_comboboxtext.get_active_text ();
|
2015-03-04 11:55:36 -03:00
|
|
|
if (preferences_dialog.mirrorlist_generation_method_comboboxtext.get_active_text () == dgettext (null, "speed")) {
|
2014-12-30 11:04:40 -03:00
|
|
|
choosen_generation_method = "rank";
|
2015-03-04 11:55:36 -03:00
|
|
|
} else {
|
2014-12-30 11:04:40 -03:00
|
|
|
choosen_generation_method = "random";
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
|
|
|
if (enable_aur != pamac_config.enable_aur) {
|
2014-12-30 11:04:40 -03:00
|
|
|
new_pamac_conf.insert ("EnableAUR", new Variant.boolean (enable_aur));
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
|
|
|
if (recurse != pamac_config.recurse) {
|
2014-12-30 11:04:40 -03:00
|
|
|
new_pamac_conf.insert ("RemoveUnrequiredDeps", new Variant.boolean (recurse));
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
|
|
|
if (refresh_period != pamac_config.refresh_period) {
|
2014-12-30 11:04:40 -03:00
|
|
|
new_pamac_conf.insert ("RefreshPeriod", new Variant.int32 (refresh_period));
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
|
|
|
if (checkspace != get_checkspace ()) {
|
|
|
|
new_alpm_conf.insert ("CheckSpace", new Variant.boolean (checkspace));
|
|
|
|
}
|
|
|
|
if (syncfirst != get_syncfirst ()) {
|
2014-12-30 11:04:40 -03:00
|
|
|
new_alpm_conf.insert ("SyncFirst", new Variant.string (syncfirst));
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
|
|
|
if (ignorepkg != get_ignorepkg ()) {
|
2014-12-30 11:04:40 -03:00
|
|
|
new_alpm_conf.insert ("IgnorePkg", new Variant.string (ignorepkg));
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
|
|
|
if (choosen_country != mirrors_config.choosen_country) {
|
2014-12-30 11:04:40 -03:00
|
|
|
new_mirrors_conf.insert ("OnlyCountry", new Variant.string (choosen_country));
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
2014-12-30 11:04:40 -03:00
|
|
|
if (choosen_generation_method == "rank"
|
2015-03-04 11:55:36 -03:00
|
|
|
&& preferences_dialog.mirrorlist_generation_method_comboboxtext.get_active_text () == dgettext (null, "random")) {
|
2014-12-30 11:04:40 -03:00
|
|
|
new_mirrors_conf.insert ("Method", new Variant.string (dgettext (null, "random")));
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
2014-12-30 11:04:40 -03:00
|
|
|
if (choosen_generation_method == "random"
|
2015-03-04 11:55:36 -03:00
|
|
|
&& preferences_dialog.mirrorlist_generation_method_comboboxtext.get_active_text () == dgettext (null, "speed")) {
|
2014-12-30 11:04:40 -03:00
|
|
|
new_mirrors_conf.insert ("Method", new Variant.string (dgettext (null, "speed")));
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
2015-04-11 13:00:49 -03:00
|
|
|
if (new_pamac_conf.size () != 0) {
|
|
|
|
start_write_pamac_config (new_pamac_conf);
|
|
|
|
SourceFunc callback = run_preferences_dialog.callback;
|
|
|
|
ulong handler_id = daemon.write_pamac_config_finished.connect (() => {
|
|
|
|
Idle.add((owned) callback);
|
|
|
|
});
|
|
|
|
yield;
|
|
|
|
daemon.disconnect (handler_id);
|
|
|
|
}
|
|
|
|
if (new_alpm_conf.size () != 0) {
|
|
|
|
start_write_alpm_config (new_alpm_conf);
|
|
|
|
SourceFunc callback = run_preferences_dialog.callback;
|
|
|
|
ulong handler_id = daemon.write_alpm_config_finished.connect (() => {
|
|
|
|
Idle.add((owned) callback);
|
|
|
|
});
|
|
|
|
yield;
|
|
|
|
daemon.disconnect (handler_id);
|
|
|
|
}
|
|
|
|
if (new_mirrors_conf.size () != 0) {
|
|
|
|
start_write_mirrors_config (new_mirrors_conf);
|
|
|
|
SourceFunc callback = run_preferences_dialog.callback;
|
|
|
|
ulong handler_id = daemon.write_mirrors_config_finished.connect (() => {
|
|
|
|
Idle.add((owned) callback);
|
|
|
|
});
|
|
|
|
yield;
|
|
|
|
daemon.disconnect (handler_id);
|
|
|
|
}
|
2014-12-30 11:04:40 -03:00
|
|
|
}
|
2015-04-11 13:00:49 -03:00
|
|
|
preferences_dialog.destroy ();
|
2015-03-04 11:55:36 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-12-30 11:04:40 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
2014-12-30 11:04:40 -03:00
|
|
|
}
|
|
|
|
|
2014-12-03 12:02:14 -03:00
|
|
|
void on_emit_event (uint primary_event, uint secondary_event, string[] details) {
|
2014-10-26 08:30:04 -03:00
|
|
|
string msg;
|
2014-12-03 12:02:14 -03:00
|
|
|
switch (primary_event) {
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.CHECKDEPS_START:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Checking dependencies") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.FILECONFLICTS_START:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Checking file conflicts") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.RESOLVEDEPS_START:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Resolving dependencies") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.INTERCONFLICTS_START:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Checking inter-conflicts") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.PACKAGE_OPERATION_START:
|
2014-12-03 12:02:14 -03:00
|
|
|
switch (secondary_event) {
|
|
|
|
case Alpm.Package.Operation.INSTALL:
|
|
|
|
progress_dialog.cancel_button.set_visible (false);
|
|
|
|
previous_filename = details[0];
|
|
|
|
msg = dgettext (null, "Installing %s").printf (details[0]) + "...";
|
|
|
|
progress_dialog.action_label.set_text (msg);
|
|
|
|
msg = dgettext (null, "Installing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-12-03 12:02:14 -03:00
|
|
|
break;
|
|
|
|
case Alpm.Package.Operation.REINSTALL:
|
|
|
|
progress_dialog.cancel_button.set_visible (false);
|
|
|
|
previous_filename = details[0];
|
|
|
|
msg = dgettext (null, "Reinstalling %s").printf (details[0]) + "...";
|
|
|
|
progress_dialog.action_label.set_text (msg);
|
|
|
|
msg = dgettext (null, "Reinstalling %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-12-03 12:02:14 -03:00
|
|
|
break;
|
|
|
|
case Alpm.Package.Operation.REMOVE:
|
|
|
|
progress_dialog.cancel_button.set_visible (false);
|
|
|
|
previous_filename = details[0];
|
|
|
|
msg = dgettext (null, "Removing %s").printf (details[0]) + "...";
|
|
|
|
progress_dialog.action_label.set_text (msg);
|
|
|
|
msg = dgettext (null, "Removing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-12-03 12:02:14 -03:00
|
|
|
break;
|
|
|
|
case Alpm.Package.Operation.UPGRADE:
|
|
|
|
progress_dialog.cancel_button.set_visible (false);
|
|
|
|
previous_filename = details[0];
|
|
|
|
msg = dgettext (null, "Upgrading %s").printf (details[0]) + "...";
|
|
|
|
progress_dialog.action_label.set_text (msg);
|
|
|
|
msg = dgettext (null, "Upgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2]))+ "...";
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-12-03 12:02:14 -03:00
|
|
|
break;
|
|
|
|
case Alpm.Package.Operation.DOWNGRADE:
|
|
|
|
progress_dialog.cancel_button.set_visible (false);
|
|
|
|
previous_filename = details[0];
|
|
|
|
msg = dgettext (null, "Downgrading %s").printf (details[0]) + "...";
|
|
|
|
progress_dialog.action_label.set_text (msg);
|
|
|
|
msg = dgettext (null, "Downgrading %s").printf ("%s (%s -> %s)".printf (details[0], details[1], details[2]))+ "...";
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-12-03 12:02:14 -03:00
|
|
|
break;
|
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.INTEGRITY_START:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Checking integrity") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.KEYRING_START:
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.cancel_button.set_visible (true);
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Checking keyring") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-26 08:30:04 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.KEY_DOWNLOAD_START:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Downloading required keys") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.LOAD_START:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Loading packages files") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-26 08:30:04 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.DELTA_INTEGRITY_START:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Checking delta integrity") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-26 08:30:04 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.DELTA_PATCHES_START:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Applying deltas") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-26 08:30:04 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.DELTA_PATCH_START:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Generating %s with %s").printf (details[0], details[1]) + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-26 08:30:04 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.DELTA_PATCH_DONE:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Generation succeeded") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-26 08:30:04 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.DELTA_PATCH_FAILED:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Generation failed") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.SCRIPTLET_INFO:
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (dgettext (null, "Configuring %s").printf (previous_filename) + "...");
|
|
|
|
progress_dialog.expander.set_expanded (true);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", "-n", details[0]});
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.RETRIEVE_START:
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.cancel_button.set_visible (true);
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Downloading") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-12-03 12:02:14 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.DISKSPACE_START:
|
2014-10-26 08:30:04 -03:00
|
|
|
msg = dgettext (null, "Checking available disk space") + "...";
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.action_label.set_text (msg);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", msg});
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.OPTDEP_REMOVAL:
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", dgettext (null, "%s optionally requires %s").printf (details[0], details[1])});
|
2014-10-26 08:30:04 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.DATABASE_MISSING:
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", dgettext (null, "Database file for %s does not exist").printf (details[0])});
|
2014-10-22 13:44:02 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.PACNEW_CREATED:
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacnew").printf (details[0])});
|
2014-12-03 12:02:14 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.PACSAVE_CREATED:
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacsave").printf (details[0])});
|
2014-12-03 12:02:14 -03:00
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Event.Type.PACORIG_CREATED:
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", dgettext (null, "%s installed as %s.pacorig").printf (details[0])});
|
2014-12-03 12:02:14 -03:00
|
|
|
break;
|
2014-10-22 13:44:02 -03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-03-18 12:07:18 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-10-26 08:30:04 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void on_emit_providers (string depend, string[] providers) {
|
|
|
|
choose_provider (depend, providers);
|
|
|
|
}
|
|
|
|
|
2014-10-26 08:30:04 -03:00
|
|
|
void on_emit_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target) {
|
2014-10-22 13:44:02 -03:00
|
|
|
double fraction;
|
|
|
|
switch (progress) {
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Progress.ADD_START:
|
|
|
|
case Alpm.Progress.UPGRADE_START:
|
|
|
|
case Alpm.Progress.DOWNGRADE_START:
|
|
|
|
case Alpm.Progress.REINSTALL_START:
|
|
|
|
case Alpm.Progress.REMOVE_START:
|
2014-10-22 13:44:02 -03:00
|
|
|
fraction = ((float) (current_target-1)/n_targets)+((float) percent/(100*n_targets));
|
|
|
|
break;
|
2015-03-04 11:55:36 -03:00
|
|
|
case Alpm.Progress.CONFLICTS_START:
|
|
|
|
case Alpm.Progress.DISKSPACE_START:
|
|
|
|
case Alpm.Progress.INTEGRITY_START:
|
|
|
|
case Alpm.Progress.KEYRING_START:
|
|
|
|
case Alpm.Progress.LOAD_START:
|
2014-10-22 13:44:02 -03:00
|
|
|
default:
|
|
|
|
fraction = (float) percent/100;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
string textbar = "%lu/%lu".printf (current_target, n_targets);
|
|
|
|
if (textbar != previous_textbar) {
|
|
|
|
previous_textbar = textbar;
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.progressbar.set_text (textbar);
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
if (fraction != previous_percent) {
|
|
|
|
previous_percent = fraction;
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.progressbar.set_fraction (fraction);
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
2015-03-18 12:07:18 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-10-22 13:44:02 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void on_emit_download (string filename, uint64 xfered, uint64 total) {
|
2014-12-30 11:04:40 -03:00
|
|
|
string label;
|
2014-10-22 13:44:02 -03:00
|
|
|
string textbar;
|
|
|
|
double fraction;
|
2014-12-30 11:04:40 -03:00
|
|
|
if (filename != previous_filename) {
|
|
|
|
previous_filename = filename;
|
|
|
|
if (filename.has_suffix (".db")) {
|
|
|
|
label = dgettext (null, "Refreshing %s").printf (filename.replace (".db", "")) + "...";
|
|
|
|
} else {
|
|
|
|
label = dgettext (null, "Downloading %s").printf (filename.replace (".pkg.tar.xz", "")) + "...";
|
|
|
|
}
|
|
|
|
if (label != previous_label) {
|
|
|
|
previous_label = label;
|
|
|
|
progress_dialog.action_label.set_text (label);
|
|
|
|
spawn_in_term ({"echo", label});
|
|
|
|
}
|
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
if (total_download > 0) {
|
|
|
|
fraction = (float) (xfered + already_downloaded) / total_download;
|
2015-03-18 12:07:18 -03:00
|
|
|
if (fraction <= 1) {
|
2014-11-16 07:31:44 -03:00
|
|
|
textbar = "%s/%s".printf (format_size (xfered + already_downloaded), format_size (total_download));
|
2015-03-18 12:07:18 -03:00
|
|
|
} else {
|
2014-11-16 07:31:44 -03:00
|
|
|
textbar = "%s".printf (format_size (xfered + already_downloaded));
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
} else {
|
|
|
|
fraction = (float) xfered / total;
|
2015-03-18 12:07:18 -03:00
|
|
|
if (fraction <= 1) {
|
2014-11-16 07:31:44 -03:00
|
|
|
textbar = "%s/%s".printf (format_size (xfered), format_size (total));
|
2015-03-18 12:07:18 -03:00
|
|
|
} else {
|
2014-11-16 07:31:44 -03:00
|
|
|
textbar = "%s".printf (format_size (xfered));
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
2014-11-16 07:31:44 -03:00
|
|
|
if (fraction > 0) {
|
|
|
|
if (fraction != previous_percent) {
|
|
|
|
previous_percent = fraction;
|
|
|
|
progress_dialog.progressbar.set_fraction (fraction);
|
|
|
|
}
|
2015-03-18 12:07:18 -03:00
|
|
|
} else {
|
2014-11-16 07:31:44 -03:00
|
|
|
progress_dialog.progressbar.set_fraction (0);
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
if (textbar != previous_textbar) {
|
|
|
|
previous_textbar = textbar;
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.progressbar.set_text (textbar);
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
2014-11-16 07:31:44 -03:00
|
|
|
if (xfered == total) {
|
2014-10-22 13:44:02 -03:00
|
|
|
already_downloaded += total;
|
2014-11-16 07:31:44 -03:00
|
|
|
previous_filename = "";
|
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void on_emit_totaldownload (uint64 total) {
|
|
|
|
total_download = total;
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_emit_log (uint level, string msg) {
|
|
|
|
// msg ends with \n
|
|
|
|
string? line = null;
|
2015-03-04 11:55:36 -03:00
|
|
|
Gtk.TextIter end_iter;
|
2014-10-22 13:44:02 -03:00
|
|
|
if ((Alpm.LogLevel) level == Alpm.LogLevel.WARNING) {
|
2015-03-18 12:12:35 -03:00
|
|
|
// do not show warning when manjaro-system remove db.lck
|
|
|
|
if (previous_filename != "manjaro-system") {
|
|
|
|
if (previous_filename != "") {
|
|
|
|
line = dgettext (null, "Warning") + ": " + previous_filename + ": " + msg;
|
|
|
|
} else {
|
|
|
|
line = dgettext (null, "Warning") + ": " + msg;
|
|
|
|
}
|
|
|
|
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
|
|
|
|
transaction_info_dialog.textbuffer.insert (ref end_iter, msg, msg.length);
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
} else if ((Alpm.LogLevel) level == Alpm.LogLevel.ERROR) {
|
2015-03-18 12:07:18 -03:00
|
|
|
if (previous_filename != "") {
|
2014-11-08 13:50:35 -03:00
|
|
|
line = dgettext (null, "Error") + ": " + previous_filename + ": " + msg;
|
2015-03-18 12:07:18 -03:00
|
|
|
} else {
|
2014-11-08 13:50:35 -03:00
|
|
|
line = dgettext (null, "Error") + ": " + msg;
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
if (line != null) {
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.expander.set_expanded (true);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", "-n", line});
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-26 08:30:04 -03:00
|
|
|
public void show_warnings () {
|
2014-10-22 13:44:02 -03:00
|
|
|
if (transaction_info_dialog.textbuffer.text != "") {
|
|
|
|
transaction_info_dialog.set_title (dgettext (null, "Warning"));
|
|
|
|
transaction_info_dialog.label.set_visible (false);
|
|
|
|
transaction_info_dialog.expander.set_visible (true);
|
|
|
|
transaction_info_dialog.expander.set_expanded (true);
|
|
|
|
transaction_info_dialog.run ();
|
|
|
|
transaction_info_dialog.hide ();
|
2015-03-18 12:07:18 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-11-08 13:50:35 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2015-03-04 11:55:36 -03:00
|
|
|
Gtk.TextIter start_iter;
|
|
|
|
Gtk.TextIter end_iter;
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
|
|
|
|
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
|
|
|
|
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void handle_error (ErrorInfos error) {
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.expander.set_expanded (true);
|
2015-03-07 06:43:44 -03:00
|
|
|
spawn_in_term ({"echo", "-n", error.message});
|
2015-03-04 11:55:36 -03:00
|
|
|
Gtk.TextIter start_iter;
|
|
|
|
Gtk.TextIter end_iter;
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_info_dialog.set_title (dgettext (null, "Error"));
|
|
|
|
transaction_info_dialog.label.set_visible (true);
|
2015-03-07 06:43:44 -03:00
|
|
|
transaction_info_dialog.label.set_markup (error.message);
|
2014-10-22 13:44:02 -03:00
|
|
|
if (error.details.length != 0) {
|
2014-10-26 08:30:04 -03:00
|
|
|
transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
|
|
|
|
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
|
|
|
|
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
|
|
|
|
transaction_info_dialog.expander.set_visible (true);
|
|
|
|
transaction_info_dialog.expander.set_expanded (true);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", ":"});
|
2014-10-22 13:44:02 -03:00
|
|
|
foreach (string detail in error.details) {
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", detail});
|
2014-10-26 08:30:04 -03:00
|
|
|
string str = detail + "\n";
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
|
2014-10-26 08:30:04 -03:00
|
|
|
transaction_info_dialog.textbuffer.insert (ref end_iter, str, str.length);
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
2015-03-18 12:07:18 -03:00
|
|
|
} else {
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_info_dialog.expander.set_visible (false);
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo"});
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_info_dialog.run ();
|
|
|
|
transaction_info_dialog.hide ();
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.hide ();
|
2014-10-26 08:30:04 -03:00
|
|
|
transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
|
|
|
|
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
|
|
|
|
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
|
2015-03-18 12:07:18 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-10-22 13:44:02 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public void on_refresh_finished (ErrorInfos error) {
|
2015-03-07 06:43:44 -03:00
|
|
|
if (error.message == "") {
|
2014-10-22 13:44:02 -03:00
|
|
|
if (mode == Mode.UPDATER) {
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.hide ();
|
2015-03-04 11:55:36 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-11-08 13:50:35 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
finished (false);
|
|
|
|
} else {
|
2014-12-30 11:04:40 -03:00
|
|
|
clear_lists ();
|
2014-10-22 13:44:02 -03:00
|
|
|
sysupgrade (0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
finished (true);
|
2015-04-11 13:00:49 -03:00
|
|
|
handle_error (error);
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
2014-11-08 13:50:35 -03:00
|
|
|
previous_filename = "";
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public void on_trans_prepare_finished (ErrorInfos error) {
|
2015-03-07 06:43:44 -03:00
|
|
|
if (error.message == "") {
|
2014-10-26 08:30:04 -03:00
|
|
|
show_warnings ();
|
2015-01-03 10:52:26 -03:00
|
|
|
TransactionType type = set_transaction_sum ();
|
2015-01-07 11:09:39 -03:00
|
|
|
if (type == TransactionType.UPDATE && mode == Mode.UPDATER) {
|
2015-01-03 10:52:26 -03:00
|
|
|
// there only updates
|
2015-03-04 11:55:36 -03:00
|
|
|
start_commit ();
|
2015-01-03 10:52:26 -03:00
|
|
|
} else if (type != 0) {
|
2015-03-04 11:55:36 -03:00
|
|
|
if (transaction_sum_dialog.run () == Gtk.ResponseType.OK) {
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_sum_dialog.hide ();
|
2015-03-18 12:07:18 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-10-22 13:44:02 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2015-01-03 10:52:26 -03:00
|
|
|
if (type == TransactionType.BUILD) {
|
|
|
|
// there only AUR packages to build
|
2015-03-07 06:43:44 -03:00
|
|
|
var err = ErrorInfos ();
|
2015-03-04 11:55:36 -03:00
|
|
|
on_trans_commit_finished (err);
|
2015-03-18 12:07:18 -03:00
|
|
|
} else {
|
2015-03-04 11:55:36 -03:00
|
|
|
start_commit ();
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
} else {
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", dgettext (null, "Transaction cancelled") + ".\n"});
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.hide ();
|
2014-10-22 13:44:02 -03:00
|
|
|
transaction_sum_dialog.hide ();
|
2015-03-18 12:07:18 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-11-08 13:50:35 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
release ();
|
2015-04-11 13:00:49 -03:00
|
|
|
to_build.remove_all ();
|
2014-11-24 17:34:23 -03:00
|
|
|
sysupgrade_after_trans = false;
|
2014-10-22 13:44:02 -03:00
|
|
|
finished (true);
|
|
|
|
}
|
|
|
|
} else {
|
2015-03-07 06:43:44 -03:00
|
|
|
//var err = ErrorInfos ();
|
|
|
|
//err.message = dgettext (null, "Nothing to do") + "\n";
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", dgettext (null, "Nothing to do") + ".\n"});
|
2014-10-30 10:44:09 -03:00
|
|
|
progress_dialog.hide ();
|
2015-03-18 12:07:18 -03:00
|
|
|
while (Gtk.events_pending ()) {
|
2014-11-08 13:50:35 -03:00
|
|
|
Gtk.main_iteration ();
|
2015-03-18 12:07:18 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
release ();
|
|
|
|
clear_lists ();
|
|
|
|
finished (false);
|
|
|
|
//handle_error (err);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
finished (true);
|
|
|
|
handle_error (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
public void on_trans_commit_finished (ErrorInfos error) {
|
2015-03-07 06:43:44 -03:00
|
|
|
if (error.message == "") {
|
2015-04-11 13:00:49 -03:00
|
|
|
if (to_build.length != 0) {
|
|
|
|
if (to_add.length != 0
|
|
|
|
|| to_remove.length != 0
|
|
|
|
|| to_load.length != 0) {
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
|
2014-10-24 10:29:39 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
build_aur_packages ();
|
|
|
|
} else {
|
2014-10-30 10:44:09 -03:00
|
|
|
//progress_dialog.action_label.set_text (dgettext (null, "Transaction successfully finished"));
|
2014-10-22 13:44:02 -03:00
|
|
|
clear_lists ();
|
2014-10-26 08:30:04 -03:00
|
|
|
show_warnings ();
|
2014-10-22 13:44:02 -03:00
|
|
|
if (sysupgrade_after_trans) {
|
|
|
|
sysupgrade_after_trans = false;
|
|
|
|
sysupgrade (0);
|
|
|
|
} else {
|
2015-03-11 15:42:04 -03:00
|
|
|
if (build_status == 0) {
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", dgettext (null, "Transaction successfully finished") + ".\n"});
|
2015-04-11 13:00:49 -03:00
|
|
|
progress_dialog.hide ();
|
|
|
|
while (Gtk.events_pending ()) {
|
|
|
|
Gtk.main_iteration ();
|
|
|
|
}
|
2015-03-11 15:42:04 -03:00
|
|
|
} else {
|
2015-04-11 13:00:49 -03:00
|
|
|
progress_dialog.progressbar.set_fraction (0);
|
|
|
|
progress_dialog.cancel_button.set_visible (false);
|
|
|
|
progress_dialog.close_button.set_visible (true);
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo"});
|
2015-03-11 15:42:04 -03:00
|
|
|
}
|
2014-10-22 13:44:02 -03:00
|
|
|
finished (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
finished (true);
|
|
|
|
handle_error (error);
|
|
|
|
}
|
|
|
|
total_download = 0;
|
|
|
|
already_downloaded = 0;
|
2014-10-26 08:30:04 -03:00
|
|
|
build_status = 0;
|
2014-11-08 13:50:35 -03:00
|
|
|
previous_filename = "";
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void on_term_child_exited (int status) {
|
2014-12-30 11:04:40 -03:00
|
|
|
Source.remove (pulse_timeout_id);
|
2015-04-11 13:00:49 -03:00
|
|
|
to_build.remove_all ();
|
2014-10-26 08:30:04 -03:00
|
|
|
build_status = status;
|
2015-03-27 12:31:07 -03:00
|
|
|
// let the time to the daemon to update packages
|
|
|
|
Timeout.add (1000, () => {
|
|
|
|
var err = ErrorInfos ();
|
|
|
|
on_trans_commit_finished (err);
|
|
|
|
return false;
|
|
|
|
});
|
2015-03-04 11:55:36 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void on_write_pamac_config_finished (int refresh_period, bool aur_enabled, bool recurse) {
|
|
|
|
flags = Alpm.TransFlag.CASCADE;
|
|
|
|
if (recurse) {
|
|
|
|
flags |= Alpm.TransFlag.RECURSE;
|
|
|
|
}
|
|
|
|
enable_aur (aur_enabled);
|
2014-10-22 13:44:02 -03:00
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
void on_generate_mirrorlist_start () {
|
2014-12-30 11:04:40 -03:00
|
|
|
string action = dgettext (null, "Generating mirrorlist") + "...";
|
2015-01-28 12:40:05 -03:00
|
|
|
spawn_in_term ({"echo", action});
|
2014-12-30 11:04:40 -03:00
|
|
|
progress_dialog.action_label.set_text (action);
|
|
|
|
progress_dialog.progressbar.set_fraction (0);
|
|
|
|
progress_dialog.progressbar.set_text ("");
|
|
|
|
progress_dialog.cancel_button.set_visible (false);
|
|
|
|
progress_dialog.close_button.set_visible (false);
|
|
|
|
progress_dialog.expander.set_expanded (true);
|
|
|
|
progress_dialog.width_request = 700;
|
|
|
|
pulse_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse);
|
|
|
|
progress_dialog.show ();
|
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
void on_generate_mirrorlist_data (string line) {
|
2014-12-30 11:04:40 -03:00
|
|
|
spawn_in_term ({"echo", "-n", line});
|
|
|
|
}
|
|
|
|
|
2015-03-04 11:55:36 -03:00
|
|
|
void on_generate_mirrorlist_finished () {
|
2014-12-30 11:04:40 -03:00
|
|
|
Source.remove (pulse_timeout_id);
|
|
|
|
spawn_in_term ({"echo"});
|
2015-03-07 05:39:51 -03:00
|
|
|
// force a dbs refresh
|
|
|
|
start_refresh (1);
|
2014-12-30 11:04:40 -03:00
|
|
|
}
|
|
|
|
|
2014-10-22 13:44:02 -03:00
|
|
|
void connecting_dbus_signals () {
|
|
|
|
try {
|
|
|
|
daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
|
|
|
|
"/org/manjaro/pamac");
|
|
|
|
// Connecting to signals
|
|
|
|
daemon.emit_event.connect (on_emit_event);
|
|
|
|
daemon.emit_providers.connect (on_emit_providers);
|
|
|
|
daemon.emit_progress.connect (on_emit_progress);
|
|
|
|
daemon.emit_download.connect (on_emit_download);
|
|
|
|
daemon.emit_totaldownload.connect (on_emit_totaldownload);
|
|
|
|
daemon.emit_log.connect (on_emit_log);
|
2015-03-04 11:55:36 -03:00
|
|
|
daemon.refresh_finished.connect (on_refresh_finished);
|
|
|
|
daemon.trans_prepare_finished.connect (on_trans_prepare_finished);
|
|
|
|
daemon.trans_commit_finished.connect (on_trans_commit_finished);
|
|
|
|
daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished);
|
|
|
|
daemon.generate_mirrorlist_start.connect (on_generate_mirrorlist_start);
|
|
|
|
daemon.generate_mirrorlist_data.connect (on_generate_mirrorlist_data);
|
|
|
|
daemon.generate_mirrorlist_finished.connect (on_generate_mirrorlist_finished);
|
2014-10-22 13:44:02 -03:00
|
|
|
} catch (IOError e) {
|
|
|
|
stderr.printf ("IOError: %s\n", e.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|