From 69f4b4368eec0baf4572aa1ec9274093360bf2b0 Mon Sep 17 00:00:00 2001 From: guinux Date: Sun, 23 Aug 2015 13:00:55 +0200 Subject: [PATCH] use satisfier for AUR and mirrors support --- src/daemon.vala | 6 +++++- src/manager_window.vala | 2 +- src/preferences_dialog.vala | 4 ++-- src/transaction.vala | 11 +++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/daemon.vala b/src/daemon.vala index 66e3119..0368d2e 100644 --- a/src/daemon.vala +++ b/src/daemon.vala @@ -396,6 +396,10 @@ namespace Pamac { return Pamac.Package (alpm_config.handle.localdb.get_pkg (pkgname), null); } + public Pamac.Package find_local_satisfier (string pkgname) { + return Pamac.Package (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, pkgname), null); + } + private unowned Alpm.Package? get_syncpkg (string name) { unowned Alpm.Package? pkg = null; foreach (var db in alpm_config.handle.syncdbs) { @@ -514,7 +518,7 @@ namespace Pamac { } if (alpm_pkg != null) { foreach (unowned Depend optdep in alpm_pkg.optdepends) { - if (find_satisfier (alpm_config.handle.localdb.pkgcache, optdep.name) == null) { + if (Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, optdep.name) == null) { optdeps += optdep.compute_string (); } } diff --git a/src/manager_window.vala b/src/manager_window.vala index 933e012..56002cb 100644 --- a/src/manager_window.vala +++ b/src/manager_window.vala @@ -180,7 +180,7 @@ namespace Pamac { if (pamac_config.recurse) { transaction.flags |= Alpm.TransFlag.RECURSE; } - Pamac.Package pkg = transaction.find_local_pkg ("yaourt"); + Pamac.Package pkg = transaction.find_local_satisfier ("yaourt"); if (pkg.name == "") { enable_aur (false); } else { diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala index 0e82667..0240454 100644 --- a/src/preferences_dialog.vala +++ b/src/preferences_dialog.vala @@ -96,7 +96,7 @@ namespace Pamac { no_update_hide_icon_checkbutton.toggled.connect (on_no_update_hide_icon_checkbutton_toggled); transaction.daemon.write_pamac_config_finished.connect (on_write_pamac_config_finished); - Pamac.Package pkg = this.transaction.find_local_pkg ("pacman-mirrorlist"); + Pamac.Package pkg = this.transaction.find_local_satisfier ("pacman-mirrorlist"); if (pkg.name == "") { mirrors_config_box.visible = false; } else { @@ -124,7 +124,7 @@ namespace Pamac { transaction.daemon.write_mirrors_config_finished.connect (on_write_mirrors_config_finished); } - pkg = this.transaction.find_local_pkg ("yaourt"); + pkg = this.transaction.find_local_satisfier ("yaourt"); if (pkg.name == "") { aur_config_box.visible = false; } else { diff --git a/src/transaction.vala b/src/transaction.vala index cc58eac..2ce33e6 100644 --- a/src/transaction.vala +++ b/src/transaction.vala @@ -37,6 +37,7 @@ namespace Pamac { 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_local_satisfier (string pkgname) throws IOError; public abstract Pamac.Package find_sync_pkg (string pkgname) throws IOError; public abstract async Pamac.Package[] search_pkgs (string search_string, bool search_from_aur) throws IOError; public abstract string[] get_repos_names () throws IOError; @@ -328,6 +329,16 @@ namespace Pamac { return pkg; } + public Pamac.Package find_local_satisfier (string pkgname) { + var pkg = Pamac.Package (null, null); + try { + pkg = daemon.find_local_satisfier (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 {