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

View File

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

View File

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

View File

@ -29,10 +29,7 @@ MainLoop loop;
namespace Pamac {
[DBus (name = "org.manjaro.pamac")]
public class Daemon : Object {
string[] syncfirst;
string[] holdpkg;
string[] ignorepkg;
Handle? handle;
Alpm.Config alpm_config;
public uint64 previous_percent;
int force_refresh;
bool emit_refreshed_signal;
@ -40,7 +37,7 @@ namespace Pamac {
public Mutex provider_mutex;
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_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target);
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 Daemon () {
alpm_config = new Alpm.Config ("/etc/pacman.conf");
}
private void init_alpm_config () {
var alpm_config = new Alpm.Config ("/etc/pacman.conf");
syncfirst = alpm_config.get_syncfirst ();
holdpkg = alpm_config.get_holdpkg ();
ignorepkg = alpm_config.get_ignore_pkgs ();
handle = alpm_config.get_handle ();
if (handle == null) {
private void refresh_handle () {
alpm_config.get_handle ();
if (alpm_config.handle == null) {
ErrorInfos err = ErrorInfos ();
err.str = _("Failed to initialize alpm library");
emit_trans_committed (err);
} else {
handle.eventcb = (EventCallBack) cb_event;
handle.progresscb = (ProgressCallBack) cb_progress;
handle.questioncb = (QuestionCallBack) cb_question;
handle.dlcb = (DownloadCallBack) cb_download;
handle.totaldlcb = (TotalDownloadCallBack) cb_totaldownload;
handle.logcb = (LogCallBack) cb_log;
alpm_config.handle.eventcb = (EventCallBack) cb_event;
alpm_config.handle.progresscb = (ProgressCallBack) cb_progress;
alpm_config.handle.questioncb = (QuestionCallBack) cb_question;
alpm_config.handle.dlcb = (DownloadCallBack) cb_download;
alpm_config.handle.totaldlcb = (TotalDownloadCallBack) cb_totaldownload;
alpm_config.handle.logcb = (LogCallBack) cb_log;
}
previous_percent = 0;
}
@ -106,10 +100,10 @@ namespace Pamac {
null
);
if (result.get_is_authorized ()) {
init_alpm_config ();
unowned Package? pkg = handle.localdb.get_pkg (pkgname);
refresh_handle ();
unowned Package? pkg = alpm_config.handle.localdb.get_pkg (pkgname);
if (pkg != null)
pkg.reason = (PkgReason) reason;
pkg.reason = (Package.Reason) reason;
}
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
@ -117,12 +111,12 @@ namespace Pamac {
}
private int refresh_real () {
init_alpm_config ();
refresh_handle ();
ErrorInfos err = ErrorInfos ();
string[] details = {};
int success = 0;
int ret;
foreach (var db in handle.syncdbs) {
foreach (var db in alpm_config.handle.syncdbs) {
ret = db.update (force_refresh);
if (ret >= 0) {
success++;
@ -132,7 +126,7 @@ namespace Pamac {
// fail later with unresolved deps, but that should be rare, and would be expected
if (success == 0) {
err.str = _("Failed to synchronize any databases");
details += Alpm.strerror (handle.errno ());
details += Alpm.strerror (alpm_config.handle.errno ());
err.details = details;
}
if (emit_refreshed_signal)
@ -151,16 +145,16 @@ namespace Pamac {
}
public UpdatesInfos[] get_updates () {
init_alpm_config ();
refresh_handle ();
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
UpdatesInfos[] updates = {};
updates = get_syncfirst_updates (handle, syncfirst);
updates = get_syncfirst_updates (alpm_config.handle, alpm_config.syncfirst);
if (updates.length != 0) {
return updates;
} else {
updates = get_repos_updates (handle, ignorepkg);
updates = get_repos_updates (alpm_config.handle, alpm_config.ignore_pkgs);
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)
updates += infos;
}
@ -169,13 +163,13 @@ namespace Pamac {
}
public ErrorInfos trans_init (TransFlag transflags) {
init_alpm_config ();
refresh_handle ();
ErrorInfos err = ErrorInfos ();
string[] details = {};
int ret = handle.trans_init (transflags);
int ret = alpm_config.handle.trans_init (transflags);
if (ret == -1) {
err.str = _("Failed to init transaction");
details += Alpm.strerror (handle.errno ());
details += Alpm.strerror (alpm_config.handle.errno ());
err.details = details;
}
return err;
@ -184,10 +178,10 @@ namespace Pamac {
public ErrorInfos trans_sysupgrade (int enable_downgrade) {
ErrorInfos err = ErrorInfos ();
string[] details = {};
int ret = handle.trans_sysupgrade (enable_downgrade);
int ret = alpm_config.handle.trans_sysupgrade (enable_downgrade);
if (ret == -1) {;
err.str = _("Failed to prepare transaction");
details += Alpm.strerror (handle.errno ());
details += Alpm.strerror (alpm_config.handle.errno ());
err.details = details;
}
return err;
@ -197,8 +191,8 @@ namespace Pamac {
ErrorInfos err = ErrorInfos ();
string[] details = {};
unowned Package? pkg = null;
pkg = handle.find_dbs_satisfier (handle.syncdbs, pkgname);
//foreach (var db in handle.syncdbs) {
pkg = alpm_config.handle.find_dbs_satisfier (alpm_config.handle.syncdbs, pkgname);
//foreach (var db in alpm_config.handle.syncdbs) {
//pkg = find_satisfier (db.pkgcache, pkgname);
//if (pkg != null)
//break;
@ -209,9 +203,9 @@ namespace Pamac {
err.details = details;
return err;
}
int ret = handle.trans_add_pkg (pkg);
int ret = alpm_config.handle.trans_add_pkg (pkg);
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)
// just skip duplicate or ignored targets
return err;
@ -228,16 +222,16 @@ namespace Pamac {
public ErrorInfos trans_load_pkg (string pkgpath) {
ErrorInfos err = ErrorInfos ();
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) {
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;
return err;
} else {
int ret = handle.trans_add_pkg (pkg);
int ret = alpm_config.handle.trans_add_pkg (pkg);
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)
// just skip duplicate or ignored targets
return err;
@ -257,17 +251,17 @@ namespace Pamac {
public ErrorInfos trans_remove_pkg (string pkgname) {
ErrorInfos err = ErrorInfos ();
string[] details = {};
unowned Package? pkg = handle.localdb.get_pkg (pkgname);
unowned Package? pkg = alpm_config.handle.localdb.get_pkg (pkgname);
if (pkg == null) {
err.str = _("Failed to prepare transaction");
details += _("target not found: %s").printf (pkgname);
err.details = details;
return err;
}
int ret = handle.trans_remove_pkg (pkg);
int ret = alpm_config.handle.trans_remove_pkg (pkg);
if (ret == -1) {
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;
}
return err;
@ -277,9 +271,9 @@ namespace Pamac {
ErrorInfos err = ErrorInfos ();
string[] details = {};
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) {
Alpm.Errno errno = handle.errno ();
Alpm.Errno errno = alpm_config.handle.errno ();
err.str = _("Failed to prepare transaction");
string detail = Alpm.strerror (errno);
switch (errno) {
@ -289,6 +283,7 @@ namespace Pamac {
foreach (void *i in err_data) {
char *pkgname = i;
details += _("package %s does not have a valid architecture").printf (pkgname);
delete pkgname;
}
break;
case Errno.UNSATISFIED_DEPS:
@ -298,6 +293,7 @@ namespace Pamac {
DepMissing *miss = i;
string depstring = miss->depend.compute_string ();
details += _("%s: requires %s").printf (miss->target, depstring);
delete miss;
}
break;
case Errno.CONFLICTING_DEPS:
@ -307,10 +303,11 @@ namespace Pamac {
Conflict *conflict = i;
detail = _("%s and %s are in conflict").printf (conflict->package1, conflict->package2);
// 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 ());
}
details += detail;
delete conflict;
}
break;
default:
@ -322,8 +319,8 @@ namespace Pamac {
} else {
// Search for holdpkg in target list
bool found_locked_pkg = false;
foreach (var pkg in handle.trans_to_remove ()) {
if (pkg.name in holdpkg) {
foreach (var pkg in alpm_config.handle.trans_to_remove ()) {
if (pkg.name in alpm_config.holdpkg) {
details += _("%s needs to be removed but it is a locked package").printf (pkg.name);
found_locked_pkg = true;
break;
@ -357,7 +354,7 @@ namespace Pamac {
public UpdatesInfos[] trans_to_add () {
UpdatesInfos info = UpdatesInfos ();
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.version = pkg.version;
// if pkg was load from a file, pkg.db is null
@ -375,7 +372,7 @@ namespace Pamac {
public UpdatesInfos[] trans_to_remove () {
UpdatesInfos info = UpdatesInfos ();
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.version = pkg.version;
info.db_name = pkg.db.name;
@ -390,29 +387,30 @@ namespace Pamac {
ErrorInfos err = ErrorInfos ();
string[] details = {};
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) {
Alpm.Errno errno = handle.errno ();
Alpm.Errno errno = alpm_config.handle.errno ();
err.str = _("Failed to commit transaction");
string detail = Alpm.strerror (errno);
switch (errno) {
case Alpm.Errno.FILE_CONFLICTS:
detail += ":";
details += detail;
//TransFlag flags = handle.trans_get_flags ();
//TransFlag flags = alpm_config.handle.trans_get_flags ();
//if ((flags & TransFlag.FORCE) != 0) {
//details += _("unable to %s directory-file conflicts").printf ("--force");
//}
foreach (void *i in err_data) {
FileConflict *conflict = i;
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);
break;
case FileConflictType.FILESYSTEM:
case FileConflict.Type.FILESYSTEM:
details += _("%s: %s already exists in filesystem").printf (conflict->target, conflict->file);
break;
}
delete conflict;
}
break;
case Alpm.Errno.PKG_INVALID:
@ -424,6 +422,7 @@ namespace Pamac {
foreach (void *i in err_data) {
char *filename = i;
details += _("%s is invalid or corrupted").printf (filename);
delete filename;
}
break;
default:
@ -470,13 +469,13 @@ namespace Pamac {
}
public int trans_release () {
return handle.trans_release ();
return alpm_config.handle.trans_release ();
}
public void trans_cancel () {
handle.trans_interrupt ();
handle.trans_release ();
init_alpm_config ();
alpm_config.handle.trans_interrupt ();
alpm_config.handle.trans_release ();
refresh_handle ();
}
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 = {};
switch (event) {
case Event.ADD_START:
case Event.REMOVE_START:
case Event.REINSTALL_START:
unowned Package pkg = (Package) data1;
details += pkg.name;
details += pkg.version;
uint secondary_type = 0;
switch (data.type) {
case Event.Type.PACKAGE_OPERATION_START:
switch (data.package_operation_operation) {
case Package.Operation.REMOVE:
details += data.package_operation_oldpkg.name;
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;
case Event.ADD_DONE:
unowned Package pkg = (Package) data1;
string log = "Installed %s (%s)\n".printf (pkg.name, pkg.version);
write_log_file (log);
case Event.Type.PACKAGE_OPERATION_DONE:
switch (data.package_operation_operation) {
case Package.Operation.INSTALL:
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;
case Event.REMOVE_DONE:
unowned Package pkg = (Package) data1;
string log = "Removed %s (%s)\n".printf (pkg.name, pkg.version);
write_log_file (log);
case Event.Type.DELTA_PATCH_START:
details += data.delta_patch_delta.to;
details += data.delta_patch_delta.delta;
break;
case Event.REINSTALL_DONE:
unowned Package pkg = (Package) data1;
string log = "Reinstalled %s (%s)\n".printf (pkg.name, pkg.version);
write_log_file (log);
case Event.Type.SCRIPTLET_INFO:
details += data.scriptlet_info_line;
write_log_file (data.scriptlet_info_line);
break;
case Event.UPGRADE_START:
case Event.DOWNGRADE_START:
unowned Package new_pkg = (Package) data1;
unowned Package old_pkg = (Package) data2;
details += old_pkg.name;
details += old_pkg.version;
details += new_pkg.version;
case Event.Type.PKGDOWNLOAD_START:
details += data.pkgdownload_file;
break;
case Event.UPGRADE_DONE:
unowned Package new_pkg = (Package) data1;
unowned Package old_pkg = (Package) data2;
string log = "Upgraded %s (%s -> %s)\n".printf (old_pkg.name, old_pkg.version, new_pkg.version);
write_log_file (log);
case Event.Type.OPTDEP_REMOVAL:
details += data.optdep_removal_pkg.name;
details += data.optdep_removal_optdep.compute_string ();
break;
case Event.DOWNGRADE_DONE:
unowned Package new_pkg = (Package) data1;
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);
case Event.Type.DATABASE_MISSING:
details += data.database_missing_dbname;
break;
case Event.DELTA_PATCH_START:
unowned string string1 = (string) data1;
unowned string string2 = (string) data2;
details += string1;
details += string2;
case Event.Type.PACNEW_CREATED:
details += data.pacnew_created_file;
break;
case Event.SCRIPTLET_INFO:
unowned string info = (string) data1;
details += info;
write_log_file (info);
case Event.Type.PACSAVE_CREATED:
details += data.pacsave_created_file;
break;
case Event.OPTDEP_REQUIRED:
unowned Package pkg = (Package) data1;
Depend *depend = data2;
details += pkg.name;
details += depend->compute_string ();
case Event.Type.PACORIG_CREATED:
details += data.pacorig_created_file;
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:
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) {
switch (question) {
case Question.INSTALL_IGNOREPKG:
private void cb_question (Question.Data data) {
switch (data.type) {
case Question.Type.INSTALL_IGNOREPKG:
// Do not install package in IgnorePkg/IgnoreGroup
response = 0;
data.install_ignorepkg_install = 0;
break;
case Question.REPLACE_PKG:
case Question.Type.REPLACE_PKG:
// Auto-remove conflicts in case of replaces
response = 1;
data.replace_replace = 1;
break;
case Question.CONFLICT_PKG:
case Question.Type.CONFLICT_PKG:
// Auto-remove conflicts
response = 1;
data.conflict_remove = 1;
break;
case Question.REMOVE_PKGS:
case Question.Type.REMOVE_PKGS:
// Do not upgrade packages which have unresolvable dependencies
response = 1;
data.remove_pkgs_skip = 1;
break;
case Question.SELECT_PROVIDER:
unowned Alpm.List<Package?> providers = (Alpm.List<Package?>) data1;
Depend *depend = data2;
string depend_str = depend->compute_string ();
case Question.Type.SELECT_PROVIDER:
string depend_str = data.select_provider_depend.compute_string ();
string[] providers_str = {};
foreach (var pkg in providers) {
foreach (unowned Package pkg in data.select_provider_providers) {
providers_str += pkg.name;
}
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) {
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 ();
break;
case Question.CORRUPTED_PKG:
case Question.Type.CORRUPTED_PKG:
// Auto-remove corrupted pkgs in cache
response = 1;
data.corrupted_remove = 1;
break;
case Question.IMPORT_KEY:
PGPKey *key = data1;
case Question.Type.IMPORT_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
else response = 1;
else
data.import_key_import = 1;
break;
default:
response = 0;
data.any_answer = 0;
break;
}
}
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) {
pamac_daemon.previous_percent = (uint64) percent;
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 () {
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);
}
@ -214,9 +214,9 @@ namespace Pamac {
TreeSelection selection;
selection = repos_treeview.get_selection ();
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);
foreach (unowned Group grp in db.groupcache) {
foreach (var grp in db.groupcache) {
if ((grp.name in grps) == false) {
grps += grp.name;
}
@ -266,7 +266,7 @@ namespace Pamac {
licenses.append (dgettext (null, "Licenses"));
licenses.append (":");
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 (license);
}
@ -299,7 +299,7 @@ namespace Pamac {
if (len != 0) {
unowned Depend optdep = list.nth_data (0);
unowned Alpm.Package? satisfier = find_satisfier (
transaction.handle.localdb.pkgcache,
transaction.alpm_config.handle.localdb.pkgcache,
optdep.name);
string optdep_str = optdep.compute_string ();
if (satisfier != null)
@ -311,7 +311,7 @@ namespace Pamac {
while (i < len) {
optdep = list.nth_data (i);
satisfier = find_satisfier (
transaction.handle.localdb.pkgcache,
transaction.alpm_config.handle.localdb.pkgcache,
optdep.name);
optdep_str = optdep.compute_string ();
if (satisfier != null)
@ -320,20 +320,21 @@ namespace Pamac {
i++;
}
}
if (pkg.origin == PkgFrom.LOCALDB) {
Alpm.List<string?> str_list = pkg.compute_requiredby ();
len = str_list.length;
if (pkg.origin == Alpm.Package.From.LOCALDB) {
Alpm.List<string?> *str_list = pkg.compute_requiredby ();
len = str_list->length;
if (len != 0) {
deps_list.insert_with_values (out iter, -1,
0, dgettext (null, "Required By") + ":",
1, str_list.nth_data (0));
1, str_list->nth_data (0));
i = 1;
while (i < len) {
deps_list.insert_with_values (out iter, -1,
1, str_list.nth_data (i));
1, str_list->nth_data (i));
i++;
}
}
Alpm.List.free_all (str_list);
}
list = pkg.provides;
len = list.length;
@ -379,7 +380,7 @@ namespace Pamac {
public void set_details_list (Alpm.Package pkg) {
details_list.clear ();
TreeIter iter;
if (pkg.origin == PkgFrom.SYNCDB) {
if (pkg.origin == Alpm.Package.From.SYNCDB) {
details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Repository") + ":",
1, pkg.db.name);
@ -401,16 +402,16 @@ namespace Pamac {
details_list.insert_with_values (out iter, -1,
0, dgettext (null, "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);
string strtime = time.format ("%a %d %b %Y %X %Z");
details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Install Date") + ":",
1, strtime);
string reason;
if (pkg.reason == PkgReason.EXPLICIT)
if (pkg.reason == Alpm.Package.Reason.EXPLICIT)
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");
else
reason = dgettext (null, "Unknown");
@ -418,12 +419,12 @@ namespace Pamac {
0, dgettext (null, "Install Reason") + ":",
1, reason);
}
if (pkg.origin == PkgFrom.SYNCDB) {
if (pkg.origin == Alpm.Package.From.SYNCDB) {
details_list.insert_with_values (out iter, -1,
0, dgettext (null, "Signatures") + ":",
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;
len = backup_list.length;
if (len != 0) {
@ -442,7 +443,7 @@ namespace Pamac {
public void set_files_list (Alpm.Package pkg) {
StringBuilder text = new StringBuilder ();
foreach (unowned Alpm.File file in pkg.files) {
foreach (var file in pkg.files) {
if (text.len != 0)
text.append ("\n");
text.append ("/");
@ -451,12 +452,12 @@ namespace Pamac {
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) {
unowned Alpm.List<string?> needles = null;
public async Alpm.List<Alpm.Package?> search_pkgs (string search_string, out Json.Array aur_pkgs) {
Alpm.List<string?> needles = null;
string[] splitted = search_string.split (" ");
foreach (unowned string part in splitted)
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 (aur_results.contains (search_string)) {
aur_pkgs = aur_results.get (search_string);
@ -531,7 +532,7 @@ namespace Pamac {
set_details_list (pkg.alpm_pkg);
deps_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);
files_scrolledwindow.visible = true;
} else {
@ -561,7 +562,7 @@ namespace Pamac {
packages_list.get_value (iter, 3, out val);
string db_name = val.get_string ();
if (db_name == "local") {
if ((name in transaction.holdpkg) == false) {
if ((name in transaction.alpm_config.holdpkg) == false) {
transaction.to_remove.insert (name, name);
}
} else if (db_name == "AUR") {
@ -587,7 +588,7 @@ namespace Pamac {
if (pkg.repo == "AUR")
transaction.to_build.insert (pkg.name, pkg.name);
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)
transaction.to_add.insert (pkg.name, pkg.name);
}
@ -608,7 +609,7 @@ namespace Pamac {
void on_remove_item_activate () {
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")
transaction.to_remove.insert (pkg.name, pkg.name);
}
@ -637,8 +638,8 @@ namespace Pamac {
foreach (Pamac.Package pkg in pkgs) {
var choose_dep_dialog = new ChooseDependenciesDialog (this);
nb = 0;
foreach (unowned Depend opt_dep in pkg.alpm_pkg.optdepends) {
found = find_satisfier (transaction.handle.localdb.pkgcache, opt_dep.compute_string ());
foreach (var opt_dep in pkg.alpm_pkg.optdepends) {
found = find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, opt_dep.compute_string ());
if (found == null) {
choose_dep_dialog.deps_list.insert_with_values (out iter, -1,
0, false,
@ -678,9 +679,8 @@ namespace Pamac {
void on_explicitly_installed_item_activate () {
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 ();
}
@ -743,17 +743,17 @@ namespace Pamac {
if (optdepends.length != 0) {
uint nb = 0;
unowned Alpm.Package? found;
foreach (unowned Depend opt_dep in optdepends) {
found = find_satisfier (transaction.handle.localdb.pkgcache, opt_dep.compute_string ());
foreach (var opt_dep in optdepends) {
found = find_satisfier (transaction.alpm_config.handle.localdb.pkgcache, opt_dep.compute_string ());
if (found == null)
nb += 1;
}
if (nb != 0)
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);
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 (pkg_vercmp (find_pkg.version, clicked_pkg.version) == 0)
reinstall_item.set_sensitive (true);
@ -855,7 +855,7 @@ namespace Pamac {
Gtk.main_iteration ();
search_pkgs.begin (search_string, (obj, res) => {
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) {
// add search string in search_list if needed
bool found = false;
@ -922,7 +922,7 @@ namespace Pamac {
string search_string = val.get_string ();
search_pkgs.begin (search_string, (obj, res) => {
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);
});
}
@ -940,7 +940,7 @@ namespace Pamac {
GLib.Value val;
model.get_value (iter, 0, out val);
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);
}
}
@ -957,29 +957,29 @@ namespace Pamac {
GLib.Value val;
model.get_value (iter, 0, out val);
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;
if (state == dgettext (null, "To install")) {
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)
pkgs.add (find_pkg);
else {
find_pkg = get_syncpkg (transaction.handle, name);
find_pkg = get_syncpkg (transaction.alpm_config.handle, name);
if (find_pkg != null)
pkgs.add (find_pkg);
}
}
} else if (state == dgettext (null, "To remove")) {
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)
pkgs.add (find_pkg);
}
} 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")) {
foreach (unowned DB db in transaction.handle.syncdbs) {
foreach (var db in transaction.alpm_config.handle.syncdbs) {
if (pkgs.length == 0)
pkgs = db.pkgcache.copy ();
else {
@ -987,8 +987,8 @@ namespace Pamac {
}
}
} else if (state == dgettext (null, "Orphans")) {
foreach (unowned Alpm.Package pkg in transaction.handle.localdb.pkgcache) {
if (pkg.reason == PkgReason.DEPEND) {
foreach (var pkg in transaction.alpm_config.handle.localdb.pkgcache) {
if (pkg.reason == Alpm.Package.Reason.DEPEND) {
if (pkg.compute_requiredby().length == 0)
pkgs.add (pkg);
}
@ -1010,19 +1010,19 @@ namespace Pamac {
GLib.Value val;
model.get_value (iter, 0, out val);
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;
if (repo == dgettext (null, "local")) {
foreach (unowned Alpm.Package pkg in transaction.handle.localdb.pkgcache) {
find_pkg = get_syncpkg (transaction.handle, pkg.name);
foreach (var pkg in transaction.alpm_config.handle.localdb.pkgcache) {
find_pkg = get_syncpkg (transaction.alpm_config.handle, pkg.name);
if (find_pkg == null)
pkgs.add (pkg);
}
} else {
foreach (unowned DB db in transaction.handle.syncdbs) {
foreach (var db in transaction.alpm_config.handle.syncdbs) {
if (db.name == repo) {
foreach (unowned Alpm.Package pkg in db.pkgcache) {
find_pkg = transaction.handle.localdb.get_pkg (pkg.name);
foreach (var pkg in db.pkgcache) {
find_pkg = transaction.alpm_config.handle.localdb.get_pkg (pkg.name);
if (find_pkg != null)
pkgs.add (find_pkg);
else

View File

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

View File

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

View File

@ -41,7 +41,7 @@ namespace Pamac {
public abstract void trans_cancel () throws IOError;
[DBus (no_reply = true)]
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_progress (uint progress, string pkgname, int percent, uint n_targets, uint current_target);
public signal void emit_download (string filename, uint64 xfered, uint64 total);
@ -55,10 +55,7 @@ namespace Pamac {
public class Transaction: Object {
public Daemon daemon;
public string[] syncfirst;
public string[] holdpkg;
public string[] ignorepkg;
public Handle handle;
public Alpm.Config alpm_config;
public Alpm.TransFlag flags;
// those hashtables will be used as set
@ -97,7 +94,7 @@ namespace Pamac {
public signal void finished (bool error);
public Transaction (ApplicationWindow? window) {
refresh_alpm_config ();
alpm_config = new Alpm.Config ("/etc/pacman.conf");
mode = Mode.MANAGER;
flags = Alpm.TransFlag.CASCADE;
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 {
daemon.set_pkgreason (pkgname, (uint) reason);
refresh_alpm_config ();
refresh_handle ();
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
}
}
public void refresh_alpm_config () {
var alpm_config = new Alpm.Config ("/etc/pacman.conf");
syncfirst = alpm_config.get_syncfirst ();
holdpkg = alpm_config.get_holdpkg ();
ignorepkg = alpm_config.get_ignore_pkgs ();
handle = alpm_config.get_handle ();
public void refresh_handle () {
alpm_config.get_handle ();
}
public void refresh (int force) {
@ -239,7 +232,7 @@ namespace Pamac {
Gtk.main_iteration ();
// sysupgrade
// 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) {
clear_lists ();
if (mode == Mode.MANAGER)
@ -249,11 +242,11 @@ namespace Pamac {
// run as a standard transaction
run ();
} 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;
if (check_aur) {
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;
}
if (aur_updates.length != 0) {
@ -394,7 +387,7 @@ namespace Pamac {
}
foreach (UpdatesInfos pkg_info in prepared_to_add) {
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) {
to_install += "%s %s".printf (pkg_info.name, pkg_info.version);
} else {
@ -569,137 +562,160 @@ namespace Pamac {
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;
switch (event) {
case Event.CHECKDEPS_START:
switch (primary_event) {
case Event.Type.CHECKDEPS_START:
msg = dgettext (null, "Checking dependencies") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.FILECONFLICTS_START:
case Event.Type.FILECONFLICTS_START:
msg = dgettext (null, "Checking file conflicts") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.RESOLVEDEPS_START:
case Event.Type.RESOLVEDEPS_START:
msg = dgettext (null, "Resolving dependencies") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.INTERCONFLICTS_START:
case Event.Type.INTERCONFLICTS_START:
msg = dgettext (null, "Checking inter-conflicts") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.ADD_START:
progress_dialog.cancel_button.set_visible (false);
previous_filename = details[0];
msg = dgettext (null, "Installing %s").printf (details[0]) + "...";
progress_dialog.action_label.set_text (msg);
msg = dgettext (null, "Installing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
spawn_in_term ({"/usr/bin/echo", msg});
case Event.Type.PACKAGE_OPERATION_START:
switch (secondary_event) {
case Alpm.Package.Operation.INSTALL:
progress_dialog.cancel_button.set_visible (false);
previous_filename = details[0];
msg = dgettext (null, "Installing %s").printf (details[0]) + "...";
progress_dialog.action_label.set_text (msg);
msg = dgettext (null, "Installing %s").printf ("%s (%s)".printf (details[0], details[1]))+ "...";
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;
case Event.REINSTALL_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:
case Event.Type.INTEGRITY_START:
msg = dgettext (null, "Checking integrity") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.KEYRING_START:
case Event.Type.KEYRING_START:
progress_dialog.cancel_button.set_visible (true);
msg = dgettext (null, "Checking keyring") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.KEY_DOWNLOAD_START:
case Event.Type.KEY_DOWNLOAD_START:
msg = dgettext (null, "Downloading required keys") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.LOAD_START:
case Event.Type.LOAD_START:
msg = dgettext (null, "Loading packages files") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DELTA_INTEGRITY_START:
case Event.Type.DELTA_INTEGRITY_START:
msg = dgettext (null, "Checking delta integrity") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DELTA_PATCHES_START:
case Event.Type.DELTA_PATCHES_START:
msg = dgettext (null, "Applying deltas") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DELTA_PATCH_START:
case Event.Type.DELTA_PATCH_START:
msg = dgettext (null, "Generating %s with %s").printf (details[0], details[1]) + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DELTA_PATCH_DONE:
case Event.Type.DELTA_PATCH_DONE:
msg = dgettext (null, "Generation succeeded") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
break;
case Event.DELTA_PATCH_FAILED:
case Event.Type.DELTA_PATCH_FAILED:
msg = dgettext (null, "Generation failed") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
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.expander.set_expanded (true);
spawn_in_term ({"/usr/bin/echo", "-n", details[0]});
break;
case Event.RETRIEVE_START:
case Event.Type.RETRIEVE_START:
progress_dialog.cancel_button.set_visible (true);
msg = dgettext (null, "Downloading") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
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") + "...";
progress_dialog.action_label.set_text (msg);
spawn_in_term ({"/usr/bin/echo", msg});
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])});
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])});
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:
break;
}
@ -744,22 +760,22 @@ namespace Pamac {
}
void on_emit_download (string filename, uint64 xfered, uint64 total) {
string label;
//~ string label;
string textbar;
double fraction;
if (filename != previous_filename) {
previous_filename = filename;
if (filename.has_suffix (".db")) {
label = dgettext (null, "Refreshing %s").printf (filename.replace (".db", "")) + "...";
} else {
label = dgettext (null, "Downloading %s").printf (filename.replace (".pkg.tar.xz", "")) + "...";
}
if (label != previous_label) {
previous_label = label;
progress_dialog.action_label.set_text (label);
spawn_in_term ({"/usr/bin/echo", label});
}
}
//~ if (filename != previous_filename) {
//~ previous_filename = filename;
//~ if (filename.has_suffix (".db")) {
//~ label = dgettext (null, "Refreshing %s").printf (filename.replace (".db", "")) + "...";
//~ } else {
//~ label = dgettext (null, "Downloading %s").printf (filename.replace (".pkg.tar.xz", "")) + "...";
//~ }
//~ if (label != previous_label) {
//~ previous_label = label;
//~ progress_dialog.action_label.set_text (label);
//~ spawn_in_term ({"/usr/bin/echo", label});
//~ }
//~ }
if (total_download > 0) {
fraction = (float) (xfered + already_downloaded) / total_download;
if (fraction > 0)
@ -871,7 +887,7 @@ namespace Pamac {
public void on_emit_refreshed (ErrorInfos error) {
print ("transaction refreshed\n");
refresh_alpm_config ();
refresh_handle ();
if (error.str == "") {
if (mode == Mode.UPDATER) {
progress_dialog.hide ();
@ -975,7 +991,7 @@ namespace Pamac {
//progress_dialog.close_button.set_visible (true);
clear_lists ();
show_warnings ();
refresh_alpm_config ();
refresh_handle ();
if (sysupgrade_after_trans) {
sysupgrade_after_trans = false;
sysupgrade (0);
@ -993,7 +1009,7 @@ namespace Pamac {
}
}
} else {
refresh_alpm_config ();
refresh_handle ();
finished (true);
handle_error (error);
}

View File

@ -131,7 +131,7 @@ namespace Pamac {
top_label.set_markup ("");
updates_list.clear ();
// 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) {
updates_nb = syncfirst_updates.length;
foreach (UpdatesInfos infos in syncfirst_updates) {
@ -146,7 +146,7 @@ namespace Pamac {
} else {
while (Gtk.events_pending ())
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) {
name = infos.name + " " + infos.version;
if (infos.download_size != 0)
@ -158,7 +158,7 @@ namespace Pamac {
}
updates_nb += updates.length;
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;
foreach (UpdatesInfos infos in aur_updates) {
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;
}
void alpm_list_free_all(alpm_list_t *list) {
do { alpm_list_free_inner(list, free); alpm_list_free(list); list = NULL; } while(0);
alpm_list_t *alpm_list_new () {
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;
}
void* alpm_list_iterator_next_value (alpm_list_iterator_t *iter) {
if (iter->pos) {
void* result = alpm_list_get_data(iter->pos);
iter->pos = alpm_list_next(iter->pos);
void* result = alpm_list_get_data (iter->pos);
iter->pos = alpm_list_next (iter->pos);
return result;
}
else return NULL;

View File

@ -7,15 +7,16 @@ typedef struct __alpm_list_iterator_t {
alpm_list_t* pos;
} 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);
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);
void alpm_list_free_all(alpm_list_t *list);
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_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_new ();
void alpm_list_free_all (alpm_list_t *list);
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);
#endif //!ALPM_VALA_H

File diff suppressed because it is too large Load Diff