revert to 5.1.1

This commit is contained in:
Chris Cromer
2017-10-02 10:23:53 -03:00
parent a2bd9f9ea8
commit abff38f95d
110 changed files with 3437 additions and 9525 deletions

View File

@@ -39,18 +39,11 @@ MANAGER_GRESOURCE_FILE = ../resources/pamac.manager.gresource.xml
INSTALLER_GRESOURCE_FILE = ../resources/pamac.installer.gresource.xml
binaries: pamac-clean-cache pamac-user-daemon pamac-system-daemon pamac-tray pamac-manager pamac-install
binaries: pamac-user-daemon pamac-system-daemon pamac-tray pamac-manager pamac-install
clean:
rm -f *.c pamac.h pamac.vapi libpamac.so pamac-user-daemon pamac-system-daemon pamac-tray pamac-tray-appindicator pamac-manager pamac-install
pamac-clean-cache: pamac_config.vala clean_cache.vala
valac -o pamac-clean-cache \
$(COMMON_VALA_FLAGS) \
--pkg=gio-2.0 \
pamac_config.vala \
clean_cache.vala
pamac-tray: $(COMMON_SOURCES) alpm_config.vala tray.vala tray-gtk.vala
valac -o pamac-tray \
$(COMMON_VALA_FLAGS) \
@@ -76,7 +69,6 @@ pamac-user-daemon: ../vapi/libalpm.vapi alpm_config.vala common.vala package.val
$(ALPM_VALA_FLAGS) \
--pkg=json-glib-1.0 \
--pkg=libsoup-2.4 \
--pkg=appstream-glib \
--thread \
alpm_config.vala \
common.vala \
@@ -120,7 +112,6 @@ pamac-manager: libpamac.so ../resources/manager_resources.c history_dialog.vala
$(PAMAC_LIB_FLAGS) \
--pkg=gtk+-3.0 \
--pkg=gdk-3.0 \
--pkg=libsoup-2.4 \
--gresources=$(MANAGER_GRESOURCE_FILE) \
../resources/manager_resources.c \
history_dialog.vala \

View File

@@ -142,7 +142,7 @@ class AlpmConfig {
try {
Process.spawn_command_line_sync ("mkdir -p %s".printf (tmp_dbpath));
Process.spawn_command_line_sync ("ln -sf %s/local %s".printf (dbpath, tmp_dbpath));
Process.spawn_command_line_sync ("cp -a %s/sync %s".printf (dbpath, tmp_dbpath));
Process.spawn_command_line_sync ("cp -au %s/sync %s".printf (dbpath, tmp_dbpath));
Process.spawn_command_line_sync ("chmod -R 777 %s/sync".printf (tmp_dbpath));
handle = new Alpm.Handle (rootdir, tmp_dbpath, out error);
} catch (SpawnError e) {

View File

@@ -61,7 +61,7 @@ namespace Pamac {
this.set_accels_for_action ("app.back", accels);
// search accel
action = new SimpleAction ("search", null);
action.activate.connect (() => {manager_window.search_button.activate ();});
action.activate.connect (() => {manager_window.filters_stack.visible_child_name = "search";});
this.add_action (action);
accels = {"<Ctrl>F"};
this.set_accels_for_action ("app.search", accels);
@@ -70,16 +70,11 @@ namespace Pamac {
public override int command_line (ApplicationCommandLine cmd) {
if (cmd.get_arguments ()[0] == "pamac-updater") {
if (!started) {
manager_window.update_lists ();
started = true;
}
manager_window.display_package_queue.clear ();
manager_window.main_stack.visible_child_name = "browse";
manager_window.filters_stack.visible_child_name = "updates";
} else if (!started) {
manager_window.update_lists ();
manager_window.refresh_packages_list ();
manager_window.show_default_pkgs ();
started = true;
}
if (!pamac_run) {

File diff suppressed because it is too large Load Diff

View File

@@ -20,7 +20,6 @@
namespace Pamac {
public struct AlpmPackage {
public string name;
public string app_name;
public string version;
public string installed_version;
public string desc;
@@ -28,20 +27,15 @@ namespace Pamac {
public uint64 size;
public uint64 download_size;
public uint origin;
public string icon;
}
public struct AlpmPackageDetails {
public string name;
public string app_name;
public string version;
public string desc;
public string long_desc;
public string repo;
public uint origin;
public string url;
public string icon;
public string screenshot;
public string packager;
public string builddate;
public string installdate;
@@ -75,9 +69,9 @@ namespace Pamac {
public string packagebase;
public string url;
public string maintainer;
public string firstsubmitted;
public string lastmodified;
public string outofdate;
public int64 firstsubmitted;
public int64 lastmodified;
public int64 outofdate;
public int64 numvotes;
public string[] licenses;
public string[] depends;

View File

@@ -26,10 +26,8 @@ namespace Pamac {
public uint64 refresh_period { get; private set; }
public bool no_update_hide_icon { get; private set; }
public bool enable_aur { get; private set; }
public string aur_build_dir { get; private set; }
public bool search_aur { get; private set; }
public bool check_aur_updates { get; private set; }
public uint64 keep_num_pkgs { get; private set; }
public bool rm_only_uninstalled { get; private set; }
public unowned HashTable<string,string> environment_variables {
get {
return _environment_variables;
@@ -72,10 +70,8 @@ namespace Pamac {
recurse = false;
no_update_hide_icon = false;
enable_aur = false;
aur_build_dir = "/tmp";
search_aur = false;
check_aur_updates = false;
keep_num_pkgs = 3;
rm_only_uninstalled = false;
parse_file (conf_path);
}
@@ -107,21 +103,12 @@ namespace Pamac {
unowned string val = splitted[1]._strip ();
refresh_period = uint64.parse (val);
}
} else if (key == "KeepNumPackages") {
if (splitted.length == 2) {
unowned string val = splitted[1]._strip ();
keep_num_pkgs = uint64.parse (val);
}
} else if (key == "OnlyRmUninstalled") {
rm_only_uninstalled = true;
} else if (key == "NoUpdateHideIcon") {
no_update_hide_icon = true;
} else if (key == "EnableAUR") {
enable_aur = true;
} else if (key == "BuildDirectory") {
if (splitted.length == 2) {
aur_build_dir = splitted[1]._strip ();
}
} else if (key == "SearchInAURByDefault") {
search_aur = true;
} else if (key == "CheckAURUpdates") {
check_aur_updates = true;
}
@@ -168,24 +155,6 @@ namespace Pamac {
} else {
data.append (line + "\n");
}
} else if (line.contains ("KeepNumPackages")) {
if (new_conf.lookup_extended ("KeepNumPackages", null, out variant)) {
data.append ("KeepNumPackages = %llu\n".printf (variant.get_uint64 ()));
new_conf.remove ("KeepNumPackages");
} else {
data.append (line + "\n");
}
} else if (line.contains ("OnlyRmUninstalled")) {
if (new_conf.lookup_extended ("OnlyRmUninstalled", null, out variant)) {
if (variant.get_boolean ()) {
data.append ("OnlyRmUninstalled\n");
} else {
data.append ("#OnlyRmUninstalled\n");
}
new_conf.remove ("OnlyRmUninstalled");
} else {
data.append (line + "\n");
}
} else if (line.contains ("NoUpdateHideIcon")) {
if (new_conf.lookup_extended ("NoUpdateHideIcon", null, out variant)) {
if (variant.get_boolean ()) {
@@ -208,10 +177,14 @@ namespace Pamac {
} else {
data.append (line + "\n");
}
} else if (line.contains ("BuildDirectory")) {
if (new_conf.lookup_extended ("BuildDirectory", null, out variant)) {
data.append ("BuildDirectory = %s\n".printf (variant.get_string ()));
new_conf.remove ("BuildDirectory");
} else if (line.contains ("SearchInAURByDefault")) {
if (new_conf.lookup_extended ("SearchInAURByDefault", null, out variant)) {
if (variant.get_boolean ()) {
data.append ("SearchInAURByDefault\n");
} else {
data.append ("#SearchInAURByDefault\n");
}
new_conf.remove ("SearchInAURByDefault");
} else {
data.append (line + "\n");
}
@@ -253,14 +226,6 @@ namespace Pamac {
}
} else if (key == "RefreshPeriod") {
data.append ("RefreshPeriod = %llu\n".printf (val.get_uint64 ()));
} else if (key == "KeepNumPackages") {
data.append ("KeepNumPackages = %llu\n".printf (val.get_uint64 ()));
} else if (key == "OnlyRmUninstalled") {
if (val.get_boolean ()) {
data.append ("OnlyRmUninstalled\n");
} else {
data.append ("#OnlyRmUninstalled\n");
}
} else if (key =="NoUpdateHideIcon") {
if (val.get_boolean ()) {
data.append ("NoUpdateHideIcon\n");
@@ -273,8 +238,12 @@ namespace Pamac {
} else {
data.append ("#EnableAUR\n");
}
} else if (key == "BuildDirectory") {
data.append ("BuildDirectory = %s\n".printf (val.get_string ()));
} else if (key == "SearchInAURByDefault") {
if (val.get_boolean ()) {
data.append ("SearchInAURByDefault\n");
} else {
data.append ("#SearchInAURByDefault\n");
}
} else if (key == "CheckAURUpdates") {
if (val.get_boolean ()) {
data.append ("CheckAURUpdates\n");

View File

@@ -49,9 +49,7 @@ namespace Pamac {
[GtkChild]
Gtk.Switch enable_aur_button;
[GtkChild]
Gtk.Label aur_build_dir_label;
[GtkChild]
Gtk.FileChooserButton aur_build_dir_file_chooser;
Gtk.CheckButton search_aur_checkbutton;
[GtkChild]
Gtk.CheckButton check_aur_updates_checkbutton;
[GtkChild]
@@ -64,16 +62,14 @@ namespace Pamac {
Gtk.ListStore ignorepkgs_liststore;
Transaction transaction;
uint64 previous_refresh_period;
string[] countries;
public PreferencesDialog (Transaction transaction) {
int use_header_bar;
Gtk.Settings.get_default ().get ("gtk-dialogs-use-header", out use_header_bar);
Object (transient_for: transaction.application_window, use_header_bar: use_header_bar);
Object (transient_for: transaction.application_window, use_header_bar: 1);
this.transaction = transaction;
refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":");
cache_keep_nb_label.set_markup (dgettext (null, "Number of versions of each package to keep in the cache") +":");
aur_build_dir_label.set_markup (dgettext (null, "Build directory") +":");
remove_unrequired_deps_button.active = transaction.recurse;
check_space_button.active = transaction.get_checkspace ();
if (transaction.refresh_period == 0) {
@@ -91,8 +87,6 @@ namespace Pamac {
previous_refresh_period = transaction.refresh_period;
}
no_update_hide_icon_checkbutton.active = transaction.no_update_hide_icon;
cache_keep_nb_spin_button.value = transaction.keep_num_pkgs;
cache_only_uninstalled_checkbutton.active = transaction.rm_only_uninstalled;
// populate ignorepkgs_liststore
ignorepkgs_liststore = new Gtk.ListStore (1, typeof (string));
@@ -106,8 +100,6 @@ namespace Pamac {
check_updates_button.state_set.connect (on_check_updates_button_state_set);
refresh_period_spin_button.value_changed.connect (on_refresh_period_spin_button_value_changed);
no_update_hide_icon_checkbutton.toggled.connect (on_no_update_hide_icon_checkbutton_toggled);
cache_keep_nb_spin_button.value_changed.connect (on_cache_keep_nb_spin_button_value_changed);
cache_only_uninstalled_checkbutton.toggled.connect (on_cache_only_uninstalled_checkbutton_toggled);
transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished);
AlpmPackage pkg = transaction.find_installed_satisfier ("pacman-mirrors");
@@ -117,11 +109,9 @@ namespace Pamac {
var mirrors_config = new MirrorsConfig ("/etc/pacman-mirrors.conf");
mirrors_country_comboboxtext.append_text (dgettext (null, "Worldwide"));
mirrors_country_comboboxtext.active = 0;
if (transaction.preferences_available_countries.length == 0) {
transaction.preferences_available_countries = transaction.get_mirrors_countries ();
}
countries = transaction.get_mirrors_countries ();
int index = 1;
foreach (unowned string country in transaction.preferences_available_countries) {
foreach (unowned string country in countries) {
mirrors_country_comboboxtext.append_text (country);
if (country == mirrors_config.choosen_country) {
mirrors_country_comboboxtext.active = index;
@@ -141,19 +131,12 @@ namespace Pamac {
}
enable_aur_button.active = transaction.enable_aur;
aur_build_dir_label.sensitive = transaction.enable_aur;
aur_build_dir_file_chooser.sensitive = transaction.enable_aur;
aur_build_dir_file_chooser.set_filename (transaction.aur_build_dir);
// add /tmp choice always visible
try {
aur_build_dir_file_chooser.add_shortcut_folder ("/tmp");
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
}
search_aur_checkbutton.active = transaction.search_aur;
search_aur_checkbutton.sensitive = transaction.enable_aur;
check_aur_updates_checkbutton.active = transaction.check_aur_updates;
check_aur_updates_checkbutton.sensitive = transaction.enable_aur;
enable_aur_button.state_set.connect (on_enable_aur_button_state_set);
aur_build_dir_file_chooser.file_set.connect (on_aur_build_dir_set);
search_aur_checkbutton.toggled.connect (on_search_aur_checkbutton_toggled);
check_aur_updates_checkbutton.toggled.connect (on_check_aur_updates_checkbutton_toggled);
}
@@ -185,18 +168,6 @@ namespace Pamac {
transaction.start_write_pamac_config (new_pamac_conf);
}
void on_cache_keep_nb_spin_button_value_changed () {
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
new_pamac_conf.insert ("KeepNumPackages", new Variant.uint64 (cache_keep_nb_spin_button.get_value_as_int ()));
transaction.start_write_pamac_config (new_pamac_conf);
}
void on_cache_only_uninstalled_checkbutton_toggled () {
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
new_pamac_conf.insert ("OnlyRmUninstalled", new Variant.boolean (cache_only_uninstalled_checkbutton.active));
transaction.start_write_pamac_config (new_pamac_conf);
}
void on_no_update_hide_icon_checkbutton_toggled () {
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
new_pamac_conf.insert ("NoUpdateHideIcon", new Variant.boolean (no_update_hide_icon_checkbutton.active));
@@ -210,9 +181,9 @@ namespace Pamac {
return true;
}
void on_aur_build_dir_set () {
void on_search_aur_checkbutton_toggled () {
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
new_pamac_conf.insert ("BuildDirectory", new Variant.string (aur_build_dir_file_chooser.get_filename ()));
new_pamac_conf.insert ("SearchInAURByDefault", new Variant.boolean (search_aur_checkbutton.active));
transaction.start_write_pamac_config (new_pamac_conf);
}
@@ -223,7 +194,7 @@ namespace Pamac {
}
void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, string aur_build_dir, bool check_aur_updates) {
bool enable_aur, bool search_aur, bool check_aur_updates) {
remove_unrequired_deps_button.state = recurse;
if (refresh_period == 0) {
check_updates_button.state = false;
@@ -242,8 +213,8 @@ namespace Pamac {
}
no_update_hide_icon_checkbutton.active = no_update_hide_icon;
enable_aur_button.state = enable_aur;
aur_build_dir_label.sensitive = enable_aur;
aur_build_dir_file_chooser.sensitive = enable_aur;
search_aur_checkbutton.active = search_aur;
search_aur_checkbutton.sensitive = enable_aur;
check_aur_updates_checkbutton.active = check_aur_updates;
check_aur_updates_checkbutton.sensitive = enable_aur;
}
@@ -318,6 +289,7 @@ namespace Pamac {
var new_alpm_conf = new HashTable<string,Variant> (str_hash, str_equal);
new_alpm_conf.insert ("IgnorePkg", new Variant.string (ignorepkg_string.str));
transaction.start_write_alpm_config (new_alpm_conf);
}
}
@@ -381,7 +353,8 @@ namespace Pamac {
[GtkCallback]
void on_cache_clean_button_clicked () {
transaction.clean_cache (transaction.keep_num_pkgs, transaction.rm_only_uninstalled);
transaction.clean_cache ((uint) cache_keep_nb_spin_button.get_value_as_int (),
cache_only_uninstalled_checkbutton.active);
}
}
}

View File

@@ -87,7 +87,7 @@ namespace Pamac {
public signal void trans_commit_finished (bool success);
public signal void get_authorization_finished (bool authorized);
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, string aur_build_dir, bool check_aur_updates);
bool enable_aur, bool search_aur, bool check_aur_updates);
public signal void write_alpm_config_finished (bool checkspace);
public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method);
public signal void generate_mirrors_list_data (string line);
@@ -339,7 +339,7 @@ namespace Pamac {
pamac_config.reload ();
}
write_pamac_config_finished (pamac_config.recurse, pamac_config.refresh_period, pamac_config.no_update_hide_icon,
pamac_config.enable_aur, pamac_config.aur_build_dir, pamac_config.check_aur_updates);
pamac_config.enable_aur, pamac_config.search_aur, pamac_config.check_aur_updates);
});
}
@@ -379,7 +379,6 @@ namespace Pamac {
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
}
alpm_config.reload ();
refresh_handle ();
generate_mirrors_list_finished ();
}
@@ -397,12 +396,12 @@ namespace Pamac {
});
}
public void clean_cache (uint64 keep_nb, bool only_uninstalled, GLib.BusName sender) {
public void clean_cache (uint keep_nb, bool only_uninstalled, GLib.BusName sender) {
check_authorization.begin (sender, (obj, res) => {
bool authorized = check_authorization.end (res);
if (authorized) {
string[] commands = {"paccache", "--nocolor", "-rq"};
commands += "-k%llu".printf (keep_nb);
string[] commands = {"paccache", "-rq"};
commands += "-k%u".printf (keep_nb);
if (only_uninstalled) {
commands += "-u";
}
@@ -552,23 +551,19 @@ namespace Pamac {
}
return AlpmPackage () {
name = alpm_pkg.name,
app_name = "",
version = alpm_pkg.version,
// desc can be null
desc = alpm_pkg.desc ?? "",
repo = (owned) repo_name,
size = alpm_pkg.isize,
origin = (uint) alpm_pkg.origin,
icon = ""
origin = (uint) alpm_pkg.origin
};
} else {
return AlpmPackage () {
name = "",
app_name = "",
version = "",
desc = "",
repo = "",
icon = ""
repo = ""
};
}
}

View File

@@ -21,7 +21,6 @@ namespace Pamac {
[DBus (name = "org.manjaro.pamac.user")]
interface UserDaemon : Object {
public abstract void refresh_handle () throws IOError;
public abstract string get_lockfile () throws IOError;
public abstract AlpmPackage get_installed_pkg (string pkgname) throws IOError;
public abstract bool get_checkspace () throws IOError;
public abstract string[] get_ignorepkgs () throws IOError;
@@ -37,12 +36,11 @@ namespace Pamac {
public abstract AlpmPackage find_sync_satisfier (string depstring) throws IOError;
public abstract async AlpmPackage[] search_pkgs (string search_string) throws IOError;
public abstract async AURPackage[] search_in_aur (string search_string) throws IOError;
public abstract async AlpmPackage[] get_category_pkgs (string category) throws IOError;
public abstract string[] get_repos_names () throws IOError;
public abstract async AlpmPackage[] get_repo_pkgs (string repo) throws IOError;
public abstract string[] get_groups_names () throws IOError;
public abstract async AlpmPackage[] get_group_pkgs (string groupname) throws IOError;
public abstract AlpmPackageDetails get_pkg_details (string pkgname, string app_name) throws IOError;
public abstract AlpmPackageDetails get_pkg_details (string pkgname) throws IOError;
public abstract string[] get_pkg_files (string pkgname) throws IOError;
public abstract async AURPackageDetails get_aur_details (string pkgname) throws IOError;
public abstract string[] get_pkg_uninstalled_optdeps (string pkgname) throws IOError;
@@ -63,7 +61,7 @@ namespace Pamac {
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_generate_mirrors_list () throws IOError;
public abstract void clean_cache (uint64 keep_nb, bool only_uninstalled) throws IOError;
public abstract void clean_cache (uint keep_nb, bool only_uninstalled) throws IOError;
public abstract void start_set_pkgreason (string pkgname, uint reason) throws IOError;
public abstract void start_refresh (bool force) throws IOError;
public abstract void start_sysupgrade_prepare (bool enable_downgrade, string[] temporary_ignorepkgs) throws IOError;
@@ -89,7 +87,7 @@ namespace Pamac {
public signal void trans_commit_finished (bool success);
public signal void get_authorization_finished (bool authorized);
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, string aur_build_dir, bool check_aur_updates);
bool enable_aur, bool search_aur, bool check_aur_updates);
public signal void write_alpm_config_finished (bool checkspace);
public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method);
public signal void generate_mirrors_list_data (string line);
@@ -120,9 +118,7 @@ namespace Pamac {
public bool no_update_hide_icon { get { return pamac_config.no_update_hide_icon; } }
public bool recurse { get { return pamac_config.recurse; } }
public uint64 refresh_period { get { return pamac_config.refresh_period; } }
public string aur_build_dir { get { return pamac_config.aur_build_dir; } }
public uint64 keep_num_pkgs { get { return pamac_config.keep_num_pkgs; } }
public bool rm_only_uninstalled { get { return pamac_config.rm_only_uninstalled; } }
public bool search_aur { get { return pamac_config.search_aur; } }
//Alpm.TransFlag
int flags;
@@ -138,7 +134,6 @@ namespace Pamac {
GenericSet<string?> previous_to_remove;
public GenericSet<string?> transaction_summary;
public GenericSet<string?> temporary_ignorepkgs;
public GLib.File lockfile;
uint64 total_download;
uint64 already_downloaded;
@@ -159,7 +154,6 @@ namespace Pamac {
StringBuilder warning_textbuffer;
//dialogs
public string[] preferences_available_countries;
TransactionSumDialog transaction_sum_dialog;
public ProgressBox progress_box;
Vte.Terminal term;
@@ -177,7 +171,7 @@ namespace Pamac {
public signal void finished (bool success);
public signal void set_pkgreason_finished ();
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, string aur_build_dir, bool check_aur_updates);
bool enable_aur, bool search_aur, bool check_aur_updates);
public signal void write_alpm_config_finished (bool checkspace);
public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method);
public signal void generate_mirrors_list ();
@@ -202,10 +196,8 @@ namespace Pamac {
transaction_summary = new GenericSet<string?> (str_hash, str_equal);
temporary_ignorepkgs = new GenericSet<string?> (str_hash, str_equal);
connecting_user_daemon ();
get_lockfile ();
//creating dialogs
this.application_window = application_window;
preferences_available_countries = {};
transaction_sum_dialog = new TransactionSumDialog (application_window);
progress_box = new ProgressBox ();
progress_box.progressbar.text = "";
@@ -450,7 +442,7 @@ namespace Pamac {
}
}
public void clean_cache (uint64 keep_nb, bool only_uninstalled) {
public void clean_cache (uint keep_nb, bool only_uninstalled) {
try {
system_daemon.clean_cache (keep_nb, only_uninstalled);
} catch (IOError e) {
@@ -495,22 +487,11 @@ namespace Pamac {
public void refresh_handle () {
try {
user_daemon.refresh_handle ();
get_lockfile ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
}
void get_lockfile () {
try {
lockfile = GLib.File.new_for_path (user_daemon.get_lockfile ());
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
//try standard lock file
lockfile = GLib.File.new_for_path ("var/lib/pacman/db.lck");
}
}
public bool get_checkspace () {
bool checkspace = false;
try {
@@ -677,16 +658,6 @@ namespace Pamac {
return pkgs;
}
public async AlpmPackage[] get_category_pkgs (string category) {
AlpmPackage[] pkgs = {};
try {
pkgs = yield user_daemon.get_category_pkgs (category);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
return pkgs;
}
public string[] get_repos_names () {
string[] repos_names = {};
try {
@@ -737,9 +708,9 @@ namespace Pamac {
return optdeps;
}
public AlpmPackageDetails get_pkg_details (string pkgname, string app_name) {
public AlpmPackageDetails get_pkg_details (string pkgname) {
try {
return user_daemon.get_pkg_details (pkgname, app_name);
return user_daemon.get_pkg_details (pkgname);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
return AlpmPackageDetails () {
@@ -1108,12 +1079,7 @@ namespace Pamac {
to_build.remove_all ();
string [] built_pkgs = {};
int status = 1;
string builddir;
if (aur_build_dir == "/tmp") {
builddir = "/tmp/pamac-build-%s".printf (Environment.get_user_name ());
} else {
builddir = aur_build_dir;
}
string builddir = "/tmp/pamac-build-%s".printf (Environment.get_user_name ());
status = yield spawn_in_term ({"mkdir", "-p", builddir});
if (status == 0) {
status = yield spawn_in_term ({"rm", "-rf", pkgname}, builddir);
@@ -1782,7 +1748,7 @@ namespace Pamac {
}
void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, string aur_build_dir, bool check_aur_updates) {
bool enable_aur, bool search_aur, bool check_aur_updates) {
system_daemon.write_pamac_config_finished.disconnect (on_write_pamac_config_finished);
pamac_config.reload ();
flags = (1 << 4); //Alpm.TransFlag.CASCADE
@@ -1790,11 +1756,10 @@ namespace Pamac {
flags |= (1 << 5); //Alpm.TransFlag.RECURSE
}
write_pamac_config_finished (recurse, refresh_period, no_update_hide_icon,
enable_aur, aur_build_dir, check_aur_updates);
enable_aur, search_aur, check_aur_updates);
}
void on_write_alpm_config_finished (bool checkspace) {
refresh_handle ();
system_daemon.write_alpm_config_finished.disconnect (on_write_alpm_config_finished);
write_alpm_config_finished (checkspace);
}

View File

@@ -132,7 +132,7 @@ namespace Pamac {
set_tooltip (noupdate_info);
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
set_icon_visible (!pamac_config.no_update_hide_icon);
close_notification ();
close_notification();
} else {
string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
set_icon (update_icon_name);
@@ -149,7 +149,7 @@ namespace Pamac {
void show_notification (string info) {
try {
close_notification ();
close_notification();
notification = new Notify.Notification (_("Package Manager"), info, "system-software-update");
notification.add_action ("default", _("Details"), execute_updater);
notification.show ();
@@ -161,7 +161,7 @@ namespace Pamac {
void update_notification (string info) {
try {
if (notification != null) {
if (notification.get_closed_reason () == -1 && notification.body != info) {
if (notification.get_closed_reason() == -1 && notification.body != info) {
notification.update (_("Package Manager"), info, "system-software-update");
notification.show ();
}
@@ -175,9 +175,9 @@ namespace Pamac {
void close_notification () {
try {
if (notification != null && notification.get_closed_reason () == -1) {
notification.close ();
notification = null;
if (notification != null) {
notification.close();
notification = null;
}
} catch (Error e) {
stderr.printf ("Notify Error: %s", e.message);

View File

@@ -84,51 +84,29 @@ namespace Pamac {
private AlpmConfig alpm_config;
private Alpm.Handle? alpm_handle;
private Alpm.Handle? files_handle;
private bool repos_updates_checked;
private AlpmPackage[] repos_updates;
private bool check_aur_updates;
private bool aur_updates_checked;
private AURPackage[] aur_updates;
private Json.Array aur_updates_results;
private HashTable<string, Json.Array> aur_search_results;
private HashTable<string, Json.Object> aur_infos;
private As.Store app_store;
private string locale;
public signal void get_updates_finished (Updates updates);
public UserDaemon () {
alpm_config = new AlpmConfig ("/etc/pacman.conf");
repos_updates = {};
aur_updates = {};
aur_updates_results = new Json.Array ();
aur_search_results = new HashTable<string, Json.Array> (str_hash, str_equal);
aur_infos = new HashTable<string, Json.Object> (str_hash, str_equal);
refresh_handle ();
// init appstream
app_store = new As.Store ();
locale = Environ.get_variable (Environ.get (), "LANG");
if (locale != null) {
// remove .UTF-8 from locale
locale = locale.split (".")[0];
} else {
locale = "C";
}
try {
app_store.load (As.StoreLoadFlags.APP_INFO_SYSTEM);
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
}
}
public void refresh_handle () {
alpm_config.reload ();
alpm_handle = alpm_config.get_handle ();
if (alpm_handle == null) {
return;
} else {
files_handle = alpm_config.get_handle (true);
}
repos_updates_checked = false;
aur_updates_checked = false;
}
public bool get_checkspace () {
@@ -178,74 +156,10 @@ namespace Pamac {
return 0;
}
private string get_localized_string (HashTable<string,string> hashtable) {
unowned string val;
if (!hashtable.lookup_extended (locale, null, out val)) {
// try with just the language
if (!hashtable.lookup_extended (locale.split ("_")[0], null, out val)) {
// try C locale
if (!hashtable.lookup_extended ("C", null, out val)) {
return "";
}
}
}
return val;
}
private string get_app_name (As.App app) {
return get_localized_string (app.get_names ());
}
private string get_app_summary (As.App app) {
return get_localized_string (app.get_comments ());
}
private string get_app_description (As.App app) {
return get_localized_string (app.get_descriptions ());
}
private string get_app_icon (As.App app, string dbname) {
string icon = "";
app.get_icons ().foreach ((as_icon) => {
if (as_icon.get_kind () == As.IconKind.CACHED) {
if (as_icon.get_height () == 64) {
icon = "/usr/share/app-info/icons/archlinux-arch-%s/64x64/%s".printf (dbname, as_icon.get_name ());
}
}
});
return icon;
}
private string get_app_screenshot (As.App app) {
string screenshot = "";
app.get_screenshots ().foreach ((as_screenshot) => {
if (as_screenshot.get_kind () == As.ScreenshotKind.DEFAULT) {
As.Image? as_image = as_screenshot.get_source ();
if (as_image != null) {
screenshot = as_image.get_url ();
}
}
});
return screenshot;
}
private As.App[] get_pkgname_matching_apps (string pkgname) {
As.App[] matching_apps = {};
app_store.get_apps ().foreach ((app) => {
if (app.get_pkgname_default () == pkgname) {
matching_apps += app;
}
});
return matching_apps;
}
private AlpmPackage initialise_pkg_struct (Alpm.Package? alpm_pkg) {
if (alpm_pkg != null) {
string installed_version = "";
string repo_name = "";
string desc = alpm_pkg.desc ?? "";
string icon = "";
string app_name = "";
if (alpm_pkg.origin == Alpm.Package.From.LOCALDB) {
installed_version = alpm_pkg.version;
unowned Alpm.Package? sync_pkg = get_syncpkg (alpm_pkg.name);
@@ -259,117 +173,34 @@ namespace Pamac {
}
repo_name = alpm_pkg.db.name;
}
if (repo_name != "") {
// find if pkgname provides only one app
As.App[] matching_apps = get_pkgname_matching_apps (alpm_pkg.name);
if (matching_apps.length == 1) {
As.App app = matching_apps[0];
app_name = get_app_name (app);
desc = get_app_summary (app);
icon = get_app_icon (app, repo_name);
}
}
return AlpmPackage () {
name = alpm_pkg.name,
app_name = (owned) app_name,
version = alpm_pkg.version,
installed_version = (owned) installed_version,
desc = (owned) desc,
// desc can be null
desc = alpm_pkg.desc ?? "",
repo = (owned) repo_name,
size = alpm_pkg.isize,
download_size = alpm_pkg.download_size,
origin = (uint) alpm_pkg.origin,
icon = (owned) icon
origin = (uint) alpm_pkg.origin
};
} else {
return AlpmPackage () {
name = "",
app_name = "",
version = "",
installed_version = "",
desc = "",
repo = "",
icon = ""
repo = ""
};
}
}
private AlpmPackage[] initialise_pkg_structs (Alpm.Package? alpm_pkg) {
AlpmPackage[] pkgs = {};
if (alpm_pkg != null) {
string installed_version = "";
string repo_name = "";
if (alpm_pkg.origin == Alpm.Package.From.LOCALDB) {
installed_version = alpm_pkg.version;
unowned Alpm.Package? sync_pkg = get_syncpkg (alpm_pkg.name);
if (sync_pkg != null) {
repo_name = sync_pkg.db.name;
}
} else if (alpm_pkg.origin == Alpm.Package.From.SYNCDB) {
unowned Alpm.Package? local_pkg = alpm_handle.localdb.get_pkg (alpm_pkg.name);
if (local_pkg != null) {
installed_version = local_pkg.version;
}
repo_name = alpm_pkg.db.name;
}
if (repo_name != "") {
As.App[] apps = get_pkgname_matching_apps (alpm_pkg.name);
if (apps.length > 0) {
// alpm_pkg provide some apps
foreach (unowned As.App app in apps) {
pkgs += AlpmPackage () {
name = alpm_pkg.name,
app_name = get_app_name (app),
version = alpm_pkg.version,
installed_version = installed_version,
desc = get_app_summary (app),
repo = repo_name,
size = alpm_pkg.isize,
download_size = alpm_pkg.download_size,
origin = (uint) alpm_pkg.origin,
icon = get_app_icon (app, repo_name)
};
}
} else {
pkgs += AlpmPackage () {
name = alpm_pkg.name,
app_name = "",
version = alpm_pkg.version,
installed_version = installed_version,
desc = alpm_pkg.desc ?? "",
repo = repo_name,
size = alpm_pkg.isize,
download_size = alpm_pkg.download_size,
origin = (uint) alpm_pkg.origin,
icon = ""
};
}
} else {
pkgs += AlpmPackage () {
name = alpm_pkg.name,
app_name = "",
version = alpm_pkg.version,
installed_version = installed_version,
desc = alpm_pkg.desc ?? "",
repo = repo_name,
size = alpm_pkg.isize,
download_size = alpm_pkg.download_size,
origin = (uint) alpm_pkg.origin,
icon = ""
};
}
}
return pkgs;
}
public async AlpmPackage[] get_installed_pkgs () {
AlpmPackage[] pkgs = {};
unowned Alpm.List<unowned Alpm.Package> pkgcache = alpm_handle.localdb.pkgcache;
while (pkgcache != null) {
unowned Alpm.Package alpm_pkg = pkgcache.data;
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (alpm_pkg)) {
pkgs += pkg;
}
pkgs += initialise_pkg_struct (alpm_pkg);
pkgcache.next ();
}
return pkgs;
@@ -381,9 +212,7 @@ namespace Pamac {
while (pkgcache != null) {
unowned Alpm.Package alpm_pkg = pkgcache.data;
if (alpm_pkg.reason == Alpm.Package.Reason.EXPLICIT) {
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (alpm_pkg)) {
pkgs += pkg;
}
pkgs += initialise_pkg_struct (alpm_pkg);
}
pkgcache.next ();
}
@@ -407,9 +236,7 @@ namespace Pamac {
syncdbs.next ();
}
if (sync_found == false) {
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (alpm_pkg)) {
pkgs += pkg;
}
pkgs += initialise_pkg_struct (alpm_pkg);
}
pkgcache.next ();
}
@@ -426,9 +253,7 @@ namespace Pamac {
if (requiredby.length == 0) {
Alpm.List<string> optionalfor = alpm_pkg.compute_optionalfor ();
if (optionalfor.length == 0) {
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (alpm_pkg)) {
pkgs += pkg;
}
pkgs += initialise_pkg_struct (alpm_pkg);
} else {
optionalfor.free_inner (GLib.free);
}
@@ -511,17 +336,15 @@ namespace Pamac {
}
public async AlpmPackage[] search_pkgs (string search_string) {
AlpmPackage[] pkgs = {};
AlpmPackage[] result = {};
Alpm.List<unowned Alpm.Package> alpm_pkgs = search_all_dbs (search_string);
unowned Alpm.List<unowned Alpm.Package> list = alpm_pkgs;
while (list != null) {
unowned Alpm.Package alpm_pkg = list.data;
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (alpm_pkg)) {
pkgs += pkg;
}
result += initialise_pkg_struct (alpm_pkg);
list.next ();
}
return pkgs;
return result;
}
private AURPackage initialise_aur_struct (Json.Object json_object) {
@@ -565,9 +388,9 @@ namespace Pamac {
string packagebase = "";
string url = "";
string maintainer = "";
string firstsubmitted = "";
string lastmodified = "";
string outofdate = "";
int64 firstsubmitted = 0;
int64 lastmodified = 0;
int64 outofdate = 0;
int64 numvotes = 0;
string[] licenses = {};
string[] depends = {};
@@ -608,16 +431,13 @@ namespace Pamac {
maintainer = node.get_string ();
}
// firstsubmitted
GLib.Time time = GLib.Time.local ((time_t) json_object.get_int_member ("FirstSubmitted"));
firstsubmitted = time.format ("%x");
firstsubmitted = json_object.get_int_member ("FirstSubmitted");
// lastmodified
time = GLib.Time.local ((time_t) json_object.get_int_member ("LastModified"));
lastmodified = time.format ("%x");
lastmodified = json_object.get_int_member ("LastModified");
// outofdate can be null
node = json_object.get_member ("OutOfDate");
if (!node.is_null ()) {
time = GLib.Time.local ((time_t) node.get_int ());
outofdate = time.format ("%x");
outofdate = node.get_int ();
}
//numvotes
numvotes = json_object.get_int_member ("NumVotes");
@@ -724,13 +544,9 @@ namespace Pamac {
unowned Alpm.Package sync_pkg = pkgcache.data;
unowned Alpm.Package? local_pkg = alpm_handle.localdb.get_pkg (sync_pkg.name);
if (local_pkg != null) {
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (local_pkg)) {
pkgs += pkg;
}
pkgs += initialise_pkg_struct (local_pkg);
} else {
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (sync_pkg)) {
pkgs += pkg;
}
pkgs += initialise_pkg_struct (sync_pkg);
}
pkgcache.next ();
}
@@ -803,53 +619,12 @@ namespace Pamac {
unowned Alpm.List<unowned Alpm.Package> list = alpm_pkgs;
while (list != null) {
unowned Alpm.Package alpm_pkg = list.data;
foreach (unowned AlpmPackage pkg in initialise_pkg_structs (alpm_pkg)) {
pkgs += pkg;
}
pkgs += initialise_pkg_struct (alpm_pkg);
list.next ();
}
return pkgs;
}
public async AlpmPackage[] get_category_pkgs (string category) {
AlpmPackage[] pkgs = {};
app_store.get_apps ().foreach ((app) => {
app.get_categories ().foreach ((cat_name) => {
if (cat_name == category) {
string pkgname = app.get_pkgname_default ();
string installed_version = "";
string repo_name = "";
uint origin;
unowned Alpm.Package? local_pkg = alpm_handle.localdb.get_pkg (pkgname);
unowned Alpm.Package? sync_pkg = get_syncpkg (pkgname);
if (sync_pkg != null) {
if (local_pkg == null) {
repo_name = sync_pkg.db.name;
origin = (uint) sync_pkg.origin;
} else {
repo_name = sync_pkg.db.name;
installed_version = local_pkg.version;
origin = (uint) local_pkg.origin;
}
pkgs += AlpmPackage () {
name = sync_pkg.name,
app_name = get_app_name (app),
version = sync_pkg.version,
installed_version = (owned) installed_version,
desc = get_app_summary (app),
repo = (owned) repo_name,
size = sync_pkg.isize,
download_size = sync_pkg.download_size,
origin = origin,
icon = get_app_icon (app, sync_pkg.db.name)
};
}
}
});
});
return pkgs;
}
public string[] get_pkg_uninstalled_optdeps (string pkgname) {
string[] optdeps = {};
unowned Alpm.Package? alpm_pkg = alpm_handle.localdb.get_pkg (pkgname);
@@ -869,15 +644,11 @@ namespace Pamac {
return optdeps;
}
public AlpmPackageDetails get_pkg_details (string pkgname, string appname) {
public AlpmPackageDetails get_pkg_details (string pkgname) {
string name = "";
string app_name = "";
string version = "";
string desc = "";
string long_desc = "";
string url = "";
string icon = "";
string screenshot = "";
string repo = "";
string has_signature = "";
string reason = "";
@@ -896,9 +667,8 @@ namespace Pamac {
string[] conflicts = {};
var details = AlpmPackageDetails ();
unowned Alpm.Package? alpm_pkg = alpm_handle.localdb.get_pkg (pkgname);
unowned Alpm.Package? sync_pkg = get_syncpkg (pkgname);
if (alpm_pkg == null) {
alpm_pkg = sync_pkg;
alpm_pkg = get_syncpkg (pkgname);
}
if (alpm_pkg != null) {
// name
@@ -909,40 +679,6 @@ namespace Pamac {
if (alpm_pkg.desc != null) {
desc = alpm_pkg.desc;
}
if (sync_pkg != null) {
if (appname != "") {
app_store.get_apps ().foreach ((app) => {
if (get_app_name (app) == appname) {
if (app.get_pkgname_default () == alpm_pkg.name) {
app_name = appname;
desc = get_app_summary (app);
try {
long_desc = As.markup_convert_simple (get_app_description (app));
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
}
icon = get_app_icon (app, sync_pkg.db.name);
screenshot = get_app_screenshot (app);
}
}
});
} else {
// find if pkgname provides only one app
As.App[] matching_apps = get_pkgname_matching_apps (pkgname);
if (matching_apps.length == 1) {
As.App app = matching_apps[0];
app_name = get_app_name (app);
desc = get_app_summary (app);
try {
long_desc = As.markup_convert_simple (get_app_description (app));
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
}
icon = get_app_icon (app, sync_pkg.db.name);
screenshot = get_app_screenshot (app);
}
}
}
details.origin = (uint) alpm_pkg.origin;
// url can be null
if (alpm_pkg.url != null) {
@@ -964,10 +700,11 @@ namespace Pamac {
}
// build_date
GLib.Time time = GLib.Time.local ((time_t) alpm_pkg.builddate);
builddate = time.format ("%x");
builddate = time.format ("%a %d %b %Y %X %Z");
// local pkg
if (alpm_pkg.origin == Alpm.Package.From.LOCALDB) {
// repo
unowned Alpm.Package? sync_pkg = get_syncpkg (alpm_pkg.name);
if (sync_pkg != null) {
repo = sync_pkg.db.name;
}
@@ -981,7 +718,7 @@ namespace Pamac {
}
// install_date
time = GLib.Time.local ((time_t) alpm_pkg.installdate);
installdate = time.format ("%x");
installdate = time.format ("%a %d %b %Y %X %Z");
// backups
list = alpm_pkg.backups;
while (list != null) {
@@ -1043,14 +780,10 @@ namespace Pamac {
}
}
details.name = (owned) name;
details.app_name = (owned) app_name;
details.version = (owned) version;
details.desc = (owned) desc;
details.long_desc = (owned) long_desc;
details.repo = (owned) repo;
details.url = (owned) url;
details.icon = (owned) icon;
details.screenshot = (owned) screenshot;
details.packager = (owned) packager;
details.builddate = (owned) builddate;
details.installdate = (owned) installdate;
@@ -1102,15 +835,7 @@ namespace Pamac {
}
private int get_updates () {
if (repos_updates_checked && (aur_updates_checked || !check_aur_updates)) {
var updates = Updates () {
repos_updates = repos_updates,
aur_updates = aur_updates
};
get_updates_finished (updates);
return 0;
}
AlpmPackage[] repos_updates = {};
AlpmPackage[] updates_infos = {};
unowned Alpm.Package? pkg = null;
unowned Alpm.Package? candidate = null;
// use a tmp handle
@@ -1140,7 +865,7 @@ namespace Pamac {
if (candidate != null) {
var infos = initialise_pkg_struct (candidate);
infos.installed_version = installed_pkg.version;
repos_updates += (owned) infos;
updates_infos += (owned) infos;
} else {
if (check_aur_updates && (!aur_updates_checked)) {
// check if installed_pkg is a local pkg
@@ -1165,25 +890,24 @@ namespace Pamac {
// get aur updates
if (!aur_updates_checked) {
AUR.multiinfo.begin (local_pkgs, (obj, res) => {
var aur_updates_json = AUR.multiinfo.end (res);
aur_updates_results = AUR.multiinfo.end (res);
aur_updates_checked = true;
get_aur_updates (aur_updates_json);
var updates = Updates () {
repos_updates = repos_updates,
aur_updates = aur_updates
repos_updates = (owned) updates_infos,
aur_updates = get_aur_updates_infos ()
};
get_updates_finished (updates);
});
} else {
var updates = Updates () {
repos_updates = repos_updates,
aur_updates = aur_updates
repos_updates = (owned) updates_infos,
aur_updates = get_aur_updates_infos ()
};
get_updates_finished (updates);
}
} else {
var updates = Updates () {
repos_updates = repos_updates,
repos_updates = (owned) updates_infos,
aur_updates = {}
};
get_updates_finished (updates);
@@ -1191,9 +915,9 @@ namespace Pamac {
return 0;
}
private void get_aur_updates (Json.Array aur_updates_json) {
aur_updates = {};
aur_updates_json.foreach_element ((array, index, node) => {
private AURPackage[] get_aur_updates_infos () {
AURPackage[] aur_updates_infos = {};
aur_updates_results.foreach_element ((array, index, node) => {
unowned Json.Object pkg_info = node.get_object ();
unowned string name = pkg_info.get_string_member ("Name");
unowned string new_version = pkg_info.get_string_member ("Version");
@@ -1201,9 +925,10 @@ namespace Pamac {
if (Alpm.pkg_vercmp (new_version, old_version) == 1) {
var infos = initialise_aur_struct (pkg_info);
infos.installed_version = old_version;
aur_updates += (owned) infos;
aur_updates_infos += (owned) infos;
}
});
return aur_updates_infos;
}
public void start_get_updates (bool check_aur_updates_) {