port to pacman 4.2

This commit is contained in:
guinux 2014-12-03 16:02:14 +01:00
parent 6024012729
commit 61f1bec6a5
12 changed files with 1179 additions and 809 deletions

View File

@ -20,16 +20,19 @@
namespace Alpm { namespace Alpm {
class Repo { class Repo {
public string name; public string name;
public SigLevel siglevel; public Signature.Level siglevel;
public DB.Usage usage;
public string[] urls; public string[] urls;
public Repo (string name) { public Repo (string name) {
this.name = name; this.name = name;
usage = 0;
urls = {}; urls = {};
} }
} }
public class Config { public class Config {
string conf_path;
string rootdir; string rootdir;
string dbpath; string dbpath;
string gpgdir; string gpgdir;
@ -43,22 +46,33 @@ namespace Alpm {
string[] ignorepkg; string[] ignorepkg;
string[] noextract; string[] noextract;
string[] noupgrade; string[] noupgrade;
string[] holdpkg; string[] priv_holdpkg;
string[] syncfirst; string[] priv_syncfirst;
SigLevel defaultsiglevel; public string[] holdpkg;
SigLevel localfilesiglevel; public string[] syncfirst;
SigLevel remotefilesiglevel; Signature.Level defaultsiglevel;
Signature.Level localfilesiglevel;
Signature.Level remotefilesiglevel;
Repo[] repo_order; Repo[] repo_order;
public unowned Handle? handle;
string[] priv_ignore_pkgs;
public string[] ignore_pkgs;
public Config (string path) { public Config (string path) {
conf_path = path;
handle = null;
reload ();
}
public void reload () {
rootdir = "/"; rootdir = "/";
dbpath = "/var/lib/pacman"; dbpath = "/var/lib/pacman";
gpgdir = "/etc/pacman.d/gnupg/"; gpgdir = "/etc/pacman.d/gnupg/";
logfile = "/var/log/pacman.log"; logfile = "/var/log/pacman.log";
arch = Posix.utsname().machine; arch = Posix.utsname().machine;
cachedir = {"/var/cache/pacman/pkg/"}; cachedir = {"/var/cache/pacman/pkg/"};
holdpkg = {}; priv_holdpkg = {};
syncfirst = {}; priv_syncfirst = {};
ignoregroup = {}; ignoregroup = {};
ignorepkg = {}; ignorepkg = {};
noextract = {}; noextract = {};
@ -66,46 +80,41 @@ namespace Alpm {
usesyslog = 0; usesyslog = 0;
checkspace = 0; checkspace = 0;
deltaratio = 0.7; deltaratio = 0.7;
defaultsiglevel = SigLevel.PACKAGE | SigLevel.PACKAGE_OPTIONAL | SigLevel.DATABASE | SigLevel.DATABASE_OPTIONAL; defaultsiglevel = Signature.Level.PACKAGE | Signature.Level.PACKAGE_OPTIONAL | Signature.Level.DATABASE | Signature.Level.DATABASE_OPTIONAL;
localfilesiglevel = SigLevel.USE_DEFAULT; localfilesiglevel = Signature.Level.USE_DEFAULT;
remotefilesiglevel = SigLevel.USE_DEFAULT; remotefilesiglevel = Signature.Level.USE_DEFAULT;
repo_order = {}; repo_order = {};
// parse conf file // parse conf file
parse_file (path); parse_file (conf_path);
get_handle ();
get_ignore_pkgs ();
} }
public string[] get_syncfirst () { public void get_ignore_pkgs () {
return syncfirst; priv_ignore_pkgs = {};
}
public string[] get_holdpkg () {
return holdpkg;
}
public string[] get_ignore_pkgs () {
string[] ignore_pkgs = {};
unowned Group? group = null; unowned Group? group = null;
Handle? handle = this.get_handle ();
if (handle != null) { if (handle != null) {
foreach (string name in ignorepkg) foreach (string name in ignorepkg)
ignore_pkgs += name; priv_ignore_pkgs += name;
foreach (string grp_name in ignoregroup) { foreach (string grp_name in ignoregroup) {
group = handle.localdb.get_group (grp_name); group = handle.localdb.get_group (grp_name);
if (group != null) { if (group != null) {
foreach (unowned Package found_pkg in group.packages) foreach (unowned Package found_pkg in group.packages)
ignore_pkgs += found_pkg.name; priv_ignore_pkgs += found_pkg.name;
} }
} }
} }
return ignore_pkgs; ignore_pkgs = priv_ignore_pkgs;
} }
public Handle? get_handle () { public void get_handle () {
Alpm.Errno error; Alpm.Errno error;
Handle? handle = new Handle (rootdir, dbpath, out error); if (handle != null)
Handle.release (handle);
handle = Handle.new (rootdir, dbpath, out error);
if (handle == null) { if (handle == null) {
stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf(Alpm.strerror (error))); stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf(Alpm.strerror (error)));
return handle; return;
} }
// define options // define options
handle.gpgdir = gpgdir; handle.gpgdir = gpgdir;
@ -130,11 +139,13 @@ namespace Alpm {
// register dbs // register dbs
foreach (Repo repo in repo_order) { foreach (Repo repo in repo_order) {
unowned DB db = handle.register_syncdb (repo.name, repo.siglevel); unowned DB db = handle.register_syncdb (repo.name, repo.siglevel);
foreach (string url in repo.urls) { foreach (string url in repo.urls)
db.add_server (url.replace ("$repo", repo.name).replace ("$arch", handle.arch)); db.add_server (url.replace ("$repo", repo.name).replace ("$arch", handle.arch));
} if (repo.usage == 0)
db.usage = DB.Usage.ALL;
else
db.usage = repo.usage;
} }
return handle;
} }
public void parse_file (string path, string? section = null) { public void parse_file (string path, string? section = null) {
@ -193,11 +204,11 @@ namespace Alpm {
remotefilesiglevel = merge_siglevel (defaultsiglevel, define_siglevel (remotefilesiglevel, _value)); remotefilesiglevel = merge_siglevel (defaultsiglevel, define_siglevel (remotefilesiglevel, _value));
else if (_key == "HoldPkg") { else if (_key == "HoldPkg") {
foreach (string name in _value.split (" ")) { foreach (string name in _value.split (" ")) {
holdpkg += name; priv_holdpkg += name;
} }
} else if (_key == "SyncFirst") { } else if (_key == "SyncFirst") {
foreach (string name in _value.split (" ")) { foreach (string name in _value.split (" ")) {
syncfirst += name; priv_syncfirst += name;
} }
} else if (_key == "CacheDir") { } else if (_key == "CacheDir") {
foreach (string dir in _value.split (" ")) { foreach (string dir in _value.split (" ")) {
@ -227,6 +238,8 @@ namespace Alpm {
_repo.urls += _value; _repo.urls += _value;
else if (_key == "SigLevel") else if (_key == "SigLevel")
_repo.siglevel = define_siglevel (defaultsiglevel, _value); _repo.siglevel = define_siglevel (defaultsiglevel, _value);
else if (_key == "Usage")
_repo.usage = define_usage (_value);
} }
} }
} }
@ -234,10 +247,30 @@ namespace Alpm {
} catch (GLib.Error e) { } catch (GLib.Error e) {
GLib.stderr.printf("%s\n", e.message); GLib.stderr.printf("%s\n", e.message);
} }
holdpkg = priv_holdpkg;
syncfirst = priv_syncfirst;
} }
} }
public SigLevel define_siglevel (SigLevel default_level, string conf_string) { public DB.Usage define_usage (string conf_string) {
DB.Usage usage = 0;
foreach (string directive in conf_string.split(" ")) {
if (directive == "Sync") {
usage |= DB.Usage.SYNC;
} else if (directive == "Search") {
usage |= DB.Usage.SEARCH;
} else if (directive == "Install") {
usage |= DB.Usage.INSTALL;
} else if (directive == "Upgrade") {
usage |= DB.Usage.UPGRADE;
} else if (directive == "All") {
usage |= DB.Usage.ALL;
}
}
return usage;
}
public Signature.Level define_siglevel (Signature.Level default_level, string conf_string) {
foreach (string directive in conf_string.split(" ")) { foreach (string directive in conf_string.split(" ")) {
bool affect_package = false; bool affect_package = false;
bool affect_database = false; bool affect_database = false;
@ -249,71 +282,71 @@ namespace Alpm {
} }
if ("Never" in directive) { if ("Never" in directive) {
if (affect_package) { if (affect_package) {
default_level &= ~SigLevel.PACKAGE; default_level &= ~Signature.Level.PACKAGE;
default_level |= SigLevel.PACKAGE_SET; default_level |= Signature.Level.PACKAGE_SET;
} }
if (affect_database) default_level &= ~SigLevel.DATABASE; if (affect_database) default_level &= ~Signature.Level.DATABASE;
} }
else if ("Optional" in directive) { else if ("Optional" in directive) {
if (affect_package) { if (affect_package) {
default_level |= SigLevel.PACKAGE; default_level |= Signature.Level.PACKAGE;
default_level |= SigLevel.PACKAGE_OPTIONAL; default_level |= Signature.Level.PACKAGE_OPTIONAL;
default_level |= SigLevel.PACKAGE_SET; default_level |= Signature.Level.PACKAGE_SET;
} }
if (affect_database) { if (affect_database) {
default_level |= SigLevel.DATABASE; default_level |= Signature.Level.DATABASE;
default_level |= SigLevel.DATABASE_OPTIONAL; default_level |= Signature.Level.DATABASE_OPTIONAL;
} }
} }
else if ("Required" in directive) { else if ("Required" in directive) {
if (affect_package) { if (affect_package) {
default_level |= SigLevel.PACKAGE; default_level |= Signature.Level.PACKAGE;
default_level &= ~SigLevel.PACKAGE_OPTIONAL; default_level &= ~Signature.Level.PACKAGE_OPTIONAL;
default_level |= SigLevel.PACKAGE_SET; default_level |= Signature.Level.PACKAGE_SET;
} }
if (affect_database) { if (affect_database) {
default_level |= SigLevel.DATABASE; default_level |= Signature.Level.DATABASE;
default_level &= ~SigLevel.DATABASE_OPTIONAL; default_level &= ~Signature.Level.DATABASE_OPTIONAL;
} }
} }
else if ("TrustedOnly" in directive) { else if ("TrustedOnly" in directive) {
if (affect_package) { if (affect_package) {
default_level &= ~SigLevel.PACKAGE_MARGINAL_OK; default_level &= ~Signature.Level.PACKAGE_MARGINAL_OK;
default_level &= ~SigLevel.PACKAGE_UNKNOWN_OK; default_level &= ~Signature.Level.PACKAGE_UNKNOWN_OK;
default_level |= SigLevel.PACKAGE_TRUST_SET; default_level |= Signature.Level.PACKAGE_TRUST_SET;
} }
if (affect_database) { if (affect_database) {
default_level &= ~SigLevel.DATABASE_MARGINAL_OK; default_level &= ~Signature.Level.DATABASE_MARGINAL_OK;
default_level &= ~SigLevel.DATABASE_UNKNOWN_OK; default_level &= ~Signature.Level.DATABASE_UNKNOWN_OK;
} }
} }
else if ("TrustAll" in directive) { else if ("TrustAll" in directive) {
if (affect_package) { if (affect_package) {
default_level |= SigLevel.PACKAGE_MARGINAL_OK; default_level |= Signature.Level.PACKAGE_MARGINAL_OK;
default_level |= SigLevel.PACKAGE_UNKNOWN_OK; default_level |= Signature.Level.PACKAGE_UNKNOWN_OK;
default_level |= SigLevel.PACKAGE_TRUST_SET; default_level |= Signature.Level.PACKAGE_TRUST_SET;
} }
if (affect_database) { if (affect_database) {
default_level |= SigLevel.DATABASE_MARGINAL_OK; default_level |= Signature.Level.DATABASE_MARGINAL_OK;
default_level |= SigLevel.DATABASE_UNKNOWN_OK; default_level |= Signature.Level.DATABASE_UNKNOWN_OK;
} }
} }
else GLib.stderr.printf("unrecognized siglevel: %s\n", conf_string); else GLib.stderr.printf("unrecognized siglevel: %s\n", conf_string);
} }
default_level &= ~SigLevel.USE_DEFAULT; default_level &= ~Signature.Level.USE_DEFAULT;
return default_level; return default_level;
} }
public SigLevel merge_siglevel (SigLevel base_level, SigLevel over_level) { public Signature.Level merge_siglevel (Signature.Level base_level, Signature.Level over_level) {
if ((over_level & SigLevel.USE_DEFAULT) != 0) over_level = base_level; if ((over_level & Signature.Level.USE_DEFAULT) != 0) over_level = base_level;
else { else {
if ((over_level & SigLevel.PACKAGE_SET) == 0) { if ((over_level & Signature.Level.PACKAGE_SET) == 0) {
over_level |= base_level & SigLevel.PACKAGE; over_level |= base_level & Signature.Level.PACKAGE;
over_level |= base_level & SigLevel.PACKAGE_OPTIONAL; over_level |= base_level & Signature.Level.PACKAGE_OPTIONAL;
} }
if ((over_level & SigLevel.PACKAGE_TRUST_SET) == 0) { if ((over_level & Signature.Level.PACKAGE_TRUST_SET) == 0) {
over_level |= base_level & SigLevel.PACKAGE_MARGINAL_OK; over_level |= base_level & Signature.Level.PACKAGE_MARGINAL_OK;
over_level |= base_level & SigLevel.PACKAGE_UNKNOWN_OK; over_level |= base_level & Signature.Level.PACKAGE_UNKNOWN_OK;
} }
} }
return over_level; return over_level;

View File

@ -28,7 +28,7 @@ namespace AUR {
const string aur_url_id = "/packages.php?setlang=en&ID="; const string aur_url_id = "/packages.php?setlang=en&ID=";
public Json.Array search (string[] needles) { public Json.Array search (string[] needles) {
Json.Array prev_inter = new Json.Array (); var prev_inter = new Json.Array ();
string uri = rpc_url + rpc_search + Uri.escape_string (needles[0]); string uri = rpc_url + rpc_search + Uri.escape_string (needles[0]);
var session = new Soup.Session (); var session = new Soup.Session ();
var message = new Soup.Message ("GET", uri); var message = new Soup.Message ("GET", uri);
@ -46,8 +46,8 @@ namespace AUR {
if (length == 1) if (length == 1)
return prev_inter; return prev_inter;
int i = 1; int i = 1;
Json.Array inter = new Json.Array (); var inter = new Json.Array ();
Json.Array found = new Json.Array (); var found = new Json.Array ();
while (i < length) { while (i < length) {
inter = new Json.Array (); inter = new Json.Array ();
uri = rpc_url + rpc_search + Uri.escape_string (needles[i]); uri = rpc_url + rpc_search + Uri.escape_string (needles[i]);
@ -60,8 +60,8 @@ namespace AUR {
} catch (Error e) { } catch (Error e) {
print (e.message); print (e.message);
} }
foreach (Json.Node prev_inter_node in prev_inter.get_elements ()) { foreach (var prev_inter_node in prev_inter.get_elements ()) {
foreach (Json.Node found_node in found.get_elements ()) { foreach (var found_node in found.get_elements ()) {
if (strcmp (prev_inter_node.get_object ().get_string_member ("Name"), if (strcmp (prev_inter_node.get_object ().get_string_member ("Name"),
found_node.get_object ().get_string_member ("Name")) == 0) { found_node.get_object ().get_string_member ("Name")) == 0) {
inter.add_element (prev_inter_node); inter.add_element (prev_inter_node);

View File

@ -28,8 +28,7 @@ namespace Pamac {
public enum Mode { public enum Mode {
MANAGER, MANAGER,
UPDATER, UPDATER
NO_CONFIRM
} }
public struct ErrorInfos { public struct ErrorInfos {
@ -57,13 +56,11 @@ public int pkgcmp (Alpm.Package pkg1, Alpm.Package pkg2) {
return strcmp (pkg1.name, pkg2.name); return strcmp (pkg1.name, pkg2.name);
} }
public unowned Alpm.List<Alpm.Package?> search_all_dbs (Alpm.Handle handle, Alpm.List<string?> needles) { public Alpm.List<unowned Alpm.Package?> search_all_dbs (Alpm.Handle handle, Alpm.List<string?> needles) {
unowned Alpm.List<Alpm.Package?> syncpkgs = null; var syncpkgs = new Alpm.List<unowned Alpm.Package?> ();
unowned Alpm.List<Alpm.Package?> result = null; var result = handle.localdb.search (needles);
result = handle.localdb.search (needles); foreach (var db in handle.syncdbs) {
foreach (unowned Alpm.DB db in handle.syncdbs) {
if (syncpkgs.length == 0) if (syncpkgs.length == 0)
syncpkgs = db.search (needles); syncpkgs = db.search (needles);
else { else {
@ -77,12 +74,12 @@ public unowned Alpm.List<Alpm.Package?> search_all_dbs (Alpm.Handle handle, Alpm
return result; return result;
} }
public unowned Alpm.List<Alpm.Package?> group_pkgs_all_dbs (Alpm.Handle handle, string grp_name) { public Alpm.List<unowned Alpm.Package?> group_pkgs_all_dbs (Alpm.Handle handle, string grp_name) {
unowned Alpm.List<Alpm.Package?> result = null; var result = new Alpm.List<unowned Alpm.Package?> ();
unowned Alpm.Group? grp = handle.localdb.get_group (grp_name); unowned Alpm.Group? grp = handle.localdb.get_group (grp_name);
if (grp != null) { if (grp != null) {
foreach (unowned Alpm.Package pkg in grp.packages) foreach (var pkg in grp.packages)
result.add (pkg); result.add (pkg);
} }
@ -93,13 +90,12 @@ public unowned Alpm.List<Alpm.Package?> group_pkgs_all_dbs (Alpm.Handle handle,
return result; return result;
} }
public unowned Alpm.List<Alpm.Package?> get_all_pkgs (Alpm.Handle handle) { public Alpm.List<unowned Alpm.Package?> get_all_pkgs (Alpm.Handle handle) {
unowned Alpm.List<Alpm.Package?> syncpkgs = null; var syncpkgs = new Alpm.List<unowned Alpm.Package?> ();
unowned Alpm.List<Alpm.Package?> result = null; var result = new Alpm.List<unowned Alpm.Package?> ();
result = handle.localdb.pkgcache.copy (); result = handle.localdb.pkgcache.copy ();
foreach (unowned Alpm.DB db in handle.syncdbs) { foreach (var db in handle.syncdbs) {
if (syncpkgs.length == 0) if (syncpkgs.length == 0)
syncpkgs = db.pkgcache.copy (); syncpkgs = db.pkgcache.copy ();
else { else {
@ -115,7 +111,7 @@ public unowned Alpm.List<Alpm.Package?> get_all_pkgs (Alpm.Handle handle) {
public unowned Alpm.Package? get_syncpkg (Alpm.Handle handle, string name) { public unowned Alpm.Package? get_syncpkg (Alpm.Handle handle, string name) {
unowned Alpm.Package? pkg = null; unowned Alpm.Package? pkg = null;
foreach (unowned Alpm.DB db in handle.syncdbs) { foreach (var db in handle.syncdbs) {
pkg = db.get_pkg (name); pkg = db.get_pkg (name);
if (pkg != null) if (pkg != null)
break; break;
@ -128,10 +124,10 @@ public Pamac.UpdatesInfos[] get_syncfirst_updates (Alpm.Handle handle, string[]
Pamac.UpdatesInfos[] syncfirst_infos = {}; Pamac.UpdatesInfos[] syncfirst_infos = {};
unowned Alpm.Package? pkg = null; unowned Alpm.Package? pkg = null;
unowned Alpm.Package? candidate = null; unowned Alpm.Package? candidate = null;
foreach (string name in syncfirst) { foreach (var name in syncfirst) {
pkg = Alpm.find_satisfier (handle.localdb.pkgcache, name); pkg = Alpm.find_satisfier (handle.localdb.pkgcache, name);
if (pkg != null) { if (pkg != null) {
candidate = Alpm.sync_newversion (pkg, handle.syncdbs); candidate = pkg.sync_newversion (handle.syncdbs);
if (candidate != null) { if (candidate != null) {
infos.name = candidate.name; infos.name = candidate.name;
infos.version = candidate.version; infos.version = candidate.version;
@ -149,10 +145,10 @@ public Pamac.UpdatesInfos[] get_repos_updates (Alpm.Handle handle, string[] igno
unowned Alpm.Package? candidate = null; unowned Alpm.Package? candidate = null;
Pamac.UpdatesInfos infos = Pamac.UpdatesInfos (); Pamac.UpdatesInfos infos = Pamac.UpdatesInfos ();
Pamac.UpdatesInfos[] updates = {}; Pamac.UpdatesInfos[] updates = {};
foreach (unowned Alpm.Package local_pkg in handle.localdb.pkgcache) { foreach (var local_pkg in handle.localdb.pkgcache) {
// continue only if the local pkg is not in IgnorePkg or IgnoreGroup // continue only if the local pkg is not in IgnorePkg or IgnoreGroup
if ((local_pkg.name in ignore_pkgs) == false) { if ((local_pkg.name in ignore_pkgs) == false) {
candidate = Alpm.sync_newversion (local_pkg, handle.syncdbs); candidate = local_pkg.sync_newversion (handle.syncdbs);
if (candidate != null) { if (candidate != null) {
infos.name = candidate.name; infos.name = candidate.name;
infos.version = candidate.version; infos.version = candidate.version;
@ -173,18 +169,18 @@ public Pamac.UpdatesInfos[] get_aur_updates (Alpm.Handle handle, string[] ignore
Pamac.UpdatesInfos infos = Pamac.UpdatesInfos (); Pamac.UpdatesInfos infos = Pamac.UpdatesInfos ();
Pamac.UpdatesInfos[] aur_updates = {}; Pamac.UpdatesInfos[] aur_updates = {};
// get local pkgs // get local pkgs
foreach (unowned Alpm.Package local_pkg in handle.localdb.pkgcache) { foreach (var local_pkg in handle.localdb.pkgcache) {
// continue only if the local pkg is not in IgnorePkg or IgnoreGroup // continue only if the local pkg is not in IgnorePkg or IgnoreGroup
if ((local_pkg.name in ignore_pkgs) == false) { if ((local_pkg.name in ignore_pkgs) == false) {
// check updates from AUR only for local packages // check updates from AUR only for local packages
foreach (unowned Alpm.DB db in handle.syncdbs) { foreach (var db in handle.syncdbs) {
sync_pkg = Alpm.find_satisfier (db.pkgcache, local_pkg.name); sync_pkg = Alpm.find_satisfier (db.pkgcache, local_pkg.name);
if (sync_pkg != null) if (sync_pkg != null)
break; break;
} }
if (sync_pkg == null) { if (sync_pkg == null) {
// check update from AUR only if no package from dbs will replace it // check update from AUR only if no package from dbs will replace it
candidate = Alpm.sync_newversion (local_pkg, handle.syncdbs); candidate = local_pkg.sync_newversion (handle.syncdbs);
if (candidate == null) { if (candidate == null) {
local_pkgs += local_pkg.name; local_pkgs += local_pkg.name;
} }
@ -192,12 +188,13 @@ public Pamac.UpdatesInfos[] get_aur_updates (Alpm.Handle handle, string[] ignore
} }
} }
// get aur updates // get aur updates
Json.Array aur_pkgs = AUR.multiinfo (local_pkgs); var aur_pkgs = AUR.multiinfo (local_pkgs);
int cmp; int cmp;
unowned Json.Object pkg_info;
string version; string version;
string name; string name;
foreach (Json.Node node in aur_pkgs.get_elements ()) { foreach (var node in aur_pkgs.get_elements ()) {
unowned Json.Object pkg_info = node.get_object (); pkg_info = node.get_object ();
version = pkg_info.get_string_member ("Version"); version = pkg_info.get_string_member ("Version");
name = pkg_info.get_string_member ("Name"); name = pkg_info.get_string_member ("Name");
cmp = Alpm.pkg_vercmp (version, handle.localdb.get_pkg (name).version); cmp = Alpm.pkg_vercmp (version, handle.localdb.get_pkg (name).version);

View File

@ -29,10 +29,7 @@ MainLoop loop;
namespace Pamac { namespace Pamac {
[DBus (name = "org.manjaro.pamac")] [DBus (name = "org.manjaro.pamac")]
public class Daemon : Object { public class Daemon : Object {
string[] syncfirst; Alpm.Config alpm_config;
string[] holdpkg;
string[] ignorepkg;
Handle? handle;
public uint64 previous_percent; public uint64 previous_percent;
int force_refresh; int force_refresh;
bool emit_refreshed_signal; bool emit_refreshed_signal;
@ -40,7 +37,7 @@ namespace Pamac {
public Mutex provider_mutex; public Mutex provider_mutex;
public int? choosen_provider; public int? choosen_provider;
public signal void emit_event (uint event, string[] details); public signal void emit_event (uint primary_event, uint secondary_event, string[] details);
public signal void emit_providers (string depend, string[] providers); public signal void emit_providers (string depend, string[] providers);
public signal void emit_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target); public signal void emit_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target);
public signal void emit_download (string filename, uint64 xfered, uint64 total); public signal void emit_download (string filename, uint64 xfered, uint64 total);
@ -51,25 +48,22 @@ namespace Pamac {
public signal void emit_trans_committed (ErrorInfos error); public signal void emit_trans_committed (ErrorInfos error);
public Daemon () { public Daemon () {
alpm_config = new Alpm.Config ("/etc/pacman.conf");
} }
private void init_alpm_config () { private void refresh_handle () {
var alpm_config = new Alpm.Config ("/etc/pacman.conf"); alpm_config.get_handle ();
syncfirst = alpm_config.get_syncfirst (); if (alpm_config.handle == null) {
holdpkg = alpm_config.get_holdpkg ();
ignorepkg = alpm_config.get_ignore_pkgs ();
handle = alpm_config.get_handle ();
if (handle == null) {
ErrorInfos err = ErrorInfos (); ErrorInfos err = ErrorInfos ();
err.str = _("Failed to initialize alpm library"); err.str = _("Failed to initialize alpm library");
emit_trans_committed (err); emit_trans_committed (err);
} else { } else {
handle.eventcb = (EventCallBack) cb_event; alpm_config.handle.eventcb = (EventCallBack) cb_event;
handle.progresscb = (ProgressCallBack) cb_progress; alpm_config.handle.progresscb = (ProgressCallBack) cb_progress;
handle.questioncb = (QuestionCallBack) cb_question; alpm_config.handle.questioncb = (QuestionCallBack) cb_question;
handle.dlcb = (DownloadCallBack) cb_download; alpm_config.handle.dlcb = (DownloadCallBack) cb_download;
handle.totaldlcb = (TotalDownloadCallBack) cb_totaldownload; alpm_config.handle.totaldlcb = (TotalDownloadCallBack) cb_totaldownload;
handle.logcb = (LogCallBack) cb_log; alpm_config.handle.logcb = (LogCallBack) cb_log;
} }
previous_percent = 0; previous_percent = 0;
} }
@ -106,10 +100,10 @@ namespace Pamac {
null null
); );
if (result.get_is_authorized ()) { if (result.get_is_authorized ()) {
init_alpm_config (); refresh_handle ();
unowned Package? pkg = handle.localdb.get_pkg (pkgname); unowned Package? pkg = alpm_config.handle.localdb.get_pkg (pkgname);
if (pkg != null) if (pkg != null)
pkg.reason = (PkgReason) reason; pkg.reason = (Package.Reason) reason;
} }
} catch (GLib.Error e) { } catch (GLib.Error e) {
stderr.printf ("%s\n", e.message); stderr.printf ("%s\n", e.message);
@ -117,12 +111,12 @@ namespace Pamac {
} }
private int refresh_real () { private int refresh_real () {
init_alpm_config (); refresh_handle ();
ErrorInfos err = ErrorInfos (); ErrorInfos err = ErrorInfos ();
string[] details = {}; string[] details = {};
int success = 0; int success = 0;
int ret; int ret;
foreach (var db in handle.syncdbs) { foreach (var db in alpm_config.handle.syncdbs) {
ret = db.update (force_refresh); ret = db.update (force_refresh);
if (ret >= 0) { if (ret >= 0) {
success++; success++;
@ -132,7 +126,7 @@ namespace Pamac {
// fail later with unresolved deps, but that should be rare, and would be expected // fail later with unresolved deps, but that should be rare, and would be expected
if (success == 0) { if (success == 0) {
err.str = _("Failed to synchronize any databases"); err.str = _("Failed to synchronize any databases");
details += Alpm.strerror (handle.errno ()); details += Alpm.strerror (alpm_config.handle.errno ());
err.details = details; err.details = details;
} }
if (emit_refreshed_signal) if (emit_refreshed_signal)
@ -151,16 +145,16 @@ namespace Pamac {
} }
public UpdatesInfos[] get_updates () { public UpdatesInfos[] get_updates () {
init_alpm_config (); refresh_handle ();
var pamac_config = new Pamac.Config ("/etc/pamac.conf"); var pamac_config = new Pamac.Config ("/etc/pamac.conf");
UpdatesInfos[] updates = {}; UpdatesInfos[] updates = {};
updates = get_syncfirst_updates (handle, syncfirst); updates = get_syncfirst_updates (alpm_config.handle, alpm_config.syncfirst);
if (updates.length != 0) { if (updates.length != 0) {
return updates; return updates;
} else { } else {
updates = get_repos_updates (handle, ignorepkg); updates = get_repos_updates (alpm_config.handle, alpm_config.ignore_pkgs);
if (pamac_config.enable_aur) { if (pamac_config.enable_aur) {
UpdatesInfos[] aur_updates = get_aur_updates (handle, ignorepkg); UpdatesInfos[] aur_updates = get_aur_updates (alpm_config.handle, alpm_config.ignore_pkgs);
foreach (var infos in aur_updates) foreach (var infos in aur_updates)
updates += infos; updates += infos;
} }
@ -169,13 +163,13 @@ namespace Pamac {
} }
public ErrorInfos trans_init (TransFlag transflags) { public ErrorInfos trans_init (TransFlag transflags) {
init_alpm_config (); refresh_handle ();
ErrorInfos err = ErrorInfos (); ErrorInfos err = ErrorInfos ();
string[] details = {}; string[] details = {};
int ret = handle.trans_init (transflags); int ret = alpm_config.handle.trans_init (transflags);
if (ret == -1) { if (ret == -1) {
err.str = _("Failed to init transaction"); err.str = _("Failed to init transaction");
details += Alpm.strerror (handle.errno ()); details += Alpm.strerror (alpm_config.handle.errno ());
err.details = details; err.details = details;
} }
return err; return err;
@ -184,10 +178,10 @@ namespace Pamac {
public ErrorInfos trans_sysupgrade (int enable_downgrade) { public ErrorInfos trans_sysupgrade (int enable_downgrade) {
ErrorInfos err = ErrorInfos (); ErrorInfos err = ErrorInfos ();
string[] details = {}; string[] details = {};
int ret = handle.trans_sysupgrade (enable_downgrade); int ret = alpm_config.handle.trans_sysupgrade (enable_downgrade);
if (ret == -1) {; if (ret == -1) {;
err.str = _("Failed to prepare transaction"); err.str = _("Failed to prepare transaction");
details += Alpm.strerror (handle.errno ()); details += Alpm.strerror (alpm_config.handle.errno ());
err.details = details; err.details = details;
} }
return err; return err;
@ -197,8 +191,8 @@ namespace Pamac {
ErrorInfos err = ErrorInfos (); ErrorInfos err = ErrorInfos ();
string[] details = {}; string[] details = {};
unowned Package? pkg = null; unowned Package? pkg = null;
pkg = handle.find_dbs_satisfier (handle.syncdbs, pkgname); pkg = alpm_config.handle.find_dbs_satisfier (alpm_config.handle.syncdbs, pkgname);
//foreach (var db in handle.syncdbs) { //foreach (var db in alpm_config.handle.syncdbs) {
//pkg = find_satisfier (db.pkgcache, pkgname); //pkg = find_satisfier (db.pkgcache, pkgname);
//if (pkg != null) //if (pkg != null)
//break; //break;
@ -209,9 +203,9 @@ namespace Pamac {
err.details = details; err.details = details;
return err; return err;
} }
int ret = handle.trans_add_pkg (pkg); int ret = alpm_config.handle.trans_add_pkg (pkg);
if (ret == -1) { if (ret == -1) {
Alpm.Errno errno = handle.errno (); Alpm.Errno errno = alpm_config.handle.errno ();
if (errno == Errno.TRANS_DUP_TARGET || errno == Errno.PKG_IGNORED) if (errno == Errno.TRANS_DUP_TARGET || errno == Errno.PKG_IGNORED)
// just skip duplicate or ignored targets // just skip duplicate or ignored targets
return err; return err;
@ -228,16 +222,16 @@ namespace Pamac {
public ErrorInfos trans_load_pkg (string pkgpath) { public ErrorInfos trans_load_pkg (string pkgpath) {
ErrorInfos err = ErrorInfos (); ErrorInfos err = ErrorInfos ();
string[] details = {}; string[] details = {};
Package* pkg = handle.load_file (pkgpath, 1, handle.localfilesiglevel); Package* pkg = alpm_config.handle.load_file (pkgpath, 1, alpm_config.handle.localfilesiglevel);
if (pkg == null) { if (pkg == null) {
err.str = _("Failed to prepare transaction"); err.str = _("Failed to prepare transaction");
details += "%s: %s".printf (pkgpath, Alpm.strerror (handle.errno ())); details += "%s: %s".printf (pkgpath, Alpm.strerror (alpm_config.handle.errno ()));
err.details = details; err.details = details;
return err; return err;
} else { } else {
int ret = handle.trans_add_pkg (pkg); int ret = alpm_config.handle.trans_add_pkg (pkg);
if (ret == -1) { if (ret == -1) {
Alpm.Errno errno = handle.errno (); Alpm.Errno errno = alpm_config.handle.errno ();
if (errno == Errno.TRANS_DUP_TARGET || errno == Errno.PKG_IGNORED) if (errno == Errno.TRANS_DUP_TARGET || errno == Errno.PKG_IGNORED)
// just skip duplicate or ignored targets // just skip duplicate or ignored targets
return err; return err;
@ -257,17 +251,17 @@ namespace Pamac {
public ErrorInfos trans_remove_pkg (string pkgname) { public ErrorInfos trans_remove_pkg (string pkgname) {
ErrorInfos err = ErrorInfos (); ErrorInfos err = ErrorInfos ();
string[] details = {}; string[] details = {};
unowned Package? pkg = handle.localdb.get_pkg (pkgname); unowned Package? pkg = alpm_config.handle.localdb.get_pkg (pkgname);
if (pkg == null) { if (pkg == null) {
err.str = _("Failed to prepare transaction"); err.str = _("Failed to prepare transaction");
details += _("target not found: %s").printf (pkgname); details += _("target not found: %s").printf (pkgname);
err.details = details; err.details = details;
return err; return err;
} }
int ret = handle.trans_remove_pkg (pkg); int ret = alpm_config.handle.trans_remove_pkg (pkg);
if (ret == -1) { if (ret == -1) {
err.str = _("Failed to prepare transaction"); err.str = _("Failed to prepare transaction");
details += "%s: %s".printf (pkg.name, Alpm.strerror (handle.errno ())); details += "%s: %s".printf (pkg.name, Alpm.strerror (alpm_config.handle.errno ()));
err.details = details; err.details = details;
} }
return err; return err;
@ -277,9 +271,9 @@ namespace Pamac {
ErrorInfos err = ErrorInfos (); ErrorInfos err = ErrorInfos ();
string[] details = {}; string[] details = {};
Alpm.List<void*> err_data = null; Alpm.List<void*> err_data = null;
int ret = handle.trans_prepare (out err_data); int ret = alpm_config.handle.trans_prepare (out err_data);
if (ret == -1) { if (ret == -1) {
Alpm.Errno errno = handle.errno (); Alpm.Errno errno = alpm_config.handle.errno ();
err.str = _("Failed to prepare transaction"); err.str = _("Failed to prepare transaction");
string detail = Alpm.strerror (errno); string detail = Alpm.strerror (errno);
switch (errno) { switch (errno) {
@ -289,6 +283,7 @@ namespace Pamac {
foreach (void *i in err_data) { foreach (void *i in err_data) {
char *pkgname = i; char *pkgname = i;
details += _("package %s does not have a valid architecture").printf (pkgname); details += _("package %s does not have a valid architecture").printf (pkgname);
delete pkgname;
} }
break; break;
case Errno.UNSATISFIED_DEPS: case Errno.UNSATISFIED_DEPS:
@ -298,6 +293,7 @@ namespace Pamac {
DepMissing *miss = i; DepMissing *miss = i;
string depstring = miss->depend.compute_string (); string depstring = miss->depend.compute_string ();
details += _("%s: requires %s").printf (miss->target, depstring); details += _("%s: requires %s").printf (miss->target, depstring);
delete miss;
} }
break; break;
case Errno.CONFLICTING_DEPS: case Errno.CONFLICTING_DEPS:
@ -307,10 +303,11 @@ namespace Pamac {
Conflict *conflict = i; Conflict *conflict = i;
detail = _("%s and %s are in conflict").printf (conflict->package1, conflict->package2); detail = _("%s and %s are in conflict").printf (conflict->package1, conflict->package2);
// only print reason if it contains new information // only print reason if it contains new information
if (conflict->reason.mod != DepMod.ANY) { if (conflict->reason.mod != Depend.Mode.ANY) {
detail += " (%s)".printf (conflict->reason.compute_string ()); detail += " (%s)".printf (conflict->reason.compute_string ());
} }
details += detail; details += detail;
delete conflict;
} }
break; break;
default: default:
@ -322,8 +319,8 @@ namespace Pamac {
} else { } else {
// Search for holdpkg in target list // Search for holdpkg in target list
bool found_locked_pkg = false; bool found_locked_pkg = false;
foreach (var pkg in handle.trans_to_remove ()) { foreach (var pkg in alpm_config.handle.trans_to_remove ()) {
if (pkg.name in holdpkg) { if (pkg.name in alpm_config.holdpkg) {
details += _("%s needs to be removed but it is a locked package").printf (pkg.name); details += _("%s needs to be removed but it is a locked package").printf (pkg.name);
found_locked_pkg = true; found_locked_pkg = true;
break; break;
@ -357,7 +354,7 @@ namespace Pamac {
public UpdatesInfos[] trans_to_add () { public UpdatesInfos[] trans_to_add () {
UpdatesInfos info = UpdatesInfos (); UpdatesInfos info = UpdatesInfos ();
UpdatesInfos[] infos = {}; UpdatesInfos[] infos = {};
foreach (var pkg in handle.trans_to_add ()) { foreach (var pkg in alpm_config.handle.trans_to_add ()) {
info.name = pkg.name; info.name = pkg.name;
info.version = pkg.version; info.version = pkg.version;
// if pkg was load from a file, pkg.db is null // if pkg was load from a file, pkg.db is null
@ -375,7 +372,7 @@ namespace Pamac {
public UpdatesInfos[] trans_to_remove () { public UpdatesInfos[] trans_to_remove () {
UpdatesInfos info = UpdatesInfos (); UpdatesInfos info = UpdatesInfos ();
UpdatesInfos[] infos = {}; UpdatesInfos[] infos = {};
foreach (var pkg in handle.trans_to_remove ()) { foreach (var pkg in alpm_config.handle.trans_to_remove ()) {
info.name = pkg.name; info.name = pkg.name;
info.version = pkg.version; info.version = pkg.version;
info.db_name = pkg.db.name; info.db_name = pkg.db.name;
@ -390,29 +387,30 @@ namespace Pamac {
ErrorInfos err = ErrorInfos (); ErrorInfos err = ErrorInfos ();
string[] details = {}; string[] details = {};
Alpm.List<void*> err_data = null; Alpm.List<void*> err_data = null;
int ret = handle.trans_commit (out err_data); int ret = alpm_config.handle.trans_commit (out err_data);
if (ret == -1) { if (ret == -1) {
Alpm.Errno errno = handle.errno (); Alpm.Errno errno = alpm_config.handle.errno ();
err.str = _("Failed to commit transaction"); err.str = _("Failed to commit transaction");
string detail = Alpm.strerror (errno); string detail = Alpm.strerror (errno);
switch (errno) { switch (errno) {
case Alpm.Errno.FILE_CONFLICTS: case Alpm.Errno.FILE_CONFLICTS:
detail += ":"; detail += ":";
details += detail; details += detail;
//TransFlag flags = handle.trans_get_flags (); //TransFlag flags = alpm_config.handle.trans_get_flags ();
//if ((flags & TransFlag.FORCE) != 0) { //if ((flags & TransFlag.FORCE) != 0) {
//details += _("unable to %s directory-file conflicts").printf ("--force"); //details += _("unable to %s directory-file conflicts").printf ("--force");
//} //}
foreach (void *i in err_data) { foreach (void *i in err_data) {
FileConflict *conflict = i; FileConflict *conflict = i;
switch (conflict->type) { switch (conflict->type) {
case FileConflictType.TARGET: case FileConflict.Type.TARGET:
details += _("%s exists in both %s and %s").printf (conflict->file, conflict->target, conflict->ctarget); details += _("%s exists in both %s and %s").printf (conflict->file, conflict->target, conflict->ctarget);
break; break;
case FileConflictType.FILESYSTEM: case FileConflict.Type.FILESYSTEM:
details += _("%s: %s already exists in filesystem").printf (conflict->target, conflict->file); details += _("%s: %s already exists in filesystem").printf (conflict->target, conflict->file);
break; break;
} }
delete conflict;
} }
break; break;
case Alpm.Errno.PKG_INVALID: case Alpm.Errno.PKG_INVALID:
@ -424,6 +422,7 @@ namespace Pamac {
foreach (void *i in err_data) { foreach (void *i in err_data) {
char *filename = i; char *filename = i;
details += _("%s is invalid or corrupted").printf (filename); details += _("%s is invalid or corrupted").printf (filename);
delete filename;
} }
break; break;
default: default:
@ -470,13 +469,13 @@ namespace Pamac {
} }
public int trans_release () { public int trans_release () {
return handle.trans_release (); return alpm_config.handle.trans_release ();
} }
public void trans_cancel () { public void trans_cancel () {
handle.trans_interrupt (); alpm_config.handle.trans_interrupt ();
handle.trans_release (); alpm_config.handle.trans_release ();
init_alpm_config (); refresh_handle ();
} }
public void quit () { public void quit () {
@ -502,127 +501,120 @@ private void write_log_file (string event) {
} }
} }
private void cb_event (Event event, void *data1, void *data2) { private void cb_event (Event.Data data) {
string[] details = {}; string[] details = {};
switch (event) { uint secondary_type = 0;
case Event.ADD_START: switch (data.type) {
case Event.REMOVE_START: case Event.Type.PACKAGE_OPERATION_START:
case Event.REINSTALL_START: switch (data.package_operation_operation) {
unowned Package pkg = (Package) data1; case Package.Operation.REMOVE:
details += pkg.name; details += data.package_operation_oldpkg.name;
details += pkg.version; details += data.package_operation_oldpkg.version;
secondary_type = (uint) Package.Operation.REMOVE;
break;
case Package.Operation.INSTALL:
details += data.package_operation_newpkg.name;
details += data.package_operation_newpkg.version;
secondary_type = (uint) Package.Operation.INSTALL;
break;
case Package.Operation.REINSTALL:
details += data.package_operation_newpkg.name;
details += data.package_operation_newpkg.version;
secondary_type = (uint) Package.Operation.REINSTALL;
break;
case Package.Operation.UPGRADE:
details += data.package_operation_oldpkg.name;
details += data.package_operation_oldpkg.version;
details += data.package_operation_newpkg.version;
secondary_type = (uint) Package.Operation.UPGRADE;
break;
case Package.Operation.DOWNGRADE:
details += data.package_operation_oldpkg.name;
details += data.package_operation_oldpkg.version;
details += data.package_operation_newpkg.version;
secondary_type = (uint) Package.Operation.DOWNGRADE;
break;
}
break; break;
case Event.ADD_DONE: case Event.Type.PACKAGE_OPERATION_DONE:
unowned Package pkg = (Package) data1; switch (data.package_operation_operation) {
string log = "Installed %s (%s)\n".printf (pkg.name, pkg.version); case Package.Operation.INSTALL:
write_log_file (log); string log = "Installed %s (%s)\n".printf (data.package_operation_newpkg.name, data.package_operation_newpkg.version);
write_log_file (log);
break;
case Package.Operation.REMOVE:
string log = "Removed %s (%s)\n".printf (data.package_operation_oldpkg.name, data.package_operation_oldpkg.version);
write_log_file (log);
break;
case Package.Operation.REINSTALL:
string log = "Reinstalled %s (%s)\n".printf (data.package_operation_newpkg.name, data.package_operation_newpkg.version);
write_log_file (log);
break;
case Package.Operation.UPGRADE:
string log = "Upgraded %s (%s -> %s)\n".printf (data.package_operation_oldpkg.name, data.package_operation_oldpkg.version, data.package_operation_newpkg.version);
write_log_file (log);
break;
case Package.Operation.DOWNGRADE:
string log = "Downgraded %s (%s -> %s)\n".printf (data.package_operation_oldpkg.name, data.package_operation_oldpkg.version, data.package_operation_newpkg.version);
write_log_file (log);
break;
}
break; break;
case Event.REMOVE_DONE: case Event.Type.DELTA_PATCH_START:
unowned Package pkg = (Package) data1; details += data.delta_patch_delta.to;
string log = "Removed %s (%s)\n".printf (pkg.name, pkg.version); details += data.delta_patch_delta.delta;
write_log_file (log);
break; break;
case Event.REINSTALL_DONE: case Event.Type.SCRIPTLET_INFO:
unowned Package pkg = (Package) data1; details += data.scriptlet_info_line;
string log = "Reinstalled %s (%s)\n".printf (pkg.name, pkg.version); write_log_file (data.scriptlet_info_line);
write_log_file (log);
break; break;
case Event.UPGRADE_START: case Event.Type.PKGDOWNLOAD_START:
case Event.DOWNGRADE_START: details += data.pkgdownload_file;
unowned Package new_pkg = (Package) data1;
unowned Package old_pkg = (Package) data2;
details += old_pkg.name;
details += old_pkg.version;
details += new_pkg.version;
break; break;
case Event.UPGRADE_DONE: case Event.Type.OPTDEP_REMOVAL:
unowned Package new_pkg = (Package) data1; details += data.optdep_removal_pkg.name;
unowned Package old_pkg = (Package) data2; details += data.optdep_removal_optdep.compute_string ();
string log = "Upgraded %s (%s -> %s)\n".printf (old_pkg.name, old_pkg.version, new_pkg.version);
write_log_file (log);
break; break;
case Event.DOWNGRADE_DONE: case Event.Type.DATABASE_MISSING:
unowned Package new_pkg = (Package) data1; details += data.database_missing_dbname;
unowned Package old_pkg = (Package) data2;
string log = "Downgraded %s (%s -> %s)\n".printf (old_pkg.name, old_pkg.version, new_pkg.version);
write_log_file (log);
break; break;
case Event.DELTA_PATCH_START: case Event.Type.PACNEW_CREATED:
unowned string string1 = (string) data1; details += data.pacnew_created_file;
unowned string string2 = (string) data2;
details += string1;
details += string2;
break; break;
case Event.SCRIPTLET_INFO: case Event.Type.PACSAVE_CREATED:
unowned string info = (string) data1; details += data.pacsave_created_file;
details += info;
write_log_file (info);
break; break;
case Event.OPTDEP_REQUIRED: case Event.Type.PACORIG_CREATED:
unowned Package pkg = (Package) data1; details += data.pacorig_created_file;
Depend *depend = data2;
details += pkg.name;
details += depend->compute_string ();
break; break;
case Event.DATABASE_MISSING:
unowned string db_name = (string) data1;
details += db_name;
break;
//~ case Event.CHECKDEPS_START:
//~ case Event.CHECKDEPS_DONE:
//~ case Event.FILECONFLICTS_START:
//~ case Event.FILECONFLICTS_DONE:
//~ case Event.RESOLVEDEPS_START:
//~ case Event.RESOLVEDEPS_DONE:
//~ case Event.INTERCONFLICTS_START:
//~ case Event.INTERCONFLICTS_DONE:
//~ case Event.INTEGRITY_START:
//~ case Event.INTEGRITY_DONE:
//~ case Event.KEYRING_START:
//~ case Event.KEYRING_DONE:
//~ case Event.KEY_DOWNLOAD_START:
//~ case Event.KEY_DOWNLOAD_DONE:
//~ case Event.LOAD_START:
//~ case Event.LOAD_DONE:
//~ case Event.DELTA_INTEGRITY_START:
//~ case Event.DELTA_INTEGRITY_DONE:
//~ case Event.DELTA_PATCHES_START:
//~ case Event.DELTA_PATCHES_DONE:
//~ case Event.DELTA_PATCH_DONE:
//~ case Event.DELTA_PATCH_FAILED:
//~ case Event.RETRIEVE_START:
//~ case Event.DISKSPACE_START:
//~ case Event.DISKSPACE_DONE:
default: default:
break; break;
} }
pamac_daemon.emit_event ((uint) event, details); pamac_daemon.emit_event ((uint) data.type, secondary_type, details);
} }
private void cb_question (Question question, void *data1, void *data2, void *data3, out int response) { private void cb_question (Question.Data data) {
switch (question) { switch (data.type) {
case Question.INSTALL_IGNOREPKG: case Question.Type.INSTALL_IGNOREPKG:
// Do not install package in IgnorePkg/IgnoreGroup // Do not install package in IgnorePkg/IgnoreGroup
response = 0; data.install_ignorepkg_install = 0;
break; break;
case Question.REPLACE_PKG: case Question.Type.REPLACE_PKG:
// Auto-remove conflicts in case of replaces // Auto-remove conflicts in case of replaces
response = 1; data.replace_replace = 1;
break; break;
case Question.CONFLICT_PKG: case Question.Type.CONFLICT_PKG:
// Auto-remove conflicts // Auto-remove conflicts
response = 1; data.conflict_remove = 1;
break; break;
case Question.REMOVE_PKGS: case Question.Type.REMOVE_PKGS:
// Do not upgrade packages which have unresolvable dependencies // Do not upgrade packages which have unresolvable dependencies
response = 1; data.remove_pkgs_skip = 1;
break; break;
case Question.SELECT_PROVIDER: case Question.Type.SELECT_PROVIDER:
unowned Alpm.List<Package?> providers = (Alpm.List<Package?>) data1; string depend_str = data.select_provider_depend.compute_string ();
Depend *depend = data2;
string depend_str = depend->compute_string ();
string[] providers_str = {}; string[] providers_str = {};
foreach (var pkg in providers) { foreach (unowned Package pkg in data.select_provider_providers) {
providers_str += pkg.name; providers_str += pkg.name;
} }
pamac_daemon.provider_cond = Cond (); pamac_daemon.provider_cond = Cond ();
@ -633,41 +625,28 @@ private void cb_question (Question question, void *data1, void *data2, void *dat
while (pamac_daemon.choosen_provider == null) { while (pamac_daemon.choosen_provider == null) {
pamac_daemon.provider_cond.wait (pamac_daemon.provider_mutex); pamac_daemon.provider_cond.wait (pamac_daemon.provider_mutex);
} }
response = pamac_daemon.choosen_provider; data.select_provider_use_index = pamac_daemon.choosen_provider;
pamac_daemon.provider_mutex.unlock (); pamac_daemon.provider_mutex.unlock ();
break; break;
case Question.CORRUPTED_PKG: case Question.Type.CORRUPTED_PKG:
// Auto-remove corrupted pkgs in cache // Auto-remove corrupted pkgs in cache
response = 1; data.corrupted_remove = 1;
break; break;
case Question.IMPORT_KEY: case Question.Type.IMPORT_KEY:
PGPKey *key = data1;
// Do not get revoked key // Do not get revoked key
if (key->revoked == 1) response = 0; if (data.import_key_key.revoked == 1)
data.import_key_import = 0;
// Auto get not revoked key // Auto get not revoked key
else response = 1; else
data.import_key_import = 1;
break; break;
default: default:
response = 0; data.any_answer = 0;
break; break;
} }
} }
private void cb_progress (Progress progress, string pkgname, int percent, uint n_targets, uint current_target) { private void cb_progress (Progress progress, string pkgname, int percent, uint n_targets, uint current_target) {
//~ switch (progress) {
//~ case Progress.ADD_START:
//~ case Progress.UPGRADE_START:
//~ case Progress.DOWNGRADE_START:
//~ case Progress.REINSTALL_START:
//~ case Progress.REMOVE_START:
//~ case Progress.CONFLICTS_START:
//~ case Progress.DISKSPACE_START:
//~ case Progress.INTEGRITY_START:
//~ case Progress.KEYRING_START:
//~ case Progress.LOAD_START:
//~ default:
//~ break;
//~ }
if ((uint64) percent != pamac_daemon.previous_percent) { if ((uint64) percent != pamac_daemon.previous_percent) {
pamac_daemon.previous_percent = (uint64) percent; pamac_daemon.previous_percent = (uint64) percent;
pamac_daemon.emit_progress ((uint) progress, pkgname, percent, n_targets, current_target); pamac_daemon.emit_progress ((uint) progress, pkgname, percent, n_targets, current_target);

View File

@ -204,7 +204,7 @@ namespace Pamac {
public void show_all_pkgs () { public void show_all_pkgs () {
this.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH)); this.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH));
populate_packages_list (get_all_pkgs (transaction.handle)); populate_packages_list (get_all_pkgs (transaction.alpm_config.handle));
this.get_window ().set_cursor (null); this.get_window ().set_cursor (null);
} }
@ -214,9 +214,9 @@ namespace Pamac {
TreeSelection selection; TreeSelection selection;
selection = repos_treeview.get_selection (); selection = repos_treeview.get_selection ();
selection.changed.disconnect (on_repos_treeview_selection_changed); selection.changed.disconnect (on_repos_treeview_selection_changed);
foreach (unowned DB db in transaction.handle.syncdbs) { foreach (var db in transaction.alpm_config.handle.syncdbs) {
repos_list.insert_with_values (out iter, -1, 0, db.name); repos_list.insert_with_values (out iter, -1, 0, db.name);
foreach (unowned Group grp in db.groupcache) { foreach (var grp in db.groupcache) {
if ((grp.name in grps) == false) { if ((grp.name in grps) == false) {
grps += grp.name; grps += grp.name;
} }
@ -266,7 +266,7 @@ namespace Pamac {
licenses.append (dgettext (null, "Licenses")); licenses.append (dgettext (null, "Licenses"));
licenses.append (":"); licenses.append (":");
if (pkg.alpm_pkg != null) { if (pkg.alpm_pkg != null) {
foreach (unowned string license in pkg.alpm_pkg.licenses) { foreach (var license in pkg.alpm_pkg.licenses) {
licenses.append (" "); licenses.append (" ");
licenses.append (license); licenses.append (license);
} }
@ -299,7 +299,7 @@ namespace Pamac {
if (len != 0) { if (len != 0) {
unowned Depend optdep = list.nth_data (0); unowned Depend optdep = list.nth_data (0);
unowned Alpm.Package? satisfier = find_satisfier ( unowned Alpm.Package? satisfier = find_satisfier (
transaction.handle.localdb.pkgcache, transaction.alpm_config.handle.localdb.pkgcache,
optdep.name); optdep.name);
string optdep_str = optdep.compute_string (); string optdep_str = optdep.compute_string ();
if (satisfier != null) if (satisfier != null)
@ -311,7 +311,7 @@ namespace Pamac {
while (i < len) { while (i < len) {
optdep = list.nth_data (i); optdep = list.nth_data (i);
satisfier = find_satisfier ( satisfier = find_satisfier (
transaction.handle.localdb.pkgcache, transaction.alpm_config.handle.localdb.pkgcache,
optdep.name); optdep.name);
optdep_str = optdep.compute_string (); optdep_str = optdep.compute_string ();
if (satisfier != null) if (satisfier != null)
@ -320,20 +320,21 @@ namespace Pamac {
i++; i++;
} }
} }
if (pkg.origin == PkgFrom.LOCALDB) { if (pkg.origin == Alpm.Package.From.LOCALDB) {
Alpm.List<string?> str_list = pkg.compute_requiredby (); Alpm.List<string?> *str_list = pkg.compute_requiredby ();
len = str_list.length; len = str_list->length;
if (len != 0) { if (len != 0) {
deps_list.insert_with_values (out iter, -1, deps_list.insert_with_values (out iter, -1,
0, dgettext (null, "Required By") + ":", 0, dgettext (null, "Required By") + ":",
1, str_list.nth_data (0)); 1, str_list->nth_data (0));
i = 1; i = 1;
while (i < len) { while (i < len) {
deps_list.insert_with_values (out iter, -1, deps_list.insert_with_values (out iter, -1,
1, str_list.nth_data (i)); 1, str_list->nth_data (i));
i++; i++;
} }
} }
Alpm.List.free_all (str_list);
} }
list = pkg.provides; list = pkg.provides;
len = list.length; len = list.length;
@ -379,7 +380,7 @@ namespace Pamac {
public void set_details_list (Alpm.Package pkg) { public void set_details_list (Alpm.Package pkg) {
details_list.clear (); details_list.clear ();
TreeIter iter; TreeIter iter;
if (pkg.origin == PkgFrom.SYNCDB) { if (pkg.origin == Alpm.Package.From.SYNCDB) {
details_list.insert_with_values (out iter, -1, details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Repository") + ":", 0, dgettext (null, "Repository") + ":",
1, pkg.db.name); 1, pkg.db.name);
@ -401,16 +402,16 @@ namespace Pamac {
details_list.insert_with_values (out iter, -1, details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Packager") + ":", 0, dgettext (null, "Packager") + ":",
1, pkg.packager); 1, pkg.packager);
if (pkg.origin == PkgFrom.LOCALDB) { if (pkg.origin == Alpm.Package.From.LOCALDB) {
GLib.Time time = GLib.Time.local ((time_t) pkg.installdate); GLib.Time time = GLib.Time.local ((time_t) pkg.installdate);
string strtime = time.format ("%a %d %b %Y %X %Z"); string strtime = time.format ("%a %d %b %Y %X %Z");
details_list.insert_with_values (out iter, -1, details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Install Date") + ":", 0, dgettext (null, "Install Date") + ":",
1, strtime); 1, strtime);
string reason; string reason;
if (pkg.reason == PkgReason.EXPLICIT) if (pkg.reason == Alpm.Package.Reason.EXPLICIT)
reason = dgettext (null, "Explicitly installed"); reason = dgettext (null, "Explicitly installed");
else if (pkg.reason == PkgReason.EXPLICIT) else if (pkg.reason == Alpm.Package.Reason.EXPLICIT)
reason = dgettext (null, "Installed as a dependency for another package"); reason = dgettext (null, "Installed as a dependency for another package");
else else
reason = dgettext (null, "Unknown"); reason = dgettext (null, "Unknown");
@ -418,12 +419,12 @@ namespace Pamac {
0, dgettext (null, "Install Reason") + ":", 0, dgettext (null, "Install Reason") + ":",
1, reason); 1, reason);
} }
if (pkg.origin == PkgFrom.SYNCDB) { if (pkg.origin == Alpm.Package.From.SYNCDB) {
details_list.insert_with_values (out iter, -1, details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Signatures") + ":", 0, dgettext (null, "Signatures") + ":",
1, pkg.base64_sig != null ? "Yes" : "No"); 1, pkg.base64_sig != null ? "Yes" : "No");
} }
if (pkg.origin == PkgFrom.LOCALDB) { if (pkg.origin == Alpm.Package.From.LOCALDB) {
unowned Alpm.List<Backup?> backup_list = pkg.backup; unowned Alpm.List<Backup?> backup_list = pkg.backup;
len = backup_list.length; len = backup_list.length;
if (len != 0) { if (len != 0) {
@ -442,7 +443,7 @@ namespace Pamac {
public void set_files_list (Alpm.Package pkg) { public void set_files_list (Alpm.Package pkg) {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
foreach (unowned Alpm.File file in pkg.files) { foreach (var file in pkg.files) {
if (text.len != 0) if (text.len != 0)
text.append ("\n"); text.append ("\n");
text.append ("/"); text.append ("/");
@ -451,12 +452,12 @@ namespace Pamac {
files_textview.buffer.set_text (text.str, (int) text.len); files_textview.buffer.set_text (text.str, (int) text.len);
} }
public async unowned Alpm.List<Alpm.Package?> search_pkgs (string search_string, out Json.Array aur_pkgs) { public async Alpm.List<Alpm.Package?> search_pkgs (string search_string, out Json.Array aur_pkgs) {
unowned Alpm.List<string?> needles = null; Alpm.List<string?> needles = null;
string[] splitted = search_string.split (" "); string[] splitted = search_string.split (" ");
foreach (unowned string part in splitted) foreach (unowned string part in splitted)
needles.add (part); needles.add (part);
unowned Alpm.List<Alpm.Package?> pkgs = search_all_dbs (transaction.handle, needles); Alpm.List<unowned Alpm.Package?> pkgs = search_all_dbs (transaction.alpm_config.handle, needles);
if (search_aur_button.get_active()) { if (search_aur_button.get_active()) {
if (aur_results.contains (search_string)) { if (aur_results.contains (search_string)) {
aur_pkgs = aur_results.get (search_string); aur_pkgs = aur_results.get (search_string);
@ -531,7 +532,7 @@ namespace Pamac {
set_details_list (pkg.alpm_pkg); set_details_list (pkg.alpm_pkg);
deps_scrolledwindow.visible = true; deps_scrolledwindow.visible = true;
details_scrolledwindow.visible = true; details_scrolledwindow.visible = true;
if (pkg.alpm_pkg.origin == PkgFrom.LOCALDB) { if (pkg.alpm_pkg.origin == Alpm.Package.From.LOCALDB) {
set_files_list (pkg.alpm_pkg); set_files_list (pkg.alpm_pkg);
files_scrolledwindow.visible = true; files_scrolledwindow.visible = true;
} else { } else {
@ -561,7 +562,7 @@ namespace Pamac {
packages_list.get_value (iter, 3, out val); packages_list.get_value (iter, 3, out val);
string db_name = val.get_string (); string db_name = val.get_string ();
if (db_name == "local") { if (db_name == "local") {
if ((name in transaction.holdpkg) == false) { if ((name in transaction.alpm_config.holdpkg) == false) {
transaction.to_remove.insert (name, name); transaction.to_remove.insert (name, name);
} }
} else if (db_name == "AUR") { } else if (db_name == "AUR") {
@ -587,7 +588,7 @@ namespace Pamac {
if (pkg.repo == "AUR") if (pkg.repo == "AUR")
transaction.to_build.insert (pkg.name, pkg.name); transaction.to_build.insert (pkg.name, pkg.name);
else { else {
find_pkg = transaction.handle.localdb.get_pkg (pkg.name); find_pkg = transaction.alpm_config.handle.localdb.get_pkg (pkg.name);
if (find_pkg == null) if (find_pkg == null)
transaction.to_add.insert (pkg.name, pkg.name); transaction.to_add.insert (pkg.name, pkg.name);
} }
@ -608,7 +609,7 @@ namespace Pamac {
void on_remove_item_activate () { void on_remove_item_activate () {
foreach (Pamac.Package pkg in selected_pkgs) { foreach (Pamac.Package pkg in selected_pkgs) {
if ((pkg.name in transaction.holdpkg) == false) { if ((pkg.name in transaction.alpm_config.holdpkg) == false) {
if (pkg.repo == "local") if (pkg.repo == "local")
transaction.to_remove.insert (pkg.name, pkg.name); transaction.to_remove.insert (pkg.name, pkg.name);
} }
@ -637,8 +638,8 @@ namespace Pamac {
foreach (Pamac.Package pkg in pkgs) { foreach (Pamac.Package pkg in pkgs) {
var choose_dep_dialog = new ChooseDependenciesDialog (this); var choose_dep_dialog = new ChooseDependenciesDialog (this);
nb = 0; nb = 0;
foreach (unowned Depend opt_dep in pkg.alpm_pkg.optdepends) { foreach (var opt_dep in pkg.alpm_pkg.optdepends) {
found = find_satisfier (transaction.handle.localdb.pkgcache, opt_dep.compute_string ()); found = find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, opt_dep.compute_string ());
if (found == null) { if (found == null) {
choose_dep_dialog.deps_list.insert_with_values (out iter, -1, choose_dep_dialog.deps_list.insert_with_values (out iter, -1,
0, false, 0, false,
@ -678,9 +679,8 @@ namespace Pamac {
void on_explicitly_installed_item_activate () { void on_explicitly_installed_item_activate () {
foreach (Pamac.Package pkg in selected_pkgs) { foreach (Pamac.Package pkg in selected_pkgs) {
transaction.set_pkgreason (pkg.name, PkgReason.EXPLICIT); transaction.set_pkgreason (pkg.name, Alpm.Package.Reason.EXPLICIT);
} }
transaction.refresh_alpm_config ();
refresh_packages_list (); refresh_packages_list ();
} }
@ -743,17 +743,17 @@ namespace Pamac {
if (optdepends.length != 0) { if (optdepends.length != 0) {
uint nb = 0; uint nb = 0;
unowned Alpm.Package? found; unowned Alpm.Package? found;
foreach (unowned Depend opt_dep in optdepends) { foreach (var opt_dep in optdepends) {
found = find_satisfier (transaction.handle.localdb.pkgcache, opt_dep.compute_string ()); found = find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, opt_dep.compute_string ());
if (found == null) if (found == null)
nb += 1; nb += 1;
} }
if (nb != 0) if (nb != 0)
install_optional_deps_item.set_sensitive (true); install_optional_deps_item.set_sensitive (true);
} }
if (clicked_pkg.alpm_pkg.reason == PkgReason.DEPEND) if (clicked_pkg.alpm_pkg.reason == Alpm.Package.Reason.DEPEND)
explicitly_installed_item.set_sensitive (true); explicitly_installed_item.set_sensitive (true);
find_pkg = get_syncpkg (transaction.handle, clicked_pkg.name); find_pkg = get_syncpkg (transaction.alpm_config.handle, clicked_pkg.name);
if (find_pkg != null) { if (find_pkg != null) {
if (pkg_vercmp (find_pkg.version, clicked_pkg.version) == 0) if (pkg_vercmp (find_pkg.version, clicked_pkg.version) == 0)
reinstall_item.set_sensitive (true); reinstall_item.set_sensitive (true);
@ -855,7 +855,7 @@ namespace Pamac {
Gtk.main_iteration (); Gtk.main_iteration ();
search_pkgs.begin (search_string, (obj, res) => { search_pkgs.begin (search_string, (obj, res) => {
Json.Array aur_pkgs; Json.Array aur_pkgs;
unowned Alpm.List<Alpm.Package?> pkgs = search_pkgs.end (res, out aur_pkgs); Alpm.List<Alpm.Package?> pkgs = search_pkgs.end (res, out aur_pkgs);
if (pkgs.length != 0 || aur_pkgs.get_length () != 0) { if (pkgs.length != 0 || aur_pkgs.get_length () != 0) {
// add search string in search_list if needed // add search string in search_list if needed
bool found = false; bool found = false;
@ -922,7 +922,7 @@ namespace Pamac {
string search_string = val.get_string (); string search_string = val.get_string ();
search_pkgs.begin (search_string, (obj, res) => { search_pkgs.begin (search_string, (obj, res) => {
Json.Array aur_pkgs; Json.Array aur_pkgs;
unowned Alpm.List<Alpm.Package?> pkgs = search_pkgs.end (res, out aur_pkgs); Alpm.List<Alpm.Package?> pkgs = search_pkgs.end (res, out aur_pkgs);
populate_packages_list (pkgs, aur_pkgs); populate_packages_list (pkgs, aur_pkgs);
}); });
} }
@ -940,7 +940,7 @@ namespace Pamac {
GLib.Value val; GLib.Value val;
model.get_value (iter, 0, out val); model.get_value (iter, 0, out val);
string grp_name = val.get_string (); string grp_name = val.get_string ();
unowned Alpm.List<Alpm.Package?> pkgs = group_pkgs_all_dbs (transaction.handle, grp_name); Alpm.List<Alpm.Package?> pkgs = group_pkgs_all_dbs (transaction.alpm_config.handle, grp_name);
populate_packages_list (pkgs); populate_packages_list (pkgs);
} }
} }
@ -957,29 +957,29 @@ namespace Pamac {
GLib.Value val; GLib.Value val;
model.get_value (iter, 0, out val); model.get_value (iter, 0, out val);
string state = val.get_string (); string state = val.get_string ();
unowned Alpm.List<Alpm.Package?> pkgs = null; var pkgs = new Alpm.List<unowned Alpm.Package?> ();
unowned Alpm.Package? find_pkg = null; unowned Alpm.Package? find_pkg = null;
if (state == dgettext (null, "To install")) { if (state == dgettext (null, "To install")) {
foreach (string name in transaction.to_add.get_keys ()) { foreach (string name in transaction.to_add.get_keys ()) {
find_pkg = transaction.handle.localdb.get_pkg (name); find_pkg = transaction.alpm_config.handle.localdb.get_pkg (name);
if (find_pkg != null) if (find_pkg != null)
pkgs.add (find_pkg); pkgs.add (find_pkg);
else { else {
find_pkg = get_syncpkg (transaction.handle, name); find_pkg = get_syncpkg (transaction.alpm_config.handle, name);
if (find_pkg != null) if (find_pkg != null)
pkgs.add (find_pkg); pkgs.add (find_pkg);
} }
} }
} else if (state == dgettext (null, "To remove")) { } else if (state == dgettext (null, "To remove")) {
foreach (string name in transaction.to_remove.get_keys ()) { foreach (string name in transaction.to_remove.get_keys ()) {
find_pkg = transaction.handle.localdb.get_pkg (name); find_pkg = transaction.alpm_config.handle.localdb.get_pkg (name);
if (find_pkg != null) if (find_pkg != null)
pkgs.add (find_pkg); pkgs.add (find_pkg);
} }
} else if (state == dgettext (null, "Installed")) { } else if (state == dgettext (null, "Installed")) {
pkgs = transaction.handle.localdb.pkgcache; pkgs = transaction.alpm_config.handle.localdb.pkgcache.copy ();
} else if (state == dgettext (null, "Uninstalled")) { } else if (state == dgettext (null, "Uninstalled")) {
foreach (unowned DB db in transaction.handle.syncdbs) { foreach (var db in transaction.alpm_config.handle.syncdbs) {
if (pkgs.length == 0) if (pkgs.length == 0)
pkgs = db.pkgcache.copy (); pkgs = db.pkgcache.copy ();
else { else {
@ -987,8 +987,8 @@ namespace Pamac {
} }
} }
} else if (state == dgettext (null, "Orphans")) { } else if (state == dgettext (null, "Orphans")) {
foreach (unowned Alpm.Package pkg in transaction.handle.localdb.pkgcache) { foreach (var pkg in transaction.alpm_config.handle.localdb.pkgcache) {
if (pkg.reason == PkgReason.DEPEND) { if (pkg.reason == Alpm.Package.Reason.DEPEND) {
if (pkg.compute_requiredby().length == 0) if (pkg.compute_requiredby().length == 0)
pkgs.add (pkg); pkgs.add (pkg);
} }
@ -1010,19 +1010,19 @@ namespace Pamac {
GLib.Value val; GLib.Value val;
model.get_value (iter, 0, out val); model.get_value (iter, 0, out val);
string repo = val.get_string (); string repo = val.get_string ();
unowned Alpm.List<Alpm.Package?> pkgs = null; var pkgs = new Alpm.List<unowned Alpm.Package?> ();
unowned Alpm.Package? find_pkg = null; unowned Alpm.Package? find_pkg = null;
if (repo == dgettext (null, "local")) { if (repo == dgettext (null, "local")) {
foreach (unowned Alpm.Package pkg in transaction.handle.localdb.pkgcache) { foreach (var pkg in transaction.alpm_config.handle.localdb.pkgcache) {
find_pkg = get_syncpkg (transaction.handle, pkg.name); find_pkg = get_syncpkg (transaction.alpm_config.handle, pkg.name);
if (find_pkg == null) if (find_pkg == null)
pkgs.add (pkg); pkgs.add (pkg);
} }
} else { } else {
foreach (unowned DB db in transaction.handle.syncdbs) { foreach (var db in transaction.alpm_config.handle.syncdbs) {
if (db.name == repo) { if (db.name == repo) {
foreach (unowned Alpm.Package pkg in db.pkgcache) { foreach (var pkg in db.pkgcache) {
find_pkg = transaction.handle.localdb.get_pkg (pkg.name); find_pkg = transaction.alpm_config.handle.localdb.get_pkg (pkg.name);
if (find_pkg != null) if (find_pkg != null)
pkgs.add (find_pkg); pkgs.add (find_pkg);
else else

View File

@ -33,7 +33,7 @@ namespace Pamac {
unowned Json.Object pkg_info; unowned Json.Object pkg_info;
string name; string name;
bool found; bool found;
foreach (Json.Node node in aur_pkgs.get_elements ()) { foreach (var node in aur_pkgs.get_elements ()) {
pkg_info = node.get_object (); pkg_info = node.get_object ();
name = pkg_info.get_string_member ("Name"); name = pkg_info.get_string_member ("Name");
// add only the packages which are not already in the list // add only the packages which are not already in the list
@ -84,7 +84,7 @@ namespace Pamac {
case 1: case 1:
val = Value (typeof (Object)); val = Value (typeof (Object));
if (pkg.alpm_pkg != null) { if (pkg.alpm_pkg != null) {
if (pkg.name in manager_window.transaction.holdpkg) if (pkg.name in manager_window.transaction.alpm_config.holdpkg)
val.set_object (manager_window.locked_icon); val.set_object (manager_window.locked_icon);
else if (pkg.repo == "local") { else if (pkg.repo == "local") {
if (manager_window.transaction.to_add.contains (pkg.name)) if (manager_window.transaction.to_add.contains (pkg.name))

View File

@ -19,19 +19,19 @@
namespace Pamac { namespace Pamac {
public class Config: Object { public class Config: Object {
string conf_path;
public uint64 refresh_period; public uint64 refresh_period;
public bool enable_aur; public bool enable_aur;
public bool recurse; public bool recurse;
public string conf_path;
public Config (string path) { public Config (string path) {
this.conf_path = path; conf_path = path;
// set default options // set default options
this.refresh_period = 4; refresh_period = 4;
this.enable_aur = false; enable_aur = false;
this.recurse = false; recurse = false;
// parse conf file // parse conf file
this.parse_include_file (conf_path); parse_include_file (conf_path);
} }
public void parse_include_file (string path) { public void parse_include_file (string path) {
@ -55,11 +55,11 @@ namespace Pamac {
if (splitted[1] != null) if (splitted[1] != null)
_value = splitted[1].strip (); _value = splitted[1].strip ();
if (_key == "RefreshPeriod") if (_key == "RefreshPeriod")
this.refresh_period = uint64.parse (_value); refresh_period = uint64.parse (_value);
else if (_key == "EnableAUR") else if (_key == "EnableAUR")
this.enable_aur = true; enable_aur = true;
else if (_key == "RemoveUnrequiredDeps") else if (_key == "RemoveUnrequiredDeps")
this.recurse = true; recurse = true;
} }
} catch (GLib.Error e) { } catch (GLib.Error e) {
GLib.stderr.printf("%s\n", e.message); GLib.stderr.printf("%s\n", e.message);
@ -68,7 +68,7 @@ namespace Pamac {
} }
public void write (HashTable<string,string> new_conf) { public void write (HashTable<string,string> new_conf) {
var file = GLib.File.new_for_path (this.conf_path); var file = GLib.File.new_for_path (conf_path);
if (file.query_exists () == false) if (file.query_exists () == false)
GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ()); GLib.stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
else { else {
@ -84,7 +84,7 @@ namespace Pamac {
if (new_conf.contains ("RefreshPeriod")) { if (new_conf.contains ("RefreshPeriod")) {
string _value = new_conf.get ("RefreshPeriod"); string _value = new_conf.get ("RefreshPeriod");
data += "RefreshPeriod = %s\n".printf (_value); data += "RefreshPeriod = %s\n".printf (_value);
this.refresh_period = uint64.parse (_value); refresh_period = uint64.parse (_value);
} else } else
data += line + "\n"; data += line + "\n";
} else if (line.contains ("EnableAUR")) { } else if (line.contains ("EnableAUR")) {
@ -94,7 +94,7 @@ namespace Pamac {
data += "EnableAUR\n"; data += "EnableAUR\n";
else else
data += "#EnableAUR\n"; data += "#EnableAUR\n";
this.enable_aur = _value; enable_aur = _value;
} else } else
data += line + "\n"; data += line + "\n";
} else if (line.contains ("RemoveUnrequiredDeps")) { } else if (line.contains ("RemoveUnrequiredDeps")) {
@ -104,7 +104,7 @@ namespace Pamac {
data += "RemoveUnrequiredDeps\n"; data += "RemoveUnrequiredDeps\n";
else else
data += "#RemoveUnrequiredDeps\n"; data += "#RemoveUnrequiredDeps\n";
this.enable_aur = _value; enable_aur = _value;
} else } else
data += line + "\n"; data += line + "\n";
} else } else
@ -125,9 +125,9 @@ namespace Pamac {
} }
public void reload () { public void reload () {
this.enable_aur = false; enable_aur = false;
this.recurse = false; recurse = false;
this.parse_include_file (this.conf_path); parse_include_file (conf_path);
} }
} }
} }

View File

@ -41,7 +41,7 @@ namespace Pamac {
public abstract void trans_cancel () throws IOError; public abstract void trans_cancel () throws IOError;
[DBus (no_reply = true)] [DBus (no_reply = true)]
public abstract void quit () throws IOError; public abstract void quit () throws IOError;
public signal void emit_event (uint event, string[] details); public signal void emit_event (uint primary_event, uint secondary_event, string[] details);
public signal void emit_providers (string depend, string[] providers); public signal void emit_providers (string depend, string[] providers);
public signal void emit_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target); public signal void emit_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target);
public signal void emit_download (string filename, uint64 xfered, uint64 total); public signal void emit_download (string filename, uint64 xfered, uint64 total);
@ -55,10 +55,7 @@ namespace Pamac {
public class Transaction: Object { public class Transaction: Object {
public Daemon daemon; public Daemon daemon;
public string[] syncfirst; public Alpm.Config alpm_config;
public string[] holdpkg;
public string[] ignorepkg;
public Handle handle;
public Alpm.TransFlag flags; public Alpm.TransFlag flags;
// those hashtables will be used as set // those hashtables will be used as set
@ -97,7 +94,7 @@ namespace Pamac {
public signal void finished (bool error); public signal void finished (bool error);
public Transaction (ApplicationWindow? window) { public Transaction (ApplicationWindow? window) {
refresh_alpm_config (); alpm_config = new Alpm.Config ("/etc/pacman.conf");
mode = Mode.MANAGER; mode = Mode.MANAGER;
flags = Alpm.TransFlag.CASCADE; flags = Alpm.TransFlag.CASCADE;
to_add = new HashTable<string, string> (str_hash, str_equal); to_add = new HashTable<string, string> (str_hash, str_equal);
@ -156,21 +153,17 @@ namespace Pamac {
} }
} }
public void set_pkgreason (string pkgname, PkgReason reason) { public void set_pkgreason (string pkgname, Alpm.Package.Reason reason) {
try { try {
daemon.set_pkgreason (pkgname, (uint) reason); daemon.set_pkgreason (pkgname, (uint) reason);
refresh_alpm_config (); refresh_handle ();
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message); stderr.printf ("IOError: %s\n", e.message);
} }
} }
public void refresh_alpm_config () { public void refresh_handle () {
var alpm_config = new Alpm.Config ("/etc/pacman.conf"); alpm_config.get_handle ();
syncfirst = alpm_config.get_syncfirst ();
holdpkg = alpm_config.get_holdpkg ();
ignorepkg = alpm_config.get_ignore_pkgs ();
handle = alpm_config.get_handle ();
} }
public void refresh (int force) { public void refresh (int force) {
@ -239,7 +232,7 @@ namespace Pamac {
Gtk.main_iteration (); Gtk.main_iteration ();
// sysupgrade // sysupgrade
// get syncfirst updates // get syncfirst updates
UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (handle, syncfirst); UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (alpm_config.handle, alpm_config.syncfirst);
if (syncfirst_updates.length != 0) { if (syncfirst_updates.length != 0) {
clear_lists (); clear_lists ();
if (mode == Mode.MANAGER) if (mode == Mode.MANAGER)
@ -249,11 +242,11 @@ namespace Pamac {
// run as a standard transaction // run as a standard transaction
run (); run ();
} else { } else {
UpdatesInfos[] repos_updates = get_repos_updates (handle, ignorepkg); UpdatesInfos[] repos_updates = get_repos_updates (alpm_config.handle, alpm_config.ignore_pkgs);
int repos_updates_len = repos_updates.length; int repos_updates_len = repos_updates.length;
if (check_aur) { if (check_aur) {
if (aur_checked == false) { if (aur_checked == false) {
aur_updates = get_aur_updates (handle, ignorepkg); aur_updates = get_aur_updates (alpm_config.handle, alpm_config.ignore_pkgs);
aur_checked = true; aur_checked = true;
} }
if (aur_updates.length != 0) { if (aur_updates.length != 0) {
@ -394,7 +387,7 @@ namespace Pamac {
} }
foreach (UpdatesInfos pkg_info in prepared_to_add) { foreach (UpdatesInfos pkg_info in prepared_to_add) {
dsize += pkg_info.download_size; dsize += pkg_info.download_size;
unowned Alpm.Package? local_pkg = handle.localdb.get_pkg (pkg_info.name); unowned Alpm.Package? local_pkg = alpm_config.handle.localdb.get_pkg (pkg_info.name);
if (local_pkg == null) { if (local_pkg == null) {
to_install += "%s %s".printf (pkg_info.name, pkg_info.version); to_install += "%s %s".printf (pkg_info.name, pkg_info.version);
} else { } else {
@ -569,137 +562,160 @@ namespace Pamac {
term.set_pty (pty); term.set_pty (pty);
} }
void on_emit_event (uint event, string[] details) { void on_emit_event (uint primary_event, uint secondary_event, string[] details) {
string msg; string msg;
switch (event) { switch (primary_event) {
case Event.CHECKDEPS_START: case Event.Type.CHECKDEPS_START:
msg = dgettext (null, "Checking dependencies") + "..."; msg = dgettext (null, "Checking dependencies") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.FILECONFLICTS_START: case Event.Type.FILECONFLICTS_START:
msg = dgettext (null, "Checking file conflicts") + "..."; msg = dgettext (null, "Checking file conflicts") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.RESOLVEDEPS_START: case Event.Type.RESOLVEDEPS_START:
msg = dgettext (null, "Resolving dependencies") + "..."; msg = dgettext (null, "Resolving dependencies") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.INTERCONFLICTS_START: case Event.Type.INTERCONFLICTS_START:
msg = dgettext (null, "Checking inter-conflicts") + "..."; msg = dgettext (null, "Checking inter-conflicts") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.ADD_START: case Event.Type.PACKAGE_OPERATION_START:
progress_dialog.cancel_button.set_visible (false); switch (secondary_event) {
previous_filename = details[0]; case Alpm.Package.Operation.INSTALL:
msg = dgettext (null, "Installing %s").printf (details[0]) + "..."; progress_dialog.cancel_button.set_visible (false);
progress_dialog.action_label.set_text (msg); previous_filename = details[0];
msg = dgettext (null, "Installing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "..."; msg = dgettext (null, "Installing %s").printf (details[0]) + "...";
spawn_in_term ({"/usr/bin/echo", msg}); progress_dialog.action_label.set_text (msg);
msg = dgettext (null, "Installing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
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]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
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]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
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]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
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]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
break;
}
break; break;
case Event.REINSTALL_START: case Event.Type.INTEGRITY_START:
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]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.REMOVE_START:
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]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.UPGRADE_START:
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]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DOWNGRADE_START:
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]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.INTEGRITY_START:
msg = dgettext (null, "Checking integrity") + "..."; msg = dgettext (null, "Checking integrity") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.KEYRING_START: case Event.Type.KEYRING_START:
progress_dialog.cancel_button.set_visible (true); progress_dialog.cancel_button.set_visible (true);
msg = dgettext (null, "Checking keyring") + "..."; msg = dgettext (null, "Checking keyring") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.KEY_DOWNLOAD_START: case Event.Type.KEY_DOWNLOAD_START:
msg = dgettext (null, "Downloading required keys") + "..."; msg = dgettext (null, "Downloading required keys") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.LOAD_START: case Event.Type.LOAD_START:
msg = dgettext (null, "Loading packages files") + "..."; msg = dgettext (null, "Loading packages files") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.DELTA_INTEGRITY_START: case Event.Type.DELTA_INTEGRITY_START:
msg = dgettext (null, "Checking delta integrity") + "..."; msg = dgettext (null, "Checking delta integrity") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.DELTA_PATCHES_START: case Event.Type.DELTA_PATCHES_START:
msg = dgettext (null, "Applying deltas") + "..."; msg = dgettext (null, "Applying deltas") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.DELTA_PATCH_START: case Event.Type.DELTA_PATCH_START:
msg = dgettext (null, "Generating %s with %s").printf (details[0], details[1]) + "..."; msg = dgettext (null, "Generating %s with %s").printf (details[0], details[1]) + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.DELTA_PATCH_DONE: case Event.Type.DELTA_PATCH_DONE:
msg = dgettext (null, "Generation succeeded") + "..."; msg = dgettext (null, "Generation succeeded") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.DELTA_PATCH_FAILED: case Event.Type.DELTA_PATCH_FAILED:
msg = dgettext (null, "Generation failed") + "..."; msg = dgettext (null, "Generation failed") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.SCRIPTLET_INFO: case Event.Type.SCRIPTLET_INFO:
progress_dialog.action_label.set_text (dgettext (null, "Configuring %s").printf (previous_filename) + "..."); progress_dialog.action_label.set_text (dgettext (null, "Configuring %s").printf (previous_filename) + "...");
progress_dialog.expander.set_expanded (true); progress_dialog.expander.set_expanded (true);
spawn_in_term ({"/usr/bin/echo", "-n", details[0]}); spawn_in_term ({"/usr/bin/echo", "-n", details[0]});
break; break;
case Event.RETRIEVE_START: case Event.Type.RETRIEVE_START:
progress_dialog.cancel_button.set_visible (true); progress_dialog.cancel_button.set_visible (true);
msg = dgettext (null, "Downloading") + "..."; msg = dgettext (null, "Downloading") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.DISKSPACE_START: case Event.Type.PKGDOWNLOAD_START:
string label;
if (details[0].has_suffix (".db")) {
label = dgettext (null, "Refreshing %s").printf (details[0].replace (".db", "")) + "...";
} else {
label = dgettext (null, "Downloading %s").printf (details[0].replace (".pkg.tar.xz", "")) + "...";
}
progress_dialog.action_label.set_text (label);
spawn_in_term ({"/usr/bin/echo", label});
break;
case Event.Type.DISKSPACE_START:
msg = dgettext (null, "Checking available disk space") + "..."; msg = dgettext (null, "Checking available disk space") + "...";
progress_dialog.action_label.set_text (msg); progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg}); spawn_in_term ({"/usr/bin/echo", msg});
break; break;
case Event.OPTDEP_REQUIRED: case Event.Type.OPTDEP_REMOVAL:
spawn_in_term ({"/usr/bin/echo", dgettext (null, "%s optionally requires %s").printf (details[0], details[1])}); spawn_in_term ({"/usr/bin/echo", dgettext (null, "%s optionally requires %s").printf (details[0], details[1])});
break; break;
case Event.DATABASE_MISSING: case Event.Type.DATABASE_MISSING:
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Database file for %s does not exist").printf (details[0])}); spawn_in_term ({"/usr/bin/echo", dgettext (null, "Database file for %s does not exist").printf (details[0])});
break; break;
case Event.Type.PACNEW_CREATED:
spawn_in_term ({"/usr/bin/echo", dgettext (null, "%s installed as %s.pacnew").printf (details[0])});
break;
case Event.Type.PACSAVE_CREATED:
spawn_in_term ({"/usr/bin/echo", dgettext (null, "%s installed as %s.pacsave").printf (details[0])});
break;
case Event.Type.PACORIG_CREATED:
spawn_in_term ({"/usr/bin/echo", dgettext (null, "%s installed as %s.pacorig").printf (details[0])});
break;
default: default:
break; break;
} }
@ -744,22 +760,22 @@ namespace Pamac {
} }
void on_emit_download (string filename, uint64 xfered, uint64 total) { void on_emit_download (string filename, uint64 xfered, uint64 total) {
string label; //~ string label;
string textbar; string textbar;
double fraction; double fraction;
if (filename != previous_filename) { //~ if (filename != previous_filename) {
previous_filename = filename; //~ previous_filename = filename;
if (filename.has_suffix (".db")) { //~ if (filename.has_suffix (".db")) {
label = dgettext (null, "Refreshing %s").printf (filename.replace (".db", "")) + "..."; //~ label = dgettext (null, "Refreshing %s").printf (filename.replace (".db", "")) + "...";
} else { //~ } else {
label = dgettext (null, "Downloading %s").printf (filename.replace (".pkg.tar.xz", "")) + "..."; //~ label = dgettext (null, "Downloading %s").printf (filename.replace (".pkg.tar.xz", "")) + "...";
} //~ }
if (label != previous_label) { //~ if (label != previous_label) {
previous_label = label; //~ previous_label = label;
progress_dialog.action_label.set_text (label); //~ progress_dialog.action_label.set_text (label);
spawn_in_term ({"/usr/bin/echo", label}); //~ spawn_in_term ({"/usr/bin/echo", label});
} //~ }
} //~ }
if (total_download > 0) { if (total_download > 0) {
fraction = (float) (xfered + already_downloaded) / total_download; fraction = (float) (xfered + already_downloaded) / total_download;
if (fraction > 0) if (fraction > 0)
@ -871,7 +887,7 @@ namespace Pamac {
public void on_emit_refreshed (ErrorInfos error) { public void on_emit_refreshed (ErrorInfos error) {
print ("transaction refreshed\n"); print ("transaction refreshed\n");
refresh_alpm_config (); refresh_handle ();
if (error.str == "") { if (error.str == "") {
if (mode == Mode.UPDATER) { if (mode == Mode.UPDATER) {
progress_dialog.hide (); progress_dialog.hide ();
@ -975,7 +991,7 @@ namespace Pamac {
//progress_dialog.close_button.set_visible (true); //progress_dialog.close_button.set_visible (true);
clear_lists (); clear_lists ();
show_warnings (); show_warnings ();
refresh_alpm_config (); refresh_handle ();
if (sysupgrade_after_trans) { if (sysupgrade_after_trans) {
sysupgrade_after_trans = false; sysupgrade_after_trans = false;
sysupgrade (0); sysupgrade (0);
@ -993,7 +1009,7 @@ namespace Pamac {
} }
} }
} else { } else {
refresh_alpm_config (); refresh_handle ();
finished (true); finished (true);
handle_error (error); handle_error (error);
} }

View File

@ -131,7 +131,7 @@ namespace Pamac {
top_label.set_markup (""); top_label.set_markup ("");
updates_list.clear (); updates_list.clear ();
// get syncfirst updates // get syncfirst updates
UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (transaction.handle, transaction.syncfirst); UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (transaction.alpm_config.handle, transaction.alpm_config.syncfirst);
if (syncfirst_updates.length != 0) { if (syncfirst_updates.length != 0) {
updates_nb = syncfirst_updates.length; updates_nb = syncfirst_updates.length;
foreach (UpdatesInfos infos in syncfirst_updates) { foreach (UpdatesInfos infos in syncfirst_updates) {
@ -146,7 +146,7 @@ namespace Pamac {
} else { } else {
while (Gtk.events_pending ()) while (Gtk.events_pending ())
Gtk.main_iteration (); Gtk.main_iteration ();
UpdatesInfos[] updates = get_repos_updates (transaction.handle, transaction.ignorepkg); UpdatesInfos[] updates = get_repos_updates (transaction.alpm_config.handle, transaction.alpm_config.ignore_pkgs);
foreach (UpdatesInfos infos in updates) { foreach (UpdatesInfos infos in updates) {
name = infos.name + " " + infos.version; name = infos.name + " " + infos.version;
if (infos.download_size != 0) if (infos.download_size != 0)
@ -158,7 +158,7 @@ namespace Pamac {
} }
updates_nb += updates.length; updates_nb += updates.length;
if (pamac_config.enable_aur) { if (pamac_config.enable_aur) {
UpdatesInfos[] aur_updates = get_aur_updates (transaction.handle, transaction.ignorepkg); UpdatesInfos[] aur_updates = get_aur_updates (transaction.alpm_config.handle, transaction.alpm_config.ignore_pkgs);
updates_nb += aur_updates.length; updates_nb += aur_updates.length;
foreach (UpdatesInfos infos in aur_updates) { foreach (UpdatesInfos infos in aur_updates) {
name = infos.name + " " + infos.version; name = infos.name + " " + infos.version;

View File

@ -41,18 +41,22 @@ alpm_list_t* alpm_list_sort_data (alpm_list_t *list, alpm_list_fn_cmp fn) {
return list; return list;
} }
void alpm_list_free_all(alpm_list_t *list) { alpm_list_t *alpm_list_new () {
do { alpm_list_free_inner(list, free); alpm_list_free(list); list = NULL; } while(0); return NULL;
} }
void alpm_list_iterator(alpm_list_t *list, alpm_list_iterator_t* iter) { void alpm_list_free_all (alpm_list_t *list) {
do { alpm_list_free_inner (list, free); alpm_list_free (list); list = NULL; } while (0);
}
void alpm_list_iterator (alpm_list_t *list, alpm_list_iterator_t* iter) {
iter->pos = list; iter->pos = list;
} }
void* alpm_list_iterator_next_value (alpm_list_iterator_t *iter) { void* alpm_list_iterator_next_value (alpm_list_iterator_t *iter) {
if (iter->pos) { if (iter->pos) {
void* result = alpm_list_get_data(iter->pos); void* result = alpm_list_get_data (iter->pos);
iter->pos = alpm_list_next(iter->pos); iter->pos = alpm_list_next (iter->pos);
return result; return result;
} }
else return NULL; else return NULL;

View File

@ -7,15 +7,16 @@ typedef struct __alpm_list_iterator_t {
alpm_list_t* pos; alpm_list_t* pos;
} alpm_list_iterator_t; } alpm_list_iterator_t;
void* alpm_list_get_data(alpm_list_t *list); void* alpm_list_get_data (alpm_list_t *list);
void* alpm_list_nth_data (alpm_list_t *list, size_t n); void* alpm_list_nth_data (alpm_list_t *list, size_t n);
alpm_list_t *alpm_list_remove_data(alpm_list_t *list, const void *needle, alpm_list_fn_cmp fn); alpm_list_t *alpm_list_remove_data (alpm_list_t *list, const void *needle, alpm_list_fn_cmp fn);
alpm_list_t *alpm_list_sort_data(alpm_list_t *list, alpm_list_fn_cmp fn); alpm_list_t *alpm_list_sort_data (alpm_list_t *list, alpm_list_fn_cmp fn);
void alpm_list_free_all(alpm_list_t *list); alpm_list_t *alpm_list_new ();
void alpm_list_iterator(alpm_list_t *list, alpm_list_iterator_t* i); void alpm_list_free_all (alpm_list_t *list);
void* alpm_list_iterator_next_value(alpm_list_iterator_t *iter); void alpm_list_iterator (alpm_list_t *list, alpm_list_iterator_t* i);
void* alpm_list_iterator_next_value (alpm_list_iterator_t *iter);
alpm_pkg_t* alpm_pkg_load_file(alpm_handle_t *handle, const char *filename, int full, alpm_siglevel_t level); alpm_pkg_t* alpm_pkg_load_file (alpm_handle_t *handle, const char *filename, int full, alpm_siglevel_t level);
alpm_list_t* alpm_pkg_get_files_list (alpm_pkg_t* pkg); alpm_list_t* alpm_pkg_get_files_list (alpm_pkg_t* pkg);
#endif //!ALPM_VALA_H #endif //!ALPM_VALA_H

File diff suppressed because it is too large Load Diff