update alpm bindings and menus
This commit is contained in:
24
src/Makefile
24
src/Makefile
@@ -6,6 +6,7 @@ COMMON_VALA_FLAGS = --pkg=libalpm \
|
||||
--vapidir=../vapi \
|
||||
--Xcc=-I../util \
|
||||
-X -D_FILE_OFFSET_BITS=64 \
|
||||
-X -DGETTEXT_PACKAGE="pamac" \
|
||||
--target-glib=2.38
|
||||
|
||||
COMMON_SOURCES = ../util/alpm-util.c \
|
||||
@@ -20,7 +21,7 @@ MANAGER_RESOURCES_FILES = ../resources/manager_window.ui \
|
||||
../resources/packages_chooser_dialog.ui \
|
||||
../resources/history_dialog.ui \
|
||||
../resources/preferences_dialog.ui \
|
||||
../resources/progress_window.ui \
|
||||
../resources/progress_dialog.ui \
|
||||
../resources/choose_provider_dialog.ui \
|
||||
../resources/transaction_sum_dialog.ui \
|
||||
../resources/transaction_info_dialog.ui \
|
||||
@@ -35,14 +36,14 @@ UPDATER_GRESOURCE_FILE = ../resources/pamac.updater.gresource.xml
|
||||
|
||||
UPDATER_RESOURCES_FILES = ../resources/updater_window.ui \
|
||||
../resources/preferences_dialog.ui \
|
||||
../resources/progress_window.ui \
|
||||
../resources/progress_dialog.ui \
|
||||
../resources/choose_provider_dialog.ui \
|
||||
../resources/transaction_sum_dialog.ui \
|
||||
../resources/transaction_info_dialog.ui
|
||||
|
||||
INSTALLER_GRESOURCE_FILE = ../resources/pamac.installer.gresource.xml
|
||||
|
||||
INSTALLER_RESOURCES_FILES = ../resources/progress_window.ui \
|
||||
INSTALLER_RESOURCES_FILES = ../resources/progress_dialog.ui \
|
||||
../resources/choose_provider_dialog.ui \
|
||||
../resources/transaction_sum_dialog.ui \
|
||||
../resources/transaction_info_dialog.ui
|
||||
@@ -50,23 +51,21 @@ INSTALLER_RESOURCES_FILES = ../resources/progress_window.ui \
|
||||
DIALOGS_FILES = choose_provider_dialog.vala \
|
||||
transaction_sum_dialog.vala \
|
||||
transaction_info_dialog.vala \
|
||||
progress_window.vala
|
||||
progress_dialog.vala
|
||||
|
||||
pamac-daemon: $(COMMON_SOURCES) daemon.vala
|
||||
pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi $(COMMON_SOURCES) daemon.vala
|
||||
valac -o pamac-daemon \
|
||||
$(COMMON_VALA_FLAGS) \
|
||||
--pkg=polkit-gobject-1 \
|
||||
-X -DGETTEXT_PACKAGE="pacman" \
|
||||
--thread \
|
||||
$(COMMON_SOURCES) \
|
||||
daemon.vala
|
||||
|
||||
pamac-tray: $(COMMON_SOURCES) tray.vala
|
||||
pamac-tray: ../vapi/libalpm.vapi $(COMMON_SOURCES) tray.vala
|
||||
valac -o pamac-tray \
|
||||
$(COMMON_VALA_FLAGS) \
|
||||
--pkg=gtk+-3.0 \
|
||||
--pkg=libnotify \
|
||||
-X -DGETTEXT_PACKAGE="pamac" \
|
||||
$(COMMON_SOURCES) \
|
||||
tray.vala
|
||||
|
||||
@@ -79,7 +78,7 @@ updater_resources.c: $(UPDATER_GRESOURCE_FILE) $(UPDATER_RESOURCES_FILES)
|
||||
installer_resources.c: $(INSTALLER_GRESOURCE_FILE) $(INSTALLER_RESOURCES_FILES)
|
||||
glib-compile-resources $(INSTALLER_GRESOURCE_FILE) --sourcedir=../resources --target=installer_resources.c --generate-source
|
||||
|
||||
pamac-manager: $(COMMON_SOURCES) $(DIALOGS_FILES) preferences_dialog.vala history_dialog.vala packages_chooser_dialog.vala manager_resources.c package.vala transaction.vala packages_model.vala manager_window.vala manager.vala
|
||||
pamac-manager: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) preferences_dialog.vala history_dialog.vala packages_chooser_dialog.vala manager_resources.c package.vala transaction.vala packages_model.vala manager_window.vala manager.vala
|
||||
valac -o pamac-manager \
|
||||
$(COMMON_VALA_FLAGS) \
|
||||
--pkg=gtk+-3.0 \
|
||||
@@ -87,7 +86,6 @@ pamac-manager: $(COMMON_SOURCES) $(DIALOGS_FILES) preferences_dialog.vala histor
|
||||
--pkg=gdk-3.0 \
|
||||
--pkg=vte-2.91 \
|
||||
--gresources=$(MANAGER_GRESOURCE_FILE) \
|
||||
-X -DGETTEXT_PACKAGE="pamac" \
|
||||
$(COMMON_SOURCES) \
|
||||
$(DIALOGS_FILES) \
|
||||
preferences_dialog.vala \
|
||||
@@ -100,14 +98,13 @@ pamac-manager: $(COMMON_SOURCES) $(DIALOGS_FILES) preferences_dialog.vala histor
|
||||
manager_window.vala \
|
||||
manager.vala
|
||||
|
||||
pamac-updater: $(COMMON_SOURCES) $(DIALOGS_FILES) preferences_dialog.vala updater_resources.c transaction.vala updater_window.vala updater.vala
|
||||
pamac-updater: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) preferences_dialog.vala updater_resources.c transaction.vala updater_window.vala updater.vala
|
||||
valac -o pamac-updater \
|
||||
$(COMMON_VALA_FLAGS) \
|
||||
--pkg=gtk+-3.0 \
|
||||
--pkg=gmodule-2.0 \
|
||||
--pkg=vte-2.91 \
|
||||
--gresources=$(UPDATER_GRESOURCE_FILE) \
|
||||
-X -DGETTEXT_PACKAGE="pamac" \
|
||||
$(COMMON_SOURCES) \
|
||||
$(DIALOGS_FILES) \
|
||||
preferences_dialog.vala \
|
||||
@@ -116,14 +113,13 @@ pamac-updater: $(COMMON_SOURCES) $(DIALOGS_FILES) preferences_dialog.vala update
|
||||
updater_window.vala \
|
||||
updater.vala
|
||||
|
||||
pamac-install: $(COMMON_SOURCES) $(DIALOGS_FILES) installer_resources.c transaction.vala installer.vala
|
||||
pamac-install: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(DIALOGS_FILES) installer_resources.c transaction.vala installer.vala
|
||||
valac -o pamac-install \
|
||||
$(COMMON_VALA_FLAGS) \
|
||||
--pkg=gtk+-3.0 \
|
||||
--pkg=gmodule-2.0 \
|
||||
--pkg=vte-2.91 \
|
||||
--gresources=$(INSTALLER_GRESOURCE_FILE) \
|
||||
-X -DGETTEXT_PACKAGE="pamac" \
|
||||
$(COMMON_SOURCES) \
|
||||
$(DIALOGS_FILES) \
|
||||
installer_resources.c \
|
||||
|
@@ -30,38 +30,103 @@ namespace Alpm {
|
||||
}
|
||||
|
||||
public class Config {
|
||||
public Handle handle;
|
||||
private string[] priv_holdpkg;
|
||||
private string[] priv_syncfirst;
|
||||
public string[] holdpkg;
|
||||
public string[] syncfirst;
|
||||
SigLevel siglevel;
|
||||
string rootdir;
|
||||
string dbpath;
|
||||
string gpgdir;
|
||||
string logfile;
|
||||
string arch;
|
||||
double deltaratio;
|
||||
int usesyslog;
|
||||
int checkspace;
|
||||
string[] cachedir;
|
||||
string[] ignoregroup;
|
||||
string[] ignorepkg;
|
||||
string[] noextract;
|
||||
string[] noupgrade;
|
||||
string[] holdpkg;
|
||||
string[] syncfirst;
|
||||
SigLevel defaultsiglevel;
|
||||
SigLevel localfilesiglevel;
|
||||
SigLevel remotefilesiglevel;
|
||||
Repo[] repo_order;
|
||||
|
||||
public Config (string path) {
|
||||
// rootdir and dbpath are hardcoded so we parse config file only once
|
||||
const string rootdir = "/";
|
||||
const string dbpath = "/var/lib/pacman";
|
||||
Alpm.Errno error;
|
||||
handle = new Handle (rootdir, dbpath, out error);
|
||||
const string gpgdir = "/etc/pacman.d/gnupg/";
|
||||
const string logfile = "/var/log/pacman.log";
|
||||
const string cachedir = "/var/cache/pacman/pkg/";
|
||||
priv_holdpkg = {};
|
||||
priv_syncfirst = {};
|
||||
siglevel = SigLevel.PACKAGE | SigLevel.PACKAGE_OPTIONAL | SigLevel.DATABASE | SigLevel.DATABASE_OPTIONAL;
|
||||
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 = {};
|
||||
ignoregroup = {};
|
||||
ignorepkg = {};
|
||||
noextract = {};
|
||||
noupgrade = {};
|
||||
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;
|
||||
repo_order = {};
|
||||
// parse conf file
|
||||
parse_file (path);
|
||||
// check essential settings
|
||||
if (handle.gpgdir == null) handle.gpgdir = gpgdir;
|
||||
if (handle.logfile == null) handle.logfile = logfile;
|
||||
if (handle.arch == null) handle.arch = Posix.utsname().machine;
|
||||
if (handle.cachedirs == null) handle.add_cachedir(cachedir);
|
||||
}
|
||||
|
||||
public string[] get_syncfirst () {
|
||||
return syncfirst;
|
||||
}
|
||||
|
||||
public string[] get_holdpkg () {
|
||||
return holdpkg;
|
||||
}
|
||||
|
||||
public string[] get_ignore_pkgs () {
|
||||
string[] ignore_pkgs = {};
|
||||
unowned Group? group = null;
|
||||
Handle? handle = this.get_handle ();
|
||||
if (handle != null) {
|
||||
foreach (string name in ignorepkg)
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ignore_pkgs;
|
||||
}
|
||||
|
||||
public Handle? get_handle () {
|
||||
Alpm.Errno error;
|
||||
Handle? handle = new Handle (rootdir, dbpath, out error);
|
||||
if (handle == null) {
|
||||
stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf(Alpm.strerror (error)));
|
||||
return handle;
|
||||
}
|
||||
// define options
|
||||
handle.gpgdir = gpgdir;
|
||||
handle.logfile = logfile;
|
||||
handle.arch = arch;
|
||||
handle.deltaratio = deltaratio;
|
||||
handle.usesyslog = usesyslog;
|
||||
handle.checkspace = checkspace;
|
||||
handle.defaultsiglevel = defaultsiglevel;
|
||||
handle.localfilesiglevel = localfilesiglevel;
|
||||
handle.remotefilesiglevel = remotefilesiglevel;
|
||||
foreach (string dir in cachedir)
|
||||
handle.add_cachedir (dir);
|
||||
foreach (string name in ignoregroup)
|
||||
handle.add_ignoregroup (name);
|
||||
foreach (string name in ignorepkg)
|
||||
handle.add_ignorepkg (name);
|
||||
foreach (string name in noextract)
|
||||
handle.add_noextract (name);
|
||||
foreach (string name in noupgrade)
|
||||
handle.add_noupgrade (name);
|
||||
// register dbs
|
||||
foreach (Repo repo in repo_order) {
|
||||
unowned DB db = handle.register_syncdb (repo.name, repo.siglevel);
|
||||
@@ -69,6 +134,7 @@ namespace Alpm {
|
||||
db.add_server (url.replace ("$repo", repo.name).replace ("$arch", handle.arch));
|
||||
}
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
public void parse_file (string path, string? section = null) {
|
||||
@@ -91,7 +157,7 @@ namespace Alpm {
|
||||
current_section = line[1:-1];
|
||||
if (current_section != "options") {
|
||||
Repo repo = new Repo (current_section);
|
||||
repo.siglevel = siglevel;
|
||||
repo.siglevel = defaultsiglevel;
|
||||
repo_order += repo;
|
||||
}
|
||||
continue;
|
||||
@@ -105,53 +171,53 @@ namespace Alpm {
|
||||
parse_file (_value, current_section);
|
||||
if (current_section == "options") {
|
||||
if (_key == "GPGDir")
|
||||
handle.gpgdir = _value;
|
||||
gpgdir = _value;
|
||||
else if (_key == "LogFile")
|
||||
handle.logfile = _value;
|
||||
logfile = _value;
|
||||
else if (_key == "Architecture") {
|
||||
if (_value == "auto")
|
||||
handle.arch = Posix.utsname ().machine;
|
||||
arch = Posix.utsname ().machine;
|
||||
else
|
||||
handle.arch = _value;
|
||||
arch = _value;
|
||||
} else if (_key == "UseDelta")
|
||||
handle.deltaratio = double.parse (_value);
|
||||
deltaratio = double.parse (_value);
|
||||
else if (_key == "UseSysLog")
|
||||
handle.usesyslog = 1;
|
||||
usesyslog = 1;
|
||||
else if (_key == "CheckSpace")
|
||||
handle.checkspace = 1;
|
||||
checkspace = 1;
|
||||
else if (_key == "SigLevel")
|
||||
siglevel = define_siglevel (siglevel, _value);
|
||||
defaultsiglevel = define_siglevel (defaultsiglevel, _value);
|
||||
else if (_key == "LocalSigLevel")
|
||||
handle.localfilesiglevel = merge_siglevel (siglevel, define_siglevel (localfilesiglevel, _value));
|
||||
localfilesiglevel = merge_siglevel (defaultsiglevel, define_siglevel (localfilesiglevel, _value));
|
||||
else if (_key == "RemoteSigLevel")
|
||||
handle.remotefilesiglevel = merge_siglevel (siglevel, define_siglevel (remotefilesiglevel, _value));
|
||||
remotefilesiglevel = merge_siglevel (defaultsiglevel, define_siglevel (remotefilesiglevel, _value));
|
||||
else if (_key == "HoldPkg") {
|
||||
foreach (string name in _value.split (" ")) {
|
||||
priv_holdpkg += name;
|
||||
holdpkg += name;
|
||||
}
|
||||
} else if (_key == "SyncFirst") {
|
||||
foreach (string name in _value.split (" ")) {
|
||||
priv_syncfirst += name;
|
||||
syncfirst += name;
|
||||
}
|
||||
} else if (_key == "CacheDir") {
|
||||
foreach (string dir in _value.split (" ")) {
|
||||
handle.add_cachedir (dir);
|
||||
cachedir += dir;
|
||||
}
|
||||
} else if (_key == "IgnoreGroup") {
|
||||
foreach (string name in _value.split (" ")) {
|
||||
handle.add_ignoregroup (name);
|
||||
ignoregroup += name;
|
||||
}
|
||||
} else if (_key == "IgnorePkg") {
|
||||
foreach (string name in _value.split (" ")) {
|
||||
handle.add_ignorepkg (name);
|
||||
ignorepkg += name;
|
||||
}
|
||||
} else if (_key == "Noextract") {
|
||||
foreach (string name in _value.split (" ")) {
|
||||
handle.add_noextract (name);
|
||||
noextract += name;
|
||||
}
|
||||
} else if (_key == "NoUpgrade") {
|
||||
foreach (string name in _value.split (" ")) {
|
||||
handle.add_noupgrade (name);
|
||||
noupgrade += name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -160,7 +226,7 @@ namespace Alpm {
|
||||
if (_key == "Server")
|
||||
_repo.urls += _value;
|
||||
else if (_key == "SigLevel")
|
||||
_repo.siglevel = define_siglevel(siglevel, _value);
|
||||
_repo.siglevel = define_siglevel (defaultsiglevel, _value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,8 +234,6 @@ namespace Alpm {
|
||||
} catch (GLib.Error e) {
|
||||
GLib.stderr.printf("%s\n", e.message);
|
||||
}
|
||||
holdpkg = priv_holdpkg;
|
||||
syncfirst = priv_syncfirst;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -26,25 +26,11 @@ namespace Pamac {
|
||||
public uint64 download_size;
|
||||
}
|
||||
|
||||
public struct Updates {
|
||||
public bool syncfirst;
|
||||
public UpdatesInfos[] infos;
|
||||
}
|
||||
|
||||
public enum Mode {
|
||||
MANAGER,
|
||||
UPDATER,
|
||||
NO_CONFIRM
|
||||
}
|
||||
|
||||
public struct TransactionData {
|
||||
public Alpm.TransFlag flags;
|
||||
// those hashtables will be used as set
|
||||
public HashTable<string, string> to_add;
|
||||
public HashTable<string, string> to_remove;
|
||||
public HashTable<string, string> to_load;
|
||||
public HashTable<string, string> to_build;
|
||||
}
|
||||
|
||||
public struct ErrorInfos {
|
||||
public string str;
|
||||
@@ -159,15 +145,15 @@ public unowned Alpm.Package? get_syncpkg (Alpm.Handle handle, string name) {
|
||||
return pkg;
|
||||
}
|
||||
|
||||
public Pamac.UpdatesInfos[] get_syncfirst_updates (Alpm.Config alpm_config) {
|
||||
public Pamac.UpdatesInfos[] get_syncfirst_updates (Alpm.Handle handle, string[] syncfirst) {
|
||||
Pamac.UpdatesInfos infos = Pamac.UpdatesInfos ();
|
||||
Pamac.UpdatesInfos[] syncfirst_infos = {};
|
||||
unowned Alpm.Package? pkg = null;
|
||||
unowned Alpm.Package? candidate = null;
|
||||
foreach (string name in alpm_config.syncfirst) {
|
||||
pkg = Alpm.find_satisfier (alpm_config.handle.localdb.pkgcache, name);
|
||||
foreach (string name in syncfirst) {
|
||||
pkg = Alpm.find_satisfier (handle.localdb.pkgcache, name);
|
||||
if (pkg != null) {
|
||||
candidate = Alpm.sync_newversion (pkg, alpm_config.handle.syncdbs);
|
||||
candidate = Alpm.sync_newversion (pkg, handle.syncdbs);
|
||||
if (candidate != null) {
|
||||
infos.name = candidate.name;
|
||||
infos.version = candidate.version;
|
||||
@@ -181,29 +167,14 @@ public Pamac.UpdatesInfos[] get_syncfirst_updates (Alpm.Config alpm_config) {
|
||||
return syncfirst_infos;
|
||||
}
|
||||
|
||||
public string[] get_ignore_pkgs (Alpm.Config alpm_config) {
|
||||
string[] ignore_pkgs = {};
|
||||
unowned Alpm.Group? group = null;
|
||||
foreach (string name in alpm_config.handle.ignorepkgs)
|
||||
ignore_pkgs += name;
|
||||
foreach (string grp_name in alpm_config.handle.ignoregroups) {
|
||||
group = alpm_config.handle.localdb.get_group (grp_name);
|
||||
if (group != null) {
|
||||
foreach (unowned Alpm.Package found_pkg in group.packages)
|
||||
ignore_pkgs += found_pkg.name;
|
||||
}
|
||||
}
|
||||
return ignore_pkgs;
|
||||
}
|
||||
|
||||
public Pamac.UpdatesInfos[] get_repos_updates (Alpm.Config alpm_config, string[] ignore_pkgs) {
|
||||
public Pamac.UpdatesInfos[] get_repos_updates (Alpm.Handle handle, string[] ignore_pkgs) {
|
||||
unowned Alpm.Package? candidate = null;
|
||||
Pamac.UpdatesInfos infos = Pamac.UpdatesInfos ();
|
||||
Pamac.UpdatesInfos[] updates = {};
|
||||
foreach (unowned Alpm.Package local_pkg in alpm_config.handle.localdb.pkgcache) {
|
||||
foreach (unowned Alpm.Package 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, alpm_config.handle.syncdbs);
|
||||
candidate = Alpm.sync_newversion (local_pkg, handle.syncdbs);
|
||||
if (candidate != null) {
|
||||
infos.name = candidate.name;
|
||||
infos.version = candidate.version;
|
||||
@@ -217,25 +188,25 @@ public Pamac.UpdatesInfos[] get_repos_updates (Alpm.Config alpm_config, string[]
|
||||
return updates;
|
||||
}
|
||||
|
||||
public Pamac.UpdatesInfos[] get_aur_updates (Alpm.Config alpm_config, string[] ignore_pkgs) {
|
||||
public Pamac.UpdatesInfos[] get_aur_updates (Alpm.Handle handle, string[] ignore_pkgs) {
|
||||
unowned Alpm.Package? sync_pkg = null;
|
||||
unowned Alpm.Package? candidate = null;
|
||||
string[] local_pkgs = {};
|
||||
Pamac.UpdatesInfos infos = Pamac.UpdatesInfos ();
|
||||
Pamac.UpdatesInfos[] aur_updates = {};
|
||||
// get local pkgs
|
||||
foreach (unowned Alpm.Package local_pkg in alpm_config.handle.localdb.pkgcache) {
|
||||
foreach (unowned Alpm.Package 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 alpm_config.handle.syncdbs) {
|
||||
foreach (unowned Alpm.DB 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, alpm_config.handle.syncdbs);
|
||||
candidate = Alpm.sync_newversion (local_pkg, handle.syncdbs);
|
||||
if (candidate == null) {
|
||||
local_pkgs += local_pkg.name;
|
||||
}
|
||||
@@ -251,7 +222,7 @@ public Pamac.UpdatesInfos[] get_aur_updates (Alpm.Config alpm_config, string[] i
|
||||
unowned Json.Object pkg_info = node.get_object ();
|
||||
version = pkg_info.get_string_member ("Version");
|
||||
name = pkg_info.get_string_member ("Name");
|
||||
cmp = Alpm.pkg_vercmp (version, alpm_config.handle.localdb.get_pkg (name).version);
|
||||
cmp = Alpm.pkg_vercmp (version, handle.localdb.get_pkg (name).version);
|
||||
if (cmp == 1) {
|
||||
infos.name = name;
|
||||
infos.version = version;
|
||||
|
815
src/daemon.vala
815
src/daemon.vala
@@ -18,211 +18,184 @@
|
||||
*/
|
||||
|
||||
using Alpm;
|
||||
using Pamac;
|
||||
using Polkit;
|
||||
|
||||
// i18n
|
||||
const string GETTEXT_PACKAGE = "pamac";
|
||||
|
||||
PamacServer server;
|
||||
Pamac.Daemon pamac_daemon;
|
||||
MainLoop loop;
|
||||
|
||||
[DBus (name = "org.manjaro.pamac")]
|
||||
public class PamacServer : Object {
|
||||
Alpm.Config alpm_config;
|
||||
Pamac.Config pamac_config;
|
||||
unowned Alpm.DB localdb;
|
||||
unowned Alpm.List<DB?> syncdbs;
|
||||
public uint64 previous_percent;
|
||||
unowned Alpm.List<string?> local_packages;
|
||||
int force_refresh;
|
||||
bool emit_refreshed_signal;
|
||||
public Cond provider_cond;
|
||||
public Mutex provider_mutex;
|
||||
public int? choosen_provider;
|
||||
namespace Pamac {
|
||||
[DBus (name = "org.manjaro.pamac")]
|
||||
public class Daemon : Object {
|
||||
string[] syncfirst;
|
||||
string[] holdpkg;
|
||||
string[] ignorepkg;
|
||||
Handle? handle;
|
||||
public uint64 previous_percent;
|
||||
int force_refresh;
|
||||
bool emit_refreshed_signal;
|
||||
public Cond provider_cond;
|
||||
public Mutex provider_mutex;
|
||||
public int? choosen_provider;
|
||||
|
||||
public signal void emit_event (uint 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);
|
||||
public signal void emit_totaldownload (uint64 total);
|
||||
public signal void emit_log (uint level, string msg);
|
||||
public signal void emit_updates (Updates updates);
|
||||
public signal void emit_refreshed (ErrorInfos error);
|
||||
public signal void emit_trans_prepared (ErrorInfos error);
|
||||
public signal void emit_trans_committed (ErrorInfos error);
|
||||
public signal void emit_event (uint 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);
|
||||
public signal void emit_totaldownload (uint64 total);
|
||||
public signal void emit_log (uint level, string msg);
|
||||
public signal void emit_refreshed (ErrorInfos error);
|
||||
public signal void emit_trans_prepared (ErrorInfos error);
|
||||
public signal void emit_trans_committed (ErrorInfos error);
|
||||
|
||||
public PamacServer () {
|
||||
previous_percent = 0;
|
||||
local_packages = null;
|
||||
get_handle ();
|
||||
force_refresh = 0;
|
||||
emit_refreshed_signal = true;
|
||||
}
|
||||
|
||||
private void get_handle () {
|
||||
alpm_config = new Alpm.Config ("/etc/pacman.conf");
|
||||
pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
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;
|
||||
localdb = alpm_config.handle.localdb;
|
||||
syncdbs = alpm_config.handle.syncdbs;
|
||||
}
|
||||
|
||||
public void write_config (HashTable<string,string> new_conf, GLib.BusName sender) {
|
||||
try {
|
||||
Polkit.Authority authority = Polkit.Authority.get_sync (null);
|
||||
Polkit.Subject subject = Polkit.SystemBusName.new (sender);
|
||||
Polkit.AuthorizationResult result = authority.check_authorization_sync
|
||||
(subject,
|
||||
"org.manjaro.pamac.commit",
|
||||
null,
|
||||
Polkit.CheckAuthorizationFlags.ALLOW_USER_INTERACTION,
|
||||
null);
|
||||
if (result.get_is_authorized ()) {
|
||||
pamac_config.write (new_conf);
|
||||
}
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
public Daemon () {
|
||||
}
|
||||
}
|
||||
|
||||
public void refresh_alpm_config () {
|
||||
get_handle ();
|
||||
}
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
previous_percent = 0;
|
||||
}
|
||||
|
||||
private void refresh_real () {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
uint success = 0;
|
||||
int ret = alpm_config.handle.trans_init (0);
|
||||
if (ret == 0) {
|
||||
foreach (unowned DB db in syncdbs) {
|
||||
ret = db.update (force_refresh);
|
||||
if (ret >= 0) {
|
||||
success++;
|
||||
public void write_config (HashTable<string,string> new_conf, GLib.BusName sender) {
|
||||
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
try {
|
||||
Polkit.Authority authority = Polkit.Authority.get_sync (null);
|
||||
Polkit.Subject subject = Polkit.SystemBusName.new (sender);
|
||||
Polkit.AuthorizationResult result = authority.check_authorization_sync
|
||||
(subject,
|
||||
"org.manjaro.pamac.commit",
|
||||
null,
|
||||
Polkit.CheckAuthorizationFlags.ALLOW_USER_INTERACTION,
|
||||
null);
|
||||
if (result.get_is_authorized ()) {
|
||||
pamac_config.write (new_conf);
|
||||
}
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
// We should always succeed if at least one DB was upgraded - we may possibly
|
||||
// fail later with unresolved deps, but that should be rare, and would be expected
|
||||
if (success == 0) {
|
||||
}
|
||||
|
||||
private int refresh_real () {
|
||||
init_alpm_config ();
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
int success = 0;
|
||||
int ret = handle.trans_init (0);
|
||||
if (ret == 0) {
|
||||
foreach (var db in handle.syncdbs) {
|
||||
ret = db.update (force_refresh);
|
||||
if (ret >= 0) {
|
||||
success++;
|
||||
}
|
||||
}
|
||||
// We should always succeed if at least one DB was upgraded - we may possibly
|
||||
// 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 ());
|
||||
err.details = details;
|
||||
}
|
||||
trans_release ();
|
||||
} else {
|
||||
err.str = _("Failed to synchronize any databases");
|
||||
details += Alpm.strerror (alpm_config.handle.errno ());
|
||||
details += Alpm.strerror (handle.errno ());
|
||||
err.details = details;
|
||||
}
|
||||
trans_release ();
|
||||
get_handle ();
|
||||
} else {
|
||||
err.str = _("Failed to synchronize any databases");
|
||||
details += Alpm.strerror (alpm_config.handle.errno ());
|
||||
err.details = details;
|
||||
if (emit_refreshed_signal)
|
||||
emit_refreshed (err);
|
||||
return success;
|
||||
}
|
||||
if (emit_refreshed_signal)
|
||||
emit_refreshed (err);
|
||||
else
|
||||
emit_refreshed_signal = true;
|
||||
}
|
||||
|
||||
public async void refresh (int force, bool emit_signal) {
|
||||
force_refresh = force;
|
||||
emit_refreshed_signal = emit_signal;
|
||||
try {
|
||||
new Thread<void*>.try ("refresh thread", (ThreadFunc) refresh_real);
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
public UpdatesInfos[] get_updates () {
|
||||
UpdatesInfos[] updates = {};
|
||||
updates = get_syncfirst_updates (alpm_config);
|
||||
if (updates.length != 0) {
|
||||
return updates;
|
||||
} else {
|
||||
string[] ignore_pkgs = get_ignore_pkgs (alpm_config);
|
||||
updates = get_repos_updates (alpm_config, ignore_pkgs);
|
||||
if (pamac_config.enable_aur) {
|
||||
UpdatesInfos[] aur_updates = get_aur_updates (alpm_config, ignore_pkgs);
|
||||
foreach (UpdatesInfos infos in aur_updates)
|
||||
updates += infos;
|
||||
}
|
||||
return updates;
|
||||
}
|
||||
}
|
||||
|
||||
public ErrorInfos trans_init (TransFlag transflags) {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
int ret = alpm_config.handle.trans_init (transflags);
|
||||
if (ret == -1) {
|
||||
err.str = _("Failed to init transaction");
|
||||
details += Alpm.strerror (alpm_config.handle.errno ());
|
||||
err.details = details;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
public ErrorInfos trans_sysupgrade (int enable_downgrade) {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
int ret = alpm_config.handle.trans_sysupgrade (enable_downgrade);
|
||||
if (ret == -1) {;
|
||||
err.str = _("Failed to prepare transaction");
|
||||
details += Alpm.strerror (alpm_config.handle.errno ());
|
||||
err.details = details;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
public ErrorInfos trans_add_pkg (string pkgname) {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
unowned Package? pkg = null;
|
||||
//pkg = alpm_config.handle.find_dbs_satisfier (syncdbs, pkgname);
|
||||
foreach (var db in syncdbs) {
|
||||
pkg = find_satisfier (db.pkgcache, pkgname);
|
||||
if (pkg != null)
|
||||
break;
|
||||
}
|
||||
if (pkg == null) {
|
||||
err.str = _("Failed to prepare transaction");
|
||||
details += _("target not found: %s").printf (pkgname);
|
||||
err.details = details;
|
||||
return err;
|
||||
}
|
||||
int ret = alpm_config.handle.trans_add_pkg (pkg);
|
||||
if (ret == -1) {
|
||||
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;
|
||||
else {
|
||||
err.str = _("Failed to prepare transaction");
|
||||
details += "%s: %s".printf (pkg.name, Alpm.strerror (errno));
|
||||
err.details = details;
|
||||
return err;
|
||||
public void refresh (int force, bool emit_signal) {
|
||||
force_refresh = force;
|
||||
emit_refreshed_signal = emit_signal;
|
||||
try {
|
||||
new Thread<int>.try ("refresh thread", (ThreadFunc) refresh_real);
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
public ErrorInfos trans_load_pkg (string pkgpath) {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
unowned 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 (alpm_config.handle.errno ()));
|
||||
err.details = details;
|
||||
return err;
|
||||
} else {
|
||||
int ret = alpm_config.handle.trans_add_pkg (pkg);
|
||||
public UpdatesInfos[] get_updates () {
|
||||
init_alpm_config ();
|
||||
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
UpdatesInfos[] updates = {};
|
||||
updates = get_syncfirst_updates (handle, syncfirst);
|
||||
if (updates.length != 0) {
|
||||
return updates;
|
||||
} else {
|
||||
updates = get_repos_updates (handle, ignorepkg);
|
||||
if (pamac_config.enable_aur) {
|
||||
UpdatesInfos[] aur_updates = get_aur_updates (handle, ignorepkg);
|
||||
foreach (var infos in aur_updates)
|
||||
updates += infos;
|
||||
}
|
||||
return updates;
|
||||
}
|
||||
}
|
||||
|
||||
public ErrorInfos trans_init (TransFlag transflags) {
|
||||
init_alpm_config ();
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
int ret = handle.trans_init (transflags);
|
||||
if (ret == -1) {
|
||||
Alpm.Errno errno = alpm_config.handle.errno ();
|
||||
err.str = _("Failed to init transaction");
|
||||
details += Alpm.strerror (handle.errno ());
|
||||
err.details = details;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
public ErrorInfos trans_sysupgrade (int enable_downgrade) {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
int ret = handle.trans_sysupgrade (enable_downgrade);
|
||||
if (ret == -1) {;
|
||||
err.str = _("Failed to prepare transaction");
|
||||
details += Alpm.strerror (handle.errno ());
|
||||
err.details = details;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
public ErrorInfos trans_add_pkg (string pkgname) {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
unowned Package? pkg = null;
|
||||
//pkg = handle.find_dbs_satisfier (handle.syncdbs, pkgname);
|
||||
foreach (var db in handle.syncdbs) {
|
||||
pkg = find_satisfier (db.pkgcache, pkgname);
|
||||
if (pkg != null)
|
||||
break;
|
||||
}
|
||||
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_add_pkg (pkg);
|
||||
if (ret == -1) {
|
||||
Alpm.Errno errno = handle.errno ();
|
||||
if (errno == Errno.TRANS_DUP_TARGET || errno == Errno.PKG_IGNORED)
|
||||
// just skip duplicate or ignored targets
|
||||
return err;
|
||||
@@ -233,231 +206,269 @@ public class PamacServer : Object {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
public ErrorInfos trans_remove_pkg (string pkgname) {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
unowned Package? pkg = 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 = alpm_config.handle.trans_remove_pkg (pkg);
|
||||
if (ret == -1) {
|
||||
err.str = _("Failed to prepare transaction");
|
||||
details += "%s: %s".printf (pkg.name, Alpm.strerror (alpm_config.handle.errno ()));
|
||||
err.details = details;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
public void trans_prepare_real () {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
Alpm.List<void*> err_data = null;
|
||||
int ret = alpm_config.handle.trans_prepare (out err_data);
|
||||
if (ret == -1) {
|
||||
Alpm.Errno errno = alpm_config.handle.errno ();
|
||||
err.str = _("Failed to prepare transaction");
|
||||
string detail = Alpm.strerror (errno);
|
||||
switch (errno) {
|
||||
case Errno.PKG_INVALID_ARCH:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
char *pkgname = i;
|
||||
details += _("package %s does not have a valid architecture").printf (pkgname);
|
||||
public ErrorInfos trans_load_pkg (string pkgpath) {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
Package* pkg = handle.load_file (pkgpath, 1, handle.localfilesiglevel);
|
||||
if (pkg == null) {
|
||||
err.str = _("Failed to prepare transaction");
|
||||
details += "%s: %s".printf (pkgpath, Alpm.strerror (handle.errno ()));
|
||||
err.details = details;
|
||||
return err;
|
||||
} else {
|
||||
int ret = handle.trans_add_pkg (pkg);
|
||||
if (ret == -1) {
|
||||
Alpm.Errno errno = handle.errno ();
|
||||
if (errno == Errno.TRANS_DUP_TARGET || errno == Errno.PKG_IGNORED)
|
||||
// just skip duplicate or ignored targets
|
||||
return err;
|
||||
else {
|
||||
err.str = _("Failed to prepare transaction");
|
||||
details += "%s: %s".printf (pkg->name, Alpm.strerror (errno));
|
||||
err.details = details;
|
||||
return err;
|
||||
}
|
||||
break;
|
||||
case Errno.UNSATISFIED_DEPS:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
DepMissing *miss = i;
|
||||
string depstring = miss->depend.compute_string ();
|
||||
details += _("%s: requires %s").printf (miss->target, depstring);
|
||||
}
|
||||
break;
|
||||
case Errno.CONFLICTING_DEPS:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
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) {
|
||||
detail += " (%s)".printf (conflict->reason.compute_string ());
|
||||
}
|
||||
details += detail;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
details += detail;
|
||||
break;
|
||||
}
|
||||
err.details = details;
|
||||
trans_release ();
|
||||
} else {
|
||||
// Search for holdpkg in target list
|
||||
bool found_locked_pkg = false;
|
||||
foreach (unowned Package 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;
|
||||
// free the package because it will not be used
|
||||
delete pkg;
|
||||
}
|
||||
}
|
||||
if (found_locked_pkg) {
|
||||
return err;
|
||||
}
|
||||
|
||||
public ErrorInfos trans_remove_pkg (string pkgname) {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
unowned Package? pkg = 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);
|
||||
if (ret == -1) {
|
||||
err.str = _("Failed to prepare transaction");
|
||||
details += "%s: %s".printf (pkg.name, Alpm.strerror (handle.errno ()));
|
||||
err.details = details;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
public int trans_prepare_real () {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
Alpm.List<void*> err_data = null;
|
||||
int ret = handle.trans_prepare (out err_data);
|
||||
if (ret == -1) {
|
||||
Alpm.Errno errno = handle.errno ();
|
||||
err.str = _("Failed to prepare transaction");
|
||||
string detail = Alpm.strerror (errno);
|
||||
switch (errno) {
|
||||
case Errno.PKG_INVALID_ARCH:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
char *pkgname = i;
|
||||
details += _("package %s does not have a valid architecture").printf (pkgname);
|
||||
}
|
||||
break;
|
||||
case Errno.UNSATISFIED_DEPS:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
DepMissing *miss = i;
|
||||
string depstring = miss->depend.compute_string ();
|
||||
details += _("%s: requires %s").printf (miss->target, depstring);
|
||||
}
|
||||
break;
|
||||
case Errno.CONFLICTING_DEPS:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
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) {
|
||||
detail += " (%s)".printf (conflict->reason.compute_string ());
|
||||
}
|
||||
details += detail;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
details += detail;
|
||||
break;
|
||||
}
|
||||
err.details = details;
|
||||
trans_release ();
|
||||
} 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) {
|
||||
details += _("%s needs to be removed but it is a locked package").printf (pkg.name);
|
||||
found_locked_pkg = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found_locked_pkg) {
|
||||
err.str = _("Failed to prepare transaction");
|
||||
err.details = details;
|
||||
trans_release ();
|
||||
}
|
||||
}
|
||||
emit_trans_prepared (err);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void trans_prepare () {
|
||||
try {
|
||||
new Thread<int>.try ("prepare thread", (ThreadFunc) trans_prepare_real);
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
}
|
||||
emit_trans_prepared (err);
|
||||
}
|
||||
|
||||
public async void trans_prepare () {
|
||||
try {
|
||||
new Thread<void*>.try ("prepare thread", (ThreadFunc) trans_prepare_real);
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
public void choose_provider (int provider) {
|
||||
provider_mutex.lock ();
|
||||
choosen_provider = provider;
|
||||
provider_cond.signal ();
|
||||
provider_mutex.unlock ();
|
||||
}
|
||||
}
|
||||
|
||||
public void choose_provider (int provider) {
|
||||
provider_mutex.lock ();
|
||||
choosen_provider = provider;
|
||||
provider_cond.signal ();
|
||||
provider_mutex.unlock ();
|
||||
}
|
||||
public UpdatesInfos[] trans_to_add () {
|
||||
UpdatesInfos info = UpdatesInfos ();
|
||||
UpdatesInfos[] infos = {};
|
||||
foreach (var pkg in handle.trans_to_add ()) {
|
||||
info.name = pkg.name;
|
||||
info.version = pkg.version;
|
||||
// if pkg was load from a file, pkg.db is null
|
||||
if (pkg.db != null)
|
||||
info.db_name = pkg.db.name;
|
||||
else
|
||||
info.db_name = "";
|
||||
info.tarpath = "";
|
||||
info.download_size = pkg.download_size;
|
||||
infos += info;
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
public UpdatesInfos[] trans_to_add () {
|
||||
UpdatesInfos info = UpdatesInfos ();
|
||||
UpdatesInfos[] infos = {};
|
||||
foreach (unowned Package 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
|
||||
if (pkg.db != null)
|
||||
public UpdatesInfos[] trans_to_remove () {
|
||||
UpdatesInfos info = UpdatesInfos ();
|
||||
UpdatesInfos[] infos = {};
|
||||
foreach (var pkg in handle.trans_to_remove ()) {
|
||||
info.name = pkg.name;
|
||||
info.version = pkg.version;
|
||||
info.db_name = pkg.db.name;
|
||||
else
|
||||
info.db_name = "";
|
||||
info.tarpath = "";
|
||||
info.download_size = pkg.download_size;
|
||||
infos += info;
|
||||
info.tarpath = "";
|
||||
info.download_size = pkg.download_size;
|
||||
infos += info;
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
public UpdatesInfos[] trans_to_remove () {
|
||||
UpdatesInfos info = UpdatesInfos ();
|
||||
UpdatesInfos[] infos = {};
|
||||
foreach (unowned Package pkg in alpm_config.handle.trans_to_remove ()) {
|
||||
info.name = pkg.name;
|
||||
info.version = pkg.version;
|
||||
info.db_name = pkg.db.name;
|
||||
info.tarpath = "";
|
||||
info.download_size = pkg.download_size;
|
||||
infos += info;
|
||||
private int trans_commit_real () {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
Alpm.List<void*> err_data = null;
|
||||
int ret = handle.trans_commit (out err_data);
|
||||
if (ret == -1) {
|
||||
Alpm.Errno errno = 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 ();
|
||||
//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:
|
||||
details += _("%s exists in both %s and %s").printf (conflict->file, conflict->target, conflict->ctarget);
|
||||
break;
|
||||
case FileConflictType.FILESYSTEM:
|
||||
details += _("%s: %s already exists in filesystem").printf (conflict->target, conflict->file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Alpm.Errno.PKG_INVALID:
|
||||
case Alpm.Errno.PKG_INVALID_CHECKSUM:
|
||||
case Alpm.Errno.PKG_INVALID_SIG:
|
||||
case Alpm.Errno.DLT_INVALID:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
char *filename = i;
|
||||
details += _("%s is invalid or corrupted").printf (filename);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
details += detail;
|
||||
break;
|
||||
}
|
||||
err.details = details;
|
||||
}
|
||||
trans_release ();
|
||||
emit_trans_committed (err);
|
||||
return ret;
|
||||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
private void trans_commit_real () {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
string[] details = {};
|
||||
Alpm.List<void*> err_data = null;
|
||||
int ret = alpm_config.handle.trans_commit (out err_data);
|
||||
if (ret == -1) {
|
||||
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 = 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:
|
||||
details += _("%s exists in both %s and %s").printf (conflict->file, conflict->target, conflict->ctarget);
|
||||
break;
|
||||
case FileConflictType.FILESYSTEM:
|
||||
details += _("%s: %s already exists in filesystem").printf (conflict->target, conflict->file);
|
||||
break;
|
||||
public void trans_commit (GLib.BusName sender) {
|
||||
try {
|
||||
Polkit.Authority authority = Polkit.Authority.get_sync (null);
|
||||
Polkit.Subject subject = Polkit.SystemBusName.new (sender);
|
||||
var result = new Polkit.AuthorizationResult (false, false, null);
|
||||
authority.check_authorization.begin (
|
||||
subject,
|
||||
"org.manjaro.pamac.commit",
|
||||
null,
|
||||
Polkit.CheckAuthorizationFlags.ALLOW_USER_INTERACTION,
|
||||
null,
|
||||
(obj, res) => {
|
||||
try {
|
||||
result = authority.check_authorization.end (res);
|
||||
if (result.get_is_authorized ()) {
|
||||
new Thread<int>.try ("commit thread", (ThreadFunc) trans_commit_real);
|
||||
} else {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
err.str = dgettext (null, "Authentication failed");
|
||||
emit_trans_committed (err);
|
||||
trans_release ();
|
||||
}
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("Polkit Error: %s\n", e.message);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Alpm.Errno.PKG_INVALID:
|
||||
case Alpm.Errno.PKG_INVALID_CHECKSUM:
|
||||
case Alpm.Errno.PKG_INVALID_SIG:
|
||||
case Alpm.Errno.DLT_INVALID:
|
||||
detail += ":";
|
||||
details += detail;
|
||||
foreach (void *i in err_data) {
|
||||
char *filename = i;
|
||||
details += _("%s is invalid or corrupted").printf (filename);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
details += detail;
|
||||
break;
|
||||
);
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("Polkit Error: %s\n", e.message);
|
||||
}
|
||||
err.details = details;
|
||||
}
|
||||
trans_release ();
|
||||
get_handle ();
|
||||
emit_trans_committed (err);
|
||||
}
|
||||
|
||||
public async void trans_commit (GLib.BusName sender) {
|
||||
try {
|
||||
Polkit.Authority authority = Polkit.Authority.get_sync (null);
|
||||
Polkit.Subject subject = Polkit.SystemBusName.new (sender);
|
||||
Polkit.AuthorizationResult result = authority.check_authorization_sync
|
||||
(subject,
|
||||
"org.manjaro.pamac.commit",
|
||||
null,
|
||||
Polkit.CheckAuthorizationFlags.ALLOW_USER_INTERACTION,
|
||||
null);
|
||||
if (result.get_is_authorized ()) {
|
||||
new Thread<void*>.try ("commit thread", (ThreadFunc) trans_commit_real);
|
||||
} else {
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
err.str = dgettext ("pamac", "Authentication failed");
|
||||
emit_trans_committed (err);
|
||||
trans_release ();
|
||||
}
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
public int trans_release () {
|
||||
return handle.trans_release ();
|
||||
}
|
||||
}
|
||||
|
||||
public int trans_release () {
|
||||
return alpm_config.handle.trans_release ();
|
||||
}
|
||||
public void trans_cancel () {
|
||||
handle.trans_interrupt ();
|
||||
handle.trans_release ();
|
||||
}
|
||||
|
||||
public void trans_cancel () {
|
||||
alpm_config.handle.trans_interrupt ();
|
||||
alpm_config.handle.trans_release ();
|
||||
get_handle ();
|
||||
public void quit () {
|
||||
GLib.File lockfile = GLib.File.new_for_path ("/var/lib/pacman/db.lck");
|
||||
if (lockfile.query_exists () == false)
|
||||
loop.quit ();
|
||||
}
|
||||
// End of Daemon Object
|
||||
}
|
||||
|
||||
public void quit () {
|
||||
GLib.File lockfile = GLib.File.new_for_path ("/var/lib/pacman/db.lck");
|
||||
if (lockfile.query_exists () == false)
|
||||
loop.quit ();
|
||||
}
|
||||
// End of Server Object
|
||||
}
|
||||
|
||||
private void write_log_file (string event) {
|
||||
@@ -568,7 +579,7 @@ private void cb_event (Event event, void *data1, void *data2) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
server.emit_event ((uint) event, details);
|
||||
pamac_daemon.emit_event ((uint) event, details);
|
||||
}
|
||||
|
||||
private void cb_question (Question question, void *data1, void *data2, void *data3, out int response) {
|
||||
@@ -594,19 +605,19 @@ private void cb_question (Question question, void *data1, void *data2, void *dat
|
||||
Depend *depend = data2;
|
||||
string depend_str = depend->compute_string ();
|
||||
string[] providers_str = {};
|
||||
foreach (unowned Package pkg in providers) {
|
||||
foreach (var pkg in providers) {
|
||||
providers_str += pkg.name;
|
||||
}
|
||||
server.provider_cond = Cond ();
|
||||
server.provider_mutex = Mutex ();
|
||||
server.choosen_provider = null;
|
||||
server.emit_providers (depend_str, providers_str);
|
||||
server.provider_mutex.lock ();
|
||||
while (server.choosen_provider == null) {
|
||||
server.provider_cond.wait (server.provider_mutex);
|
||||
pamac_daemon.provider_cond = Cond ();
|
||||
pamac_daemon.provider_mutex = Mutex ();
|
||||
pamac_daemon.choosen_provider = null;
|
||||
pamac_daemon.emit_providers (depend_str, providers_str);
|
||||
pamac_daemon.provider_mutex.lock ();
|
||||
while (pamac_daemon.choosen_provider == null) {
|
||||
pamac_daemon.provider_cond.wait (pamac_daemon.provider_mutex);
|
||||
}
|
||||
response = server.choosen_provider;
|
||||
server.provider_mutex.unlock ();
|
||||
response = pamac_daemon.choosen_provider;
|
||||
pamac_daemon.provider_mutex.unlock ();
|
||||
break;
|
||||
case Question.CORRUPTED_PKG:
|
||||
// Auto-remove corrupted pkgs in cache
|
||||
@@ -640,21 +651,21 @@ private void cb_progress (Progress progress, string pkgname, int percent, uint n
|
||||
//~ default:
|
||||
//~ break;
|
||||
//~ }
|
||||
if ((uint64) percent != server.previous_percent) {
|
||||
server.previous_percent = (uint64) percent;
|
||||
server.emit_progress ((uint) progress, pkgname, percent, n_targets, current_target);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private void cb_download (string filename, uint64 xfered, uint64 total) {
|
||||
if (xfered != server.previous_percent) {
|
||||
server.previous_percent = xfered;
|
||||
server.emit_download (filename, xfered, total);
|
||||
if (xfered != pamac_daemon.previous_percent) {
|
||||
pamac_daemon.previous_percent = xfered;
|
||||
pamac_daemon.emit_download (filename, xfered, total);
|
||||
}
|
||||
}
|
||||
|
||||
private void cb_totaldownload (uint64 total) {
|
||||
server.emit_totaldownload (total);
|
||||
pamac_daemon.emit_totaldownload (total);
|
||||
}
|
||||
|
||||
private void cb_log (LogLevel level, string fmt, va_list args) {
|
||||
@@ -664,13 +675,13 @@ private void cb_log (LogLevel level, string fmt, va_list args) {
|
||||
string? log = null;
|
||||
log = fmt.vprintf (args);
|
||||
if (log != null)
|
||||
server.emit_log ((uint) level, log);
|
||||
pamac_daemon.emit_log ((uint) level, log);
|
||||
}
|
||||
|
||||
void on_bus_acquired (DBusConnection conn) {
|
||||
server = new PamacServer ();
|
||||
pamac_daemon = new Pamac.Daemon ();
|
||||
try {
|
||||
conn.register_object ("/org/manjaro/pamac", server);
|
||||
conn.register_object ("/org/manjaro/pamac", pamac_daemon);
|
||||
}
|
||||
catch (IOError e) {
|
||||
stderr.printf ("Could not register service\n");
|
||||
@@ -679,10 +690,10 @@ void on_bus_acquired (DBusConnection conn) {
|
||||
|
||||
void main () {
|
||||
// i18n
|
||||
Intl.setlocale(LocaleCategory.ALL, "");
|
||||
Intl.textdomain(GETTEXT_PACKAGE);
|
||||
Intl.setlocale (LocaleCategory.ALL, "");
|
||||
Intl.textdomain (GETTEXT_PACKAGE);
|
||||
|
||||
Bus.own_name(BusType.SYSTEM, "org.manjaro.pamac", BusNameOwnerFlags.NONE,
|
||||
Bus.own_name (BusType.SYSTEM, "org.manjaro.pamac", BusNameOwnerFlags.NONE,
|
||||
on_bus_acquired,
|
||||
() => {},
|
||||
() => stderr.printf("Could not acquire name\n"));
|
||||
|
@@ -51,7 +51,7 @@ namespace Pamac {
|
||||
public override void open (File[] files, string hint) {
|
||||
foreach (File file in files) {
|
||||
string? path = file.get_path ();
|
||||
transaction.data.to_load.insert (path, path);
|
||||
transaction.to_load.insert (path, path);
|
||||
}
|
||||
transaction.run ();
|
||||
}
|
||||
|
@@ -59,6 +59,8 @@ namespace Pamac {
|
||||
[GtkChild]
|
||||
public TreeView search_treeview;
|
||||
[GtkChild]
|
||||
public TreeSelection search_treeview_selection;
|
||||
[GtkChild]
|
||||
public TreeView groups_treeview;
|
||||
[GtkChild]
|
||||
public TreeView states_treeview;
|
||||
@@ -167,13 +169,14 @@ namespace Pamac {
|
||||
}
|
||||
|
||||
public void update_lists () {
|
||||
Alpm.List <string?> grps = null;
|
||||
string[] grps = {};
|
||||
TreeIter iter;
|
||||
foreach (unowned DB db in transaction.alpm_config.handle.syncdbs) {
|
||||
foreach (unowned DB db in transaction.handle.syncdbs) {
|
||||
repos_list.insert_with_values (out iter, -1, 0, db.name);
|
||||
foreach (unowned Group grp in db.groupcache) {
|
||||
if (grps.find_str (grp.name) == null)
|
||||
grps.add(grp.name);
|
||||
if ((grp.name in grps) == false) {
|
||||
grps += grp.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
repos_list.insert_with_values (out iter, -1, 0, dgettext (null, "local"));
|
||||
@@ -230,20 +233,20 @@ namespace Pamac {
|
||||
if (len != 0) {
|
||||
deps_list.insert_with_values (out iter, -1,
|
||||
0, dgettext (null, "Depends On") + ":",
|
||||
1, list.nth (0).get_data ().compute_string ());
|
||||
1, list.nth_data (0).compute_string ());
|
||||
i = 1;
|
||||
while (i < len) {
|
||||
deps_list.insert_with_values (out iter, -1,
|
||||
1, list.nth (i).get_data ().compute_string ());
|
||||
1, list.nth_data (i).compute_string ());
|
||||
i++;
|
||||
}
|
||||
}
|
||||
list = pkg.optdepends;
|
||||
len = list.length;
|
||||
if (len != 0) {
|
||||
unowned Depend optdep = list.nth (0).get_data ();
|
||||
unowned Depend optdep = list.nth_data (0);
|
||||
unowned Alpm.Package? satisfier = find_satisfier (
|
||||
transaction.alpm_config.handle.localdb.pkgcache,
|
||||
transaction.handle.localdb.pkgcache,
|
||||
optdep.name);
|
||||
string optdep_str = optdep.compute_string ();
|
||||
if (satisfier != null)
|
||||
@@ -253,9 +256,9 @@ namespace Pamac {
|
||||
1, optdep_str);
|
||||
i = 1;
|
||||
while (i < len) {
|
||||
optdep = list.nth (i).get_data ();
|
||||
optdep = list.nth_data (i);
|
||||
satisfier = find_satisfier (
|
||||
transaction.alpm_config.handle.localdb.pkgcache,
|
||||
transaction.handle.localdb.pkgcache,
|
||||
optdep.name);
|
||||
optdep_str = optdep.compute_string ();
|
||||
if (satisfier != null)
|
||||
@@ -265,16 +268,16 @@ namespace Pamac {
|
||||
}
|
||||
}
|
||||
if (pkg.origin == PkgFrom.LOCALDB) {
|
||||
unowned Alpm.List<string?> str_list = pkg.compute_requiredby ();
|
||||
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 (0).get_data ());
|
||||
1, str_list.nth_data (0));
|
||||
i = 1;
|
||||
while (i < len) {
|
||||
deps_list.insert_with_values (out iter, -1,
|
||||
1, str_list.nth (i).get_data ());
|
||||
1, str_list.nth_data (i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -284,11 +287,11 @@ namespace Pamac {
|
||||
if (len != 0) {
|
||||
deps_list.insert_with_values (out iter, -1,
|
||||
0, dgettext (null, "Provides") + ":",
|
||||
1, list.nth (0).get_data ().compute_string ());
|
||||
1, list.nth_data (0).compute_string ());
|
||||
i = 1;
|
||||
while (i < len) {
|
||||
deps_list.insert_with_values (out iter, -1,
|
||||
1, list.nth (i).get_data ().compute_string ());
|
||||
1, list.nth_data (i).compute_string ());
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -297,11 +300,11 @@ namespace Pamac {
|
||||
if (len != 0) {
|
||||
deps_list.insert_with_values (out iter, -1,
|
||||
0, dgettext (null, "Replaces") + ":",
|
||||
1, list.nth (0).get_data ().compute_string ());
|
||||
1, list.nth_data (0).compute_string ());
|
||||
i = 1;
|
||||
while (i < len) {
|
||||
deps_list.insert_with_values (out iter, -1,
|
||||
1, list.nth (i).get_data ().compute_string ());
|
||||
1, list.nth_data (i).compute_string ());
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -310,11 +313,11 @@ namespace Pamac {
|
||||
if (len != 0) {
|
||||
deps_list.insert_with_values (out iter, -1,
|
||||
0, dgettext (null, "Conflicts With") + ":",
|
||||
1, list.nth (0).get_data ().compute_string ());
|
||||
1, list.nth_data (0).compute_string ());
|
||||
i = 1;
|
||||
while (i < len) {
|
||||
deps_list.insert_with_values (out iter, -1,
|
||||
1, list.nth (i).get_data ().compute_string ());
|
||||
1, list.nth_data (i).compute_string ());
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -334,11 +337,11 @@ namespace Pamac {
|
||||
if (len != 0) {
|
||||
details_list.insert_with_values (out iter, -1,
|
||||
0, dgettext (null, "Groups") + ":",
|
||||
1, list.nth (0).get_data ());
|
||||
1, list.nth_data (0));
|
||||
i = 1;
|
||||
while (i < len) {
|
||||
details_list.insert_with_values (out iter, -1,
|
||||
1, list.nth (i).get_data ());
|
||||
1, list.nth_data (i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -373,11 +376,11 @@ namespace Pamac {
|
||||
if (len != 0) {
|
||||
details_list.insert_with_values (out iter, -1,
|
||||
0, dgettext (null, "Backup files") + ":",
|
||||
1, "/" + backup_list.nth (0).get_data ().name);
|
||||
1, "/" + backup_list.nth_data (0).name);
|
||||
i = 1;
|
||||
while (i < len) {
|
||||
details_list.insert_with_values (out iter, -1,
|
||||
1, "/" + backup_list.nth (i).get_data ().name);
|
||||
1, "/" + backup_list.nth_data (i).name);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -396,12 +399,11 @@ namespace Pamac {
|
||||
}
|
||||
|
||||
public async unowned Alpm.List<Alpm.Package?> search_pkgs (string search_string, out Json.Array aur_pkgs) {
|
||||
unowned Alpm.List<Alpm.Package?> pkgs = null;
|
||||
unowned Alpm.List<string?> needles = null;
|
||||
string[] splitted = search_string.split (" ");
|
||||
foreach (unowned string part in splitted)
|
||||
needles.add (part);
|
||||
pkgs = search_all_dbs (transaction.alpm_config.handle, needles);
|
||||
unowned Alpm.List<Alpm.Package?> pkgs = search_all_dbs (transaction.handle, needles);
|
||||
if (search_aur_button.get_active()) {
|
||||
if (aur_results.contains (search_string)) {
|
||||
aur_pkgs = aur_results.get (search_string);
|
||||
@@ -495,28 +497,28 @@ namespace Pamac {
|
||||
packages_list.get_value (iter, 0, out val);
|
||||
string name = val.get_string ();
|
||||
if (name != dgettext (null, "No package found")) {
|
||||
if (transaction.data.to_add.contains (name)) {
|
||||
transaction.data.to_add.steal (name);
|
||||
} else if (transaction.data.to_remove.contains (name)) {
|
||||
transaction.data.to_remove.steal (name);
|
||||
} else if (transaction.data.to_build.contains (name)) {
|
||||
transaction.data.to_build.steal (name);
|
||||
if (transaction.to_add.contains (name)) {
|
||||
transaction.to_add.steal (name);
|
||||
} else if (transaction.to_remove.contains (name)) {
|
||||
transaction.to_remove.steal (name);
|
||||
} else if (transaction.to_build.contains (name)) {
|
||||
transaction.to_build.steal (name);
|
||||
} else {
|
||||
packages_list.get_value (iter, 3, out val);
|
||||
string db_name = val.get_string ();
|
||||
if (db_name == "local") {
|
||||
if (!(name in transaction.alpm_config.holdpkg)) {
|
||||
transaction.data.to_remove.insert (name, name);
|
||||
if ((name in transaction.holdpkg) == false) {
|
||||
transaction.to_remove.insert (name, name);
|
||||
}
|
||||
} else if (db_name == "AUR") {
|
||||
transaction.data.to_build.insert (name, name);
|
||||
transaction.to_build.insert (name, name);
|
||||
} else {
|
||||
transaction.data.to_add.insert (name, name);
|
||||
transaction.to_add.insert (name, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (transaction.data.to_add.size () + transaction.data.to_remove.size () + transaction.data.to_build.size () == 0) {
|
||||
if (transaction.to_add.size () + transaction.to_remove.size () + transaction.to_build.size () == 0) {
|
||||
set_buttons_sensitive (false);
|
||||
} else {
|
||||
set_buttons_sensitive (true);
|
||||
@@ -642,8 +644,11 @@ namespace Pamac {
|
||||
model.get_value (_iter, 0, out line);
|
||||
if ((string) line == search_string) {
|
||||
found = true;
|
||||
// populate will be done because we select the iter in search_list
|
||||
// block the signal to not populate when we select the iter in search_list
|
||||
search_treeview_selection.changed.disconnect (on_search_treeview_selection_changed);
|
||||
selection.select_iter (_iter);
|
||||
search_treeview_selection.changed.connect_after (on_search_treeview_selection_changed);
|
||||
populate_packages_list (pkgs, aur_pkgs);
|
||||
}
|
||||
return found;
|
||||
});
|
||||
@@ -651,8 +656,11 @@ namespace Pamac {
|
||||
}
|
||||
if (!found) {
|
||||
search_list.insert_with_values (out iter, -1, 0, search_string);
|
||||
// populate will be done because we select the iter in search_list
|
||||
// block the signal to not populate when we select the iter in search_list
|
||||
search_treeview_selection.changed.disconnect (on_search_treeview_selection_changed);
|
||||
selection.select_iter (iter);
|
||||
search_treeview_selection.changed.connect_after (on_search_treeview_selection_changed);
|
||||
populate_packages_list (pkgs, aur_pkgs);
|
||||
}
|
||||
} else
|
||||
// populate with empty lists
|
||||
@@ -698,7 +706,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.alpm_config.handle, grp_name);
|
||||
unowned Alpm.List<Alpm.Package?> pkgs = group_pkgs_all_dbs (transaction.handle, grp_name);
|
||||
populate_packages_list (pkgs);
|
||||
}
|
||||
}
|
||||
@@ -718,28 +726,28 @@ namespace Pamac {
|
||||
unowned Alpm.List<Alpm.Package?> pkgs = null;
|
||||
unowned Alpm.Package? find_pkg = null;
|
||||
if (state == dgettext (null, "To install")) {
|
||||
foreach (string name in transaction.data.to_add.get_keys ()) {
|
||||
find_pkg = transaction.alpm_config.handle.localdb.get_pkg (name);
|
||||
foreach (string name in transaction.to_add.get_keys ()) {
|
||||
find_pkg = transaction.handle.localdb.get_pkg (name);
|
||||
if (find_pkg != null)
|
||||
pkgs.add (find_pkg);
|
||||
else {
|
||||
find_pkg = get_syncpkg (transaction.alpm_config.handle, name);
|
||||
find_pkg = get_syncpkg (transaction.handle, name);
|
||||
if (find_pkg != null)
|
||||
pkgs.add (find_pkg);
|
||||
}
|
||||
}
|
||||
} else if (state == dgettext (null, "To remove")) {
|
||||
foreach (string name in transaction.data.to_remove.get_keys ()) {
|
||||
find_pkg = transaction.alpm_config.handle.localdb.get_pkg (name);
|
||||
foreach (string name in transaction.to_remove.get_keys ()) {
|
||||
find_pkg = transaction.handle.localdb.get_pkg (name);
|
||||
if (find_pkg != null)
|
||||
pkgs.add (find_pkg);
|
||||
}
|
||||
} else if (state == dgettext (null, "Installed")) {
|
||||
pkgs = transaction.alpm_config.handle.localdb.pkgcache;
|
||||
pkgs = transaction.handle.localdb.pkgcache;
|
||||
} else if (state == dgettext (null, "Uninstalled")) {
|
||||
unowned Alpm.List<Alpm.Package?> tmp = null;
|
||||
unowned Alpm.List<Alpm.Package?> diff = null;
|
||||
foreach (unowned DB db in transaction.alpm_config.handle.syncdbs) {
|
||||
foreach (unowned DB db in transaction.handle.syncdbs) {
|
||||
if (pkgs.length == 0)
|
||||
pkgs = db.pkgcache;
|
||||
else {
|
||||
@@ -749,7 +757,7 @@ namespace Pamac {
|
||||
}
|
||||
}
|
||||
} else if (state == dgettext (null, "Orphans")) {
|
||||
foreach (unowned Alpm.Package pkg in transaction.alpm_config.handle.localdb.pkgcache) {
|
||||
foreach (unowned Alpm.Package pkg in transaction.handle.localdb.pkgcache) {
|
||||
if (pkg.reason == PkgReason.DEPEND) {
|
||||
if (pkg.compute_requiredby().length == 0)
|
||||
pkgs.add (pkg);
|
||||
@@ -775,16 +783,16 @@ namespace Pamac {
|
||||
unowned Alpm.List<Alpm.Package?> pkgs = null;
|
||||
unowned Alpm.Package? find_pkg = null;
|
||||
if (repo == dgettext (null, "local")) {
|
||||
foreach (unowned Alpm.Package pkg in transaction.alpm_config.handle.localdb.pkgcache) {
|
||||
find_pkg = get_syncpkg (transaction.alpm_config.handle, pkg.name);
|
||||
foreach (unowned Alpm.Package pkg in transaction.handle.localdb.pkgcache) {
|
||||
find_pkg = get_syncpkg (transaction.handle, pkg.name);
|
||||
if (find_pkg == null)
|
||||
pkgs.add (pkg);
|
||||
}
|
||||
} else {
|
||||
foreach (unowned DB db in transaction.alpm_config.handle.syncdbs) {
|
||||
foreach (unowned DB db in transaction.handle.syncdbs) {
|
||||
if (db.name == repo) {
|
||||
foreach (unowned Alpm.Package pkg in db.pkgcache) {
|
||||
find_pkg = transaction.alpm_config.handle.localdb.get_pkg (pkg.name);
|
||||
find_pkg = transaction.handle.localdb.get_pkg (pkg.name);
|
||||
if (find_pkg != null)
|
||||
pkgs.add (find_pkg);
|
||||
else
|
||||
@@ -835,7 +843,7 @@ namespace Pamac {
|
||||
SList<string> packages_paths = packages_chooser_dialog.get_filenames ();
|
||||
if (packages_paths.length () != 0) {
|
||||
foreach (string path in packages_paths) {
|
||||
transaction.data.to_load.insert (path, path);
|
||||
transaction.to_load.insert (path, path);
|
||||
}
|
||||
this.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH));
|
||||
packages_chooser_dialog.hide ();
|
||||
@@ -898,7 +906,7 @@ namespace Pamac {
|
||||
while (Gtk.events_pending ())
|
||||
Gtk.main_iteration ();
|
||||
if (pamac_config.recurse)
|
||||
transaction.data.flags |= Alpm.TransFlag.RECURSE;
|
||||
transaction.flags |= Alpm.TransFlag.RECURSE;
|
||||
transaction.run ();
|
||||
}
|
||||
|
||||
@@ -921,7 +929,7 @@ namespace Pamac {
|
||||
set_buttons_sensitive (false);
|
||||
refresh_packages_list ();
|
||||
}
|
||||
transaction.data.to_load.steal_all ();
|
||||
transaction.to_load.steal_all ();
|
||||
this.get_window ().set_cursor (null);
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ namespace Pamac {
|
||||
SList<string> packages_paths = this.get_filenames ();
|
||||
if (packages_paths.length () != 0) {
|
||||
foreach (string path in packages_paths) {
|
||||
transaction.data.to_load.insert (path, path);
|
||||
transaction.to_load.insert (path, path);
|
||||
}
|
||||
window.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.WATCH));
|
||||
this.hide ();
|
||||
|
@@ -84,21 +84,21 @@ namespace Pamac {
|
||||
case 1:
|
||||
val = Value (typeof (Object));
|
||||
if (pkg.alpm_pkg != null) {
|
||||
if (pkg.name in manager_window.transaction.alpm_config.holdpkg)
|
||||
if (pkg.name in manager_window.transaction.holdpkg)
|
||||
val.set_object (manager_window.locked_icon);
|
||||
else if (pkg.repo == "local") {
|
||||
if (manager_window.transaction.data.to_add.contains (pkg.name))
|
||||
if (manager_window.transaction.to_add.contains (pkg.name))
|
||||
val.set_object (manager_window.to_reinstall_icon);
|
||||
else if (manager_window.transaction.data.to_remove.contains (pkg.name))
|
||||
else if (manager_window.transaction.to_remove.contains (pkg.name))
|
||||
val.set_object (manager_window.to_remove_icon);
|
||||
else
|
||||
val.set_object (manager_window.installed_icon);
|
||||
} else if (manager_window.transaction.data.to_add.contains (pkg.name))
|
||||
} else if (manager_window.transaction.to_add.contains (pkg.name))
|
||||
val.set_object (manager_window.to_install_icon);
|
||||
else
|
||||
val.set_object (manager_window.uninstalled_icon);
|
||||
} else if (pkg.aur_json != null) {
|
||||
if (manager_window.transaction.data.to_build.contains (pkg.name))
|
||||
if (manager_window.transaction.to_build.contains (pkg.name))
|
||||
val.set_object (manager_window.to_install_icon);
|
||||
else
|
||||
val.set_object (manager_window.uninstalled_icon);
|
||||
|
@@ -19,8 +19,8 @@
|
||||
|
||||
namespace Pamac {
|
||||
|
||||
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/progress_window.ui")]
|
||||
public class ProgressWindow : Gtk.Window {
|
||||
[GtkTemplate (ui = "/org/manjaro/pamac/transaction/progress_dialog.ui")]
|
||||
public class ProgressDialog : Gtk.Dialog {
|
||||
|
||||
[GtkChild]
|
||||
public Gtk.ProgressBar progressbar;
|
||||
@@ -35,8 +35,8 @@ namespace Pamac {
|
||||
|
||||
Transaction transaction;
|
||||
|
||||
public ProgressWindow (Transaction transaction, Gtk.ApplicationWindow? window) {
|
||||
Object (transient_for: window);
|
||||
public ProgressDialog (Transaction transaction, Gtk.ApplicationWindow? window) {
|
||||
Object (transient_for: window, use_header_bar: 0);
|
||||
|
||||
this.transaction = transaction;
|
||||
}
|
@@ -25,20 +25,18 @@ namespace Pamac {
|
||||
[DBus (name = "org.manjaro.pamac")]
|
||||
public interface Daemon : Object {
|
||||
public abstract void write_config (HashTable<string,string> new_conf) throws IOError;
|
||||
public abstract void refresh_alpm_config () throws IOError;
|
||||
public abstract async void refresh (int force, bool emit_signal) throws IOError;
|
||||
public abstract void refresh (int force, bool emit_signal) throws IOError;
|
||||
public abstract ErrorInfos trans_init (TransFlag transflags) throws IOError;
|
||||
public abstract ErrorInfos trans_sysupgrade (int enable_downgrade) throws IOError;
|
||||
public abstract ErrorInfos trans_add_pkg (string pkgname) throws IOError;
|
||||
public abstract ErrorInfos trans_remove_pkg (string pkgname) throws IOError;
|
||||
public abstract ErrorInfos trans_load_pkg (string pkgpath) throws IOError;
|
||||
public abstract async void trans_prepare () throws IOError;
|
||||
public abstract void trans_prepare () throws IOError;
|
||||
public abstract void choose_provider (int provider) throws IOError;
|
||||
public abstract UpdatesInfos[] trans_to_add () throws IOError;
|
||||
public abstract UpdatesInfos[] trans_to_remove () throws IOError;
|
||||
public abstract async void trans_commit () throws IOError;
|
||||
public abstract void trans_commit () throws IOError;
|
||||
public abstract void trans_release () throws IOError;
|
||||
[DBus (no_reply = true)]
|
||||
public abstract void trans_cancel () throws IOError;
|
||||
[DBus (no_reply = true)]
|
||||
public abstract void quit () throws IOError;
|
||||
@@ -56,10 +54,19 @@ namespace Pamac {
|
||||
public class Transaction: Object {
|
||||
public Daemon daemon;
|
||||
|
||||
public Alpm.Config alpm_config;
|
||||
public string[] syncfirst;
|
||||
public string[] holdpkg;
|
||||
public string[] ignorepkg;
|
||||
public Handle handle;
|
||||
public Pamac.Config pamac_config;
|
||||
|
||||
public TransactionData data;
|
||||
public Alpm.TransFlag flags;
|
||||
// those hashtables will be used as set
|
||||
public HashTable<string, string> to_add;
|
||||
public HashTable<string, string> to_remove;
|
||||
public HashTable<string, string> to_load;
|
||||
public HashTable<string, string> to_build;
|
||||
|
||||
public Mode mode;
|
||||
|
||||
uint64 total_download;
|
||||
@@ -80,29 +87,28 @@ namespace Pamac {
|
||||
ChooseProviderDialog choose_provider_dialog;
|
||||
TransactionSumDialog transaction_sum_dialog;
|
||||
TransactionInfoDialog transaction_info_dialog;
|
||||
ProgressWindow progress_window;
|
||||
ProgressDialog progress_dialog;
|
||||
//parent window
|
||||
ApplicationWindow? window;
|
||||
|
||||
public signal void finished (bool error);
|
||||
|
||||
public Transaction (ApplicationWindow? window, Pamac.Config pamac_config) {
|
||||
alpm_config = new Alpm.Config ("/etc/pacman.conf");
|
||||
refresh_alpm_config ();
|
||||
this.pamac_config = pamac_config;
|
||||
mode = Mode.MANAGER;
|
||||
data = TransactionData ();
|
||||
data.flags = Alpm.TransFlag.CASCADE;
|
||||
data.to_add = new HashTable<string, string> (str_hash, str_equal);
|
||||
data.to_remove = new HashTable<string, string> (str_hash, str_equal);
|
||||
data.to_load = new HashTable<string, string> (str_hash, str_equal);
|
||||
data.to_build = new HashTable<string, string> (str_hash, str_equal);
|
||||
flags = Alpm.TransFlag.CASCADE;
|
||||
to_add = new HashTable<string, string> (str_hash, str_equal);
|
||||
to_remove = new HashTable<string, string> (str_hash, str_equal);
|
||||
to_load = new HashTable<string, string> (str_hash, str_equal);
|
||||
to_build = new HashTable<string, string> (str_hash, str_equal);
|
||||
connecting_dbus_signals ();
|
||||
//creating dialogs
|
||||
this.window = window;
|
||||
choose_provider_dialog = new ChooseProviderDialog (window);
|
||||
transaction_sum_dialog = new TransactionSumDialog (window);
|
||||
transaction_info_dialog = new TransactionInfoDialog (window);
|
||||
progress_window = new ProgressWindow (this, window);
|
||||
progress_dialog = new ProgressDialog (this, window);
|
||||
//creating terminal
|
||||
term = new Terminal ();
|
||||
term.scroll_on_output = false;
|
||||
@@ -125,7 +131,7 @@ namespace Pamac {
|
||||
sb.set_visible (true);
|
||||
grid.attach (term, 0, 0, 1, 1);
|
||||
grid.attach (sb, 1, 0, 1, 1);
|
||||
progress_window.expander.add (grid);
|
||||
progress_dialog.expander.add (grid);
|
||||
// progress data
|
||||
total_download = 0;
|
||||
already_downloaded = 0;
|
||||
@@ -147,31 +153,33 @@ namespace Pamac {
|
||||
}
|
||||
|
||||
public void refresh_alpm_config () {
|
||||
alpm_config = new Alpm.Config ("/etc/pacman.conf");
|
||||
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 (int force) {
|
||||
string action = dgettext (null, "Synchronizing package databases") + "...";
|
||||
spawn_in_term ({"/usr/bin/echo", action});
|
||||
progress_window.action_label.set_text (action);
|
||||
progress_window.progressbar.set_fraction (0);
|
||||
progress_window.progressbar.set_text ("");
|
||||
progress_window.cancel_button.set_visible (true);
|
||||
progress_window.close_button.set_visible (false);
|
||||
progress_window.show ();
|
||||
daemon.refresh.begin (force, true, (obj, res) => {
|
||||
try {
|
||||
daemon.refresh.end (res);
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
});
|
||||
progress_dialog.action_label.set_text (action);
|
||||
progress_dialog.progressbar.set_fraction (0);
|
||||
progress_dialog.progressbar.set_text ("");
|
||||
progress_dialog.cancel_button.set_visible (true);
|
||||
progress_dialog.close_button.set_visible (false);
|
||||
progress_dialog.show ();
|
||||
try {
|
||||
daemon.refresh (force, true);
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
public void sysupgrade_simple (int enable_downgrade) {
|
||||
print ("simple sysupgrade\n");
|
||||
progress_window.progressbar.set_fraction (0);
|
||||
progress_window.cancel_button.set_visible (true);
|
||||
progress_dialog.progressbar.set_fraction (0);
|
||||
progress_dialog.cancel_button.set_visible (true);
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
try {
|
||||
err = daemon.trans_init (0);
|
||||
@@ -188,16 +196,14 @@ namespace Pamac {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
if (err.str == "") {
|
||||
progress_window.show ();
|
||||
progress_dialog.show ();
|
||||
while (Gtk.events_pending ())
|
||||
Gtk.main_iteration ();
|
||||
daemon.trans_prepare.begin ((obj, res) => {
|
||||
try {
|
||||
daemon.trans_prepare.end (res);
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
});
|
||||
try {
|
||||
daemon.trans_prepare ();
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
} else {
|
||||
release ();
|
||||
finished (true);
|
||||
@@ -209,35 +215,34 @@ namespace Pamac {
|
||||
public void sysupgrade (int enable_downgrade) {
|
||||
string action = dgettext (null, "Starting full system upgrade") + "...";
|
||||
spawn_in_term ({"/usr/bin/echo", action});
|
||||
progress_window.action_label.set_text (action);
|
||||
progress_window.progressbar.set_fraction (0);
|
||||
progress_window.progressbar.set_text ("");
|
||||
progress_window.cancel_button.set_visible (true);
|
||||
progress_window.close_button.set_visible (false);
|
||||
progress_dialog.action_label.set_text (action);
|
||||
progress_dialog.progressbar.set_fraction (0);
|
||||
progress_dialog.progressbar.set_text ("");
|
||||
progress_dialog.cancel_button.set_visible (true);
|
||||
progress_dialog.close_button.set_visible (false);
|
||||
while (Gtk.events_pending ())
|
||||
Gtk.main_iteration ();
|
||||
// sysupgrade
|
||||
print ("get syncfirst\n");
|
||||
// get syncfirst updates
|
||||
UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (alpm_config);
|
||||
UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (handle, syncfirst);
|
||||
if (syncfirst_updates.length != 0) {
|
||||
clear_lists ();
|
||||
if (mode == Mode.MANAGER)
|
||||
sysupgrade_after_trans = true;
|
||||
foreach (UpdatesInfos infos in syncfirst_updates)
|
||||
data.to_add.insert (infos.name, infos.name);
|
||||
to_add.insert (infos.name, infos.name);
|
||||
// run as a standard transaction
|
||||
run ();
|
||||
} else {
|
||||
if (pamac_config.enable_aur) {
|
||||
print ("get aur updates\n");
|
||||
string[] ignore_pkgs = get_ignore_pkgs (alpm_config);
|
||||
UpdatesInfos[] aur_updates = get_aur_updates (alpm_config, ignore_pkgs);
|
||||
UpdatesInfos[] aur_updates = get_aur_updates (handle, ignorepkg);
|
||||
if (aur_updates.length != 0) {
|
||||
clear_lists ();
|
||||
sysupgrade_after_build = true;
|
||||
foreach (UpdatesInfos infos in aur_updates)
|
||||
data.to_build.insert (infos.name, infos.name);
|
||||
to_build.insert (infos.name, infos.name);
|
||||
}
|
||||
}
|
||||
sysupgrade_simple (enable_downgrade);
|
||||
@@ -245,33 +250,33 @@ namespace Pamac {
|
||||
}
|
||||
|
||||
public void clear_lists () {
|
||||
data.to_add.steal_all ();
|
||||
data.to_remove.steal_all ();
|
||||
data.to_build.steal_all ();
|
||||
to_add.steal_all ();
|
||||
to_remove.steal_all ();
|
||||
to_build.steal_all ();
|
||||
}
|
||||
|
||||
public void run () {
|
||||
string action = dgettext (null,"Preparing") + "...";
|
||||
spawn_in_term ({"/usr/bin/echo", action});
|
||||
progress_window.action_label.set_text (action);
|
||||
progress_window.progressbar.set_fraction (0);
|
||||
progress_window.progressbar.set_text ("");
|
||||
progress_window.cancel_button.set_visible (true);
|
||||
progress_window.close_button.set_visible (false);
|
||||
progress_window.show ();
|
||||
progress_dialog.action_label.set_text (action);
|
||||
progress_dialog.progressbar.set_fraction (0);
|
||||
progress_dialog.progressbar.set_text ("");
|
||||
progress_dialog.cancel_button.set_visible (true);
|
||||
progress_dialog.close_button.set_visible (false);
|
||||
progress_dialog.show ();
|
||||
while (Gtk.events_pending ())
|
||||
Gtk.main_iteration ();
|
||||
// run
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
if (data.to_add.size () == 0
|
||||
&& data.to_remove.size () == 0
|
||||
&& data.to_load.size () == 0
|
||||
&& data.to_build.size () != 0) {
|
||||
if (to_add.size () == 0
|
||||
&& to_remove.size () == 0
|
||||
&& to_load.size () == 0
|
||||
&& to_build.size () != 0) {
|
||||
// there only AUR packages to build so no need to prepare transaction
|
||||
on_emit_trans_prepared (err);
|
||||
} else {
|
||||
try {
|
||||
err = daemon.trans_init (data.flags);
|
||||
err = daemon.trans_init (flags);
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
@@ -279,7 +284,7 @@ namespace Pamac {
|
||||
finished (true);
|
||||
handle_error (err);
|
||||
} else {
|
||||
foreach (string name in data.to_add.get_keys ()) {
|
||||
foreach (string name in to_add.get_keys ()) {
|
||||
try {
|
||||
err = daemon.trans_add_pkg (name);
|
||||
} catch (IOError e) {
|
||||
@@ -288,7 +293,7 @@ namespace Pamac {
|
||||
if (err.str != "")
|
||||
break;
|
||||
}
|
||||
foreach (string name in data.to_remove.get_keys ()) {
|
||||
foreach (string name in to_remove.get_keys ()) {
|
||||
try {
|
||||
err = daemon.trans_remove_pkg (name);
|
||||
} catch (IOError e) {
|
||||
@@ -297,7 +302,7 @@ namespace Pamac {
|
||||
if (err.str != "")
|
||||
break;
|
||||
}
|
||||
foreach (string path in data.to_load.get_keys ()) {
|
||||
foreach (string path in to_load.get_keys ()) {
|
||||
try {
|
||||
err = daemon.trans_load_pkg (path);
|
||||
} catch (IOError e) {
|
||||
@@ -307,13 +312,11 @@ namespace Pamac {
|
||||
break;
|
||||
}
|
||||
if (err.str == "") {
|
||||
daemon.trans_prepare.begin ((obj, res) => {
|
||||
try {
|
||||
daemon.trans_prepare.end (res);
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
});
|
||||
try {
|
||||
daemon.trans_prepare ();
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
} else {
|
||||
release ();
|
||||
finished (true);
|
||||
@@ -351,7 +354,7 @@ namespace Pamac {
|
||||
string[] to_install = {};
|
||||
string[] to_reinstall = {};
|
||||
string[] to_update = {};
|
||||
string[] to_build = {};
|
||||
string[] _to_build = {};
|
||||
TreeIter iter;
|
||||
transaction_sum_dialog.top_label.set_markup ("<big><b>%s</b></big>".printf (dgettext (null, "Transaction Summary")));
|
||||
transaction_sum_dialog.sum_list.clear ();
|
||||
@@ -363,7 +366,7 @@ namespace Pamac {
|
||||
}
|
||||
foreach (UpdatesInfos pkg_info in prepared_to_add) {
|
||||
dsize += pkg_info.download_size;
|
||||
unowned Alpm.Package? local_pkg = alpm_config.handle.localdb.get_pkg (pkg_info.name);
|
||||
unowned Alpm.Package? local_pkg = handle.localdb.get_pkg (pkg_info.name);
|
||||
if (local_pkg == null) {
|
||||
to_install += "%s %s".printf (pkg_info.name, pkg_info.version);
|
||||
} else {
|
||||
@@ -376,8 +379,8 @@ namespace Pamac {
|
||||
to_downgrade += "%s %s".printf (pkg_info.name, pkg_info.version);
|
||||
}
|
||||
}
|
||||
foreach (string name in data.to_build.get_keys ())
|
||||
to_build += name;
|
||||
foreach (string name in to_build.get_keys ())
|
||||
_to_build += name;
|
||||
int len = prepared_to_remove.length;
|
||||
int i;
|
||||
if (len != 0) {
|
||||
@@ -405,16 +408,16 @@ namespace Pamac {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
len = to_build.length;
|
||||
len = _to_build.length;
|
||||
if (len != 0) {
|
||||
ret = 0;
|
||||
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
||||
0, dgettext (null, "To build") + ":",
|
||||
1, to_build[0]);
|
||||
1, _to_build[0]);
|
||||
i = 1;
|
||||
while (i < len) {
|
||||
transaction_sum_dialog.sum_list.insert_with_values (out iter, -1,
|
||||
1, to_build[i]);
|
||||
1, _to_build[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -469,30 +472,29 @@ namespace Pamac {
|
||||
}
|
||||
|
||||
public void commit () {
|
||||
daemon.trans_commit.begin ((obj, res) => {
|
||||
try {
|
||||
daemon.trans_commit.end (res);
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
});
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
try {
|
||||
daemon.trans_commit ();
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
public void build_aur_packages () {
|
||||
print ("building packages\n");
|
||||
string action = dgettext (null,"Building packages") + "...";
|
||||
spawn_in_term ({"/usr/bin/echo", "-n", action});
|
||||
progress_window.action_label.set_text (action);
|
||||
progress_window.progressbar.set_fraction (0);
|
||||
progress_window.progressbar.set_text ("");
|
||||
progress_window.cancel_button.set_visible (false);
|
||||
progress_window.close_button.set_visible (false);
|
||||
progress_window.expander.set_expanded (true);
|
||||
progress_window.width_request = 700;
|
||||
progress_dialog.action_label.set_text (action);
|
||||
progress_dialog.progressbar.set_fraction (0);
|
||||
progress_dialog.progressbar.set_text ("");
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
progress_dialog.close_button.set_visible (false);
|
||||
progress_dialog.expander.set_expanded (true);
|
||||
progress_dialog.width_request = 700;
|
||||
term.grab_focus ();
|
||||
build_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_window.progressbar.pulse);
|
||||
build_timeout_id = Timeout.add (500, (GLib.SourceFunc) progress_dialog.progressbar.pulse);
|
||||
string[] cmds = {"/usr/bin/yaourt", "-S"};
|
||||
foreach (string name in data.to_build.get_keys ())
|
||||
foreach (string name in to_build.get_keys ())
|
||||
cmds += name;
|
||||
Pid child_pid;
|
||||
spawn_in_term (cmds, out child_pid);
|
||||
@@ -538,122 +540,124 @@ namespace Pamac {
|
||||
switch (event) {
|
||||
case Event.CHECKDEPS_START:
|
||||
msg = dgettext (null, "Checking dependencies") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.FILECONFLICTS_START:
|
||||
msg = dgettext (null, "Checking file conflicts") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.RESOLVEDEPS_START:
|
||||
msg = dgettext (null, "Resolving dependencies") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.INTERCONFLICTS_START:
|
||||
msg = dgettext (null, "Checking inter-conflicts") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.ADD_START:
|
||||
progress_window.cancel_button.set_visible (false);
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
previous_filename = details[0];
|
||||
msg = dgettext (null, "Installing %s").printf (details[0]) + "...";
|
||||
progress_window.action_label.set_text (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 Event.REINSTALL_START:
|
||||
progress_window.cancel_button.set_visible (false);
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
previous_filename = details[0];
|
||||
msg = dgettext (null, "Reinstalling %s").printf (details[0]) + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
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_window.cancel_button.set_visible (false);
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
previous_filename = details[0];
|
||||
msg = dgettext (null, "Removing %s").printf (details[0]) + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
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_window.cancel_button.set_visible (false);
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
previous_filename = details[0];
|
||||
msg = dgettext (null, "Upgrading %s").printf (details[0]) + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
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_window.cancel_button.set_visible (false);
|
||||
progress_dialog.cancel_button.set_visible (false);
|
||||
previous_filename = details[0];
|
||||
msg = dgettext (null, "Downgrading %s").printf (details[0]) + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
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") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.KEYRING_START:
|
||||
progress_dialog.cancel_button.set_visible (true);
|
||||
msg = dgettext (null, "Checking keyring") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.KEY_DOWNLOAD_START:
|
||||
msg = dgettext (null, "Downloading required keys") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.LOAD_START:
|
||||
msg = dgettext (null, "Loading packages files") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.DELTA_INTEGRITY_START:
|
||||
msg = dgettext (null, "Checking delta integrity") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.DELTA_PATCHES_START:
|
||||
msg = dgettext (null, "Applying deltas") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.DELTA_PATCH_START:
|
||||
msg = dgettext (null, "Generating %s with %s").printf (details[0], details[1]) + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.DELTA_PATCH_DONE:
|
||||
msg = dgettext (null, "Generation succeeded") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.DELTA_PATCH_FAILED:
|
||||
msg = dgettext (null, "Generation failed") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.SCRIPTLET_INFO:
|
||||
progress_window.action_label.set_text (dgettext (null, "Configuring %s").printf (previous_filename) + "...");
|
||||
progress_window.expander.set_expanded (true);
|
||||
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", details[0]});
|
||||
break;
|
||||
case Event.RETRIEVE_START:
|
||||
progress_dialog.cancel_button.set_visible (true);
|
||||
msg = dgettext (null, "Downloading") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.DISKSPACE_START:
|
||||
msg = dgettext (null, "Checking available disk space") + "...";
|
||||
progress_window.action_label.set_text (msg);
|
||||
progress_dialog.action_label.set_text (msg);
|
||||
spawn_in_term ({"/usr/bin/echo", msg});
|
||||
break;
|
||||
case Event.OPTDEP_REQUIRED:
|
||||
@@ -695,11 +699,11 @@ namespace Pamac {
|
||||
string textbar = "%lu/%lu".printf (current_target, n_targets);
|
||||
if (textbar != previous_textbar) {
|
||||
previous_textbar = textbar;
|
||||
progress_window.progressbar.set_text (textbar);
|
||||
progress_dialog.progressbar.set_text (textbar);
|
||||
}
|
||||
if (fraction != previous_percent) {
|
||||
previous_percent = fraction;
|
||||
progress_window.progressbar.set_fraction (fraction);
|
||||
progress_dialog.progressbar.set_fraction (fraction);
|
||||
}
|
||||
while (Gtk.events_pending ())
|
||||
Gtk.main_iteration ();
|
||||
@@ -718,7 +722,7 @@ namespace Pamac {
|
||||
}
|
||||
if (label != previous_label) {
|
||||
previous_label = label;
|
||||
progress_window.action_label.set_text (label);
|
||||
progress_dialog.action_label.set_text (label);
|
||||
spawn_in_term ({"/usr/bin/echo", label});
|
||||
}
|
||||
}
|
||||
@@ -731,12 +735,12 @@ namespace Pamac {
|
||||
}
|
||||
if (fraction != previous_percent) {
|
||||
previous_percent = fraction;
|
||||
progress_window.progressbar.set_fraction (fraction);
|
||||
progress_dialog.progressbar.set_fraction (fraction);
|
||||
}
|
||||
|
||||
if (textbar != previous_textbar) {
|
||||
previous_textbar = textbar;
|
||||
progress_window.progressbar.set_text (textbar);
|
||||
progress_dialog.progressbar.set_text (textbar);
|
||||
}
|
||||
if (xfered == total)
|
||||
already_downloaded += total;
|
||||
@@ -758,7 +762,7 @@ namespace Pamac {
|
||||
line = dgettext (null, "Error") + ": " + msg;
|
||||
}
|
||||
if (line != null) {
|
||||
progress_window.expander.set_expanded (true);
|
||||
progress_dialog.expander.set_expanded (true);
|
||||
spawn_in_term ({"/usr/bin/echo", "-n", line});
|
||||
}
|
||||
}
|
||||
@@ -780,7 +784,7 @@ namespace Pamac {
|
||||
}
|
||||
|
||||
public void handle_error (ErrorInfos error) {
|
||||
progress_window.expander.set_expanded (true);
|
||||
progress_dialog.expander.set_expanded (true);
|
||||
spawn_in_term ({"/usr/bin/echo", "-n", error.str});
|
||||
TextIter start_iter;
|
||||
TextIter end_iter;
|
||||
@@ -805,7 +809,7 @@ namespace Pamac {
|
||||
spawn_in_term ({"/usr/bin/echo"});
|
||||
transaction_info_dialog.run ();
|
||||
transaction_info_dialog.hide ();
|
||||
progress_window.hide ();
|
||||
progress_dialog.hide ();
|
||||
transaction_info_dialog.textbuffer.get_start_iter (out start_iter);
|
||||
transaction_info_dialog.textbuffer.get_end_iter (out end_iter);
|
||||
transaction_info_dialog.textbuffer.delete (ref start_iter, ref end_iter);
|
||||
@@ -818,7 +822,7 @@ namespace Pamac {
|
||||
refresh_alpm_config ();
|
||||
if (error.str == "") {
|
||||
if (mode == Mode.UPDATER) {
|
||||
progress_window.hide ();
|
||||
progress_dialog.hide ();
|
||||
finished (false);
|
||||
} else {
|
||||
sysupgrade (0);
|
||||
@@ -835,10 +839,10 @@ namespace Pamac {
|
||||
show_warnings ();
|
||||
int ret = set_transaction_sum ();
|
||||
if (ret == 0) {
|
||||
if (data.to_add.size () == 0
|
||||
&& data.to_remove.size () == 0
|
||||
&& data.to_load.size () == 0
|
||||
&& data.to_build.size () != 0) {
|
||||
if (to_add.size () == 0
|
||||
&& to_remove.size () == 0
|
||||
&& to_load.size () == 0
|
||||
&& to_build.size () != 0) {
|
||||
// there only AUR packages to build or we update AUR packages first
|
||||
release ();
|
||||
if (transaction_sum_dialog.run () == ResponseType.OK) {
|
||||
@@ -849,7 +853,7 @@ namespace Pamac {
|
||||
on_emit_trans_committed (err);
|
||||
} else {
|
||||
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
|
||||
progress_window.hide ();
|
||||
progress_dialog.hide ();
|
||||
transaction_sum_dialog.hide ();
|
||||
finished (true);
|
||||
}
|
||||
@@ -864,7 +868,7 @@ namespace Pamac {
|
||||
commit ();
|
||||
} else {
|
||||
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction cancelled") + ".\n"});
|
||||
progress_window.hide ();
|
||||
progress_dialog.hide ();
|
||||
transaction_sum_dialog.hide ();
|
||||
release ();
|
||||
finished (true);
|
||||
@@ -875,7 +879,7 @@ namespace Pamac {
|
||||
//ErrorInfos err = ErrorInfos ();
|
||||
//err.str = dgettext (null, "Nothing to do") + "\n";
|
||||
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Nothing to do") + ".\n"});
|
||||
progress_window.hide ();
|
||||
progress_dialog.hide ();
|
||||
release ();
|
||||
clear_lists ();
|
||||
finished (false);
|
||||
@@ -890,16 +894,16 @@ namespace Pamac {
|
||||
public void on_emit_trans_committed (ErrorInfos error) {
|
||||
print ("transaction committed\n");
|
||||
if (error.str == "") {
|
||||
if (data.to_build.size () != 0) {
|
||||
if (data.to_add.size () != 0
|
||||
|| data.to_remove.size () != 0
|
||||
|| data.to_load.size () != 0) {
|
||||
if (to_build.size () != 0) {
|
||||
if (to_add.size () != 0
|
||||
|| to_remove.size () != 0
|
||||
|| to_load.size () != 0) {
|
||||
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction successfully finished") + ".\n"});
|
||||
}
|
||||
build_aur_packages ();
|
||||
} else {
|
||||
//progress_window.action_label.set_text (dgettext (null, "Transaction successfully finished"));
|
||||
//progress_window.close_button.set_visible (true);
|
||||
//progress_dialog.action_label.set_text (dgettext (null, "Transaction successfully finished"));
|
||||
//progress_dialog.close_button.set_visible (true);
|
||||
clear_lists ();
|
||||
show_warnings ();
|
||||
refresh_alpm_config ();
|
||||
@@ -913,7 +917,7 @@ namespace Pamac {
|
||||
spawn_in_term ({"/usr/bin/echo", dgettext (null, "Transaction successfully finished") + ".\n"});
|
||||
else
|
||||
spawn_in_term ({"/usr/bin/echo"});
|
||||
progress_window.hide ();
|
||||
progress_dialog.hide ();
|
||||
finished (false);
|
||||
}
|
||||
}
|
||||
@@ -929,13 +933,8 @@ namespace Pamac {
|
||||
|
||||
void on_term_child_exited (int status) {
|
||||
Source.remove (build_timeout_id);
|
||||
data.to_build.steal_all ();
|
||||
to_build.steal_all ();
|
||||
build_status = status;
|
||||
try {
|
||||
daemon.refresh_alpm_config ();
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
ErrorInfos err = ErrorInfos ();
|
||||
on_emit_trans_committed (err);
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ const string noupdate_info = _("Your system is up-to-date");
|
||||
namespace Pamac {
|
||||
[DBus (name = "org.manjaro.pamac")]
|
||||
public interface Daemon : Object {
|
||||
public abstract async void refresh (int force, bool emit_signal) throws IOError;
|
||||
public abstract void refresh (int force, bool emit_signal) throws IOError;
|
||||
public abstract UpdatesInfos[] get_updates () throws IOError;
|
||||
[DBus (no_reply = true)]
|
||||
public abstract void quit () throws IOError;
|
||||
@@ -76,7 +76,7 @@ namespace Pamac {
|
||||
item = new Gtk.MenuItem.with_label (_("Package Manager"));
|
||||
item.activate.connect (execute_manager);
|
||||
menu.append (item);
|
||||
item = new Gtk.MenuItem.with_label (_("Quit"));
|
||||
item = new Gtk.MenuItem.with_mnemonic (_("_Quit"));
|
||||
item.activate.connect (this.release);
|
||||
menu.append (item);
|
||||
menu.show_all ();
|
||||
@@ -115,13 +115,11 @@ namespace Pamac {
|
||||
|
||||
bool refresh () {
|
||||
start_daemon ();
|
||||
daemon.refresh.begin (1, false, (obj, res) => {
|
||||
try {
|
||||
daemon.refresh.end (res);
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
});
|
||||
try {
|
||||
daemon.refresh (0, false);
|
||||
} catch (IOError e) {
|
||||
stderr.printf ("IOError: %s\n", e.message);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -141,7 +139,6 @@ namespace Pamac {
|
||||
if (pamac_run == false)
|
||||
show_notification (one_update_info);
|
||||
} else {
|
||||
// workaround to use python format string
|
||||
string info = update_info.printf (updates_nb);
|
||||
this.update_icon (update_icon_name, info);
|
||||
if (pamac_run == false)
|
||||
@@ -153,10 +150,10 @@ namespace Pamac {
|
||||
|
||||
void show_notification (string info) {
|
||||
//~ notification = new Notification (_("Update Manager"));
|
||||
//~ notification.set_body (info);
|
||||
//~ Gtk.IconTheme icon_theme = Gtk.IconTheme.get_default ();
|
||||
//~ Gdk.Pixbuf icon = icon_theme.load_icon ("system-software-update", 32, 0);
|
||||
//~ notification.set_icon (icon);
|
||||
//~ notification.set_body (info);
|
||||
//~ var action = new SimpleAction ("update", null);
|
||||
//~ action.activate.connect (execute_updater);
|
||||
//~ this.add_action (action);
|
||||
@@ -235,7 +232,7 @@ namespace Pamac {
|
||||
create_menu ();
|
||||
status_icon.popup_menu.connect (menu_popup);
|
||||
|
||||
Notify.init(_("Update Manager"));
|
||||
Notify.init (_("Update Manager"));
|
||||
|
||||
refresh ();
|
||||
launch_refresh_timeout ();
|
||||
|
@@ -127,7 +127,7 @@ namespace Pamac {
|
||||
uint updates_nb = 0;
|
||||
updates_list.clear ();
|
||||
// get syncfirst updates
|
||||
UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (transaction.alpm_config);
|
||||
UpdatesInfos[] syncfirst_updates = get_syncfirst_updates (transaction.handle, transaction.syncfirst);
|
||||
if (syncfirst_updates.length != 0) {
|
||||
updates_nb = syncfirst_updates.length;
|
||||
foreach (UpdatesInfos infos in syncfirst_updates) {
|
||||
@@ -140,8 +140,7 @@ namespace Pamac {
|
||||
updates_list.insert_with_values (out iter, -1, 0, name, 1, size);
|
||||
}
|
||||
} else {
|
||||
string[] ignore_pkgs = get_ignore_pkgs (transaction.alpm_config);
|
||||
UpdatesInfos[] updates = get_repos_updates (transaction.alpm_config, ignore_pkgs);
|
||||
UpdatesInfos[] updates = get_repos_updates (transaction.handle, transaction.ignorepkg);
|
||||
foreach (UpdatesInfos infos in updates) {
|
||||
name = infos.name + " " + infos.version;
|
||||
if (infos.download_size != 0)
|
||||
@@ -153,7 +152,7 @@ namespace Pamac {
|
||||
}
|
||||
updates_nb += updates.length;
|
||||
if (pamac_config.enable_aur) {
|
||||
UpdatesInfos[] aur_updates = get_aur_updates (transaction.alpm_config, ignore_pkgs);
|
||||
UpdatesInfos[] aur_updates = get_aur_updates (transaction.handle, transaction.ignorepkg);
|
||||
updates_nb += aur_updates.length;
|
||||
foreach (UpdatesInfos infos in aur_updates) {
|
||||
name = infos.name + " " + infos.version;
|
||||
|
Reference in New Issue
Block a user