v4.0.0-beta

This commit is contained in:
guinux
2016-04-14 18:19:20 +02:00
parent f7be6e1e88
commit b59e68459b
31 changed files with 4265 additions and 3206 deletions

View File

@@ -1,30 +1,30 @@
ALPM_VALA_FLAGS = --pkg=libalpm \
--pkg=gio-2.0 \
--vapidir=../vapi \
-X -D_FILE_OFFSET_BITS=64
COMMON_VALA_FLAGS = -X -w \
--pkg=libalpm \
--pkg=gio-2.0 \
--pkg=posix \
--vapidir=./ \
--vapidir=../vapi \
-X -I../util \
-X -D_FILE_OFFSET_BITS=64 \
-X -DGETTEXT_PACKAGE="pamac" \
--target-glib=2.38
TRANSACTION_VALA_FLAGS = --pkg=json-glib-1.0 \
--pkg=libsoup-2.4 \
--pkg=gtk+-3.0 \
TRANSACTION_VALA_FLAGS = --pkg=gtk+-3.0 \
--pkg=gdk-3.0 \
--pkg=vte-2.91 \
-X -lm
COMMON_SOURCES = ../util/alpm-util.c \
common.vala \
pamac_config.vala \
alpm_config.vala \
PAMAC_LIB_FLAGS = -X -I. \
-X -L. \
-X -lpamac \
--vapidir=./ \
--pkg=pamac \
TRANSACTION_SOURCES = transaction.vala \
alpm_utils.vala \
aur.vala \
COMMON_SOURCES = common.vala \
pamac_config.vala
TRANSACTION_SOURCES = package.vala \
transaction.vala \
choose_provider_dialog.vala \
transaction_sum_dialog.vala \
transaction_info_dialog.vala \
@@ -42,7 +42,7 @@ UPDATER_GRESOURCE_FILE = ../resources/pamac.updater.gresource.xml
INSTALLER_GRESOURCE_FILE = ../resources/pamac.installer.gresource.xml
binaries: pamac-refresh pamac-daemon pamac-tray libpamac.so pamac-updater pamac-manager pamac-install
binaries: pamac-refresh pamac-daemon pamac-tray pamac-updater pamac-manager pamac-install
clean:
rm -f *.c pamac.h pamac.vapi libpamac.so pamac-refresh pamac-daemon pamac-tray pamac-updater pamac-manager pamac-install
@@ -55,7 +55,7 @@ pamac-refresh: pamac_config.vala refresh.vala
pamac_config.vala \
refresh.vala
pamac-tray: ../vapi/libalpm.vapi $(COMMON_SOURCES) tray.vala
pamac-tray: $(COMMON_SOURCES) alpm_config.vala tray.vala
valac -o pamac-tray \
$(COMMON_VALA_FLAGS) \
--pkg=gtk+-3.0 \
@@ -63,20 +63,23 @@ pamac-tray: ../vapi/libalpm.vapi $(COMMON_SOURCES) tray.vala
$(COMMON_SOURCES) \
tray.vala
pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi ../vapi/libcurl.vapi $(COMMON_SOURCES) aur.vala mirrors_config.vala daemon.vala
pamac-daemon: ../vapi/libalpm.vapi ../vapi/polkit-gobject-1.vapi ../vapi/libcurl.vapi alpm_config.vala $(COMMON_SOURCES) package.vala aur.vala mirrors_config.vala daemon.vala
valac -o pamac-daemon \
$(COMMON_VALA_FLAGS) \
$(ALPM_VALA_FLAGS) \
--pkg=polkit-gobject-1 \
--pkg=libcurl \
--pkg=json-glib-1.0 \
--pkg=libsoup-2.4 \
--thread \
alpm_config.vala \
$(COMMON_SOURCES) \
package.vala \
aur.vala \
mirrors_config.vala \
daemon.vala
libpamac.so: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) ../resources/transaction_resources.c
libpamac.so: $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PREFERENCES_SOURCES) ../resources/transaction_resources.c
valac -o libpamac.so \
-X -fPIC \
-X --shared \
@@ -91,33 +94,24 @@ libpamac.so: ../vapi/libalpm.vapi $(COMMON_SOURCES) $(TRANSACTION_SOURCES) $(PRE
$(TRANSACTION_SOURCES) \
$(PREFERENCES_SOURCES)
pamac-manager: libpamac.so choose_dep_dialog.vala history_dialog.vala transaction_info_dialog.vala ../resources/manager_resources.c ../util/alpm-util.c packages_model.vala aur_model.vala manager_window.vala manager.vala
pamac-manager: libpamac.so choose_dep_dialog.vala history_dialog.vala transaction_info_dialog.vala ../resources/manager_resources.c manager_window.vala manager.vala
valac -o pamac-manager \
$(COMMON_VALA_FLAGS) \
-X -I. \
-X -L. \
-X -lpamac \
--pkg=pamac \
$(PAMAC_LIB_FLAGS) \
--pkg=json-glib-1.0 \
--pkg=gtk+-3.0 \
--pkg=gdk-3.0 \
--gresources=$(MANAGER_GRESOURCE_FILE) \
../resources/manager_resources.c \
../util/alpm-util.c \
choose_dep_dialog.vala \
history_dialog.vala \
packages_model.vala \
aur_model.vala \
manager_window.vala \
manager.vala
pamac-updater: libpamac.so ../resources/updater_resources.c updater_window.vala updater.vala
valac -o pamac-updater \
$(COMMON_VALA_FLAGS) \
-X -I. \
-X -L. \
-X -lpamac \
--pkg=pamac \
$(PAMAC_LIB_FLAGS) \
--pkg=json-glib-1.0 \
--pkg=gtk+-3.0 \
--pkg=gdk-3.0 \
@@ -129,10 +123,7 @@ pamac-updater: libpamac.so ../resources/updater_resources.c updater_window.vala
pamac-install: libpamac.so installer.vala
valac -o pamac-install \
$(COMMON_VALA_FLAGS) \
-X -I. \
-X -L. \
-X -lpamac \
--pkg=pamac \
$(PAMAC_LIB_FLAGS) \
--pkg=json-glib-1.0 \
--pkg=gtk+-3.0 \
installer.vala

View File

@@ -1,5 +1,5 @@
/*
* pamac-vala
* alpm_config
*
* Copyright (C) 2014-2016 Guillaume Benoit <guillaume@manjaro.org>
*
@@ -18,7 +18,7 @@
*/
[Compact]
public class AlpmRepo {
class AlpmRepo {
public string name;
public Alpm.Signature.Level siglevel;
public Alpm.Signature.Level siglevel_mask;
@@ -42,68 +42,55 @@ public class AlpmRepo {
}
[Compact]
public class AlpmConfig {
public string conf_path;
public string? rootdir;
public string? dbpath;
public string? logfile;
public string? gpgdir;
public string? arch;
public double deltaratio;
public int usesyslog;
public int checkspace;
public Alpm.List<string?>? cachedirs;
public Alpm.List<string?>? hookdirs;
public Alpm.List<string?>? ignoregroups;
public Alpm.List<string?>? ignorepkgs;
public Alpm.List<string?>? noextracts;
public Alpm.List<string?>? noupgrades;
public GLib.List<string>? holdpkgs;
public GLib.List<string>? syncfirsts;
public Alpm.Signature.Level siglevel;
public Alpm.Signature.Level localfilesiglevel;
public Alpm.Signature.Level remotefilesiglevel;
public Alpm.Signature.Level siglevel_mask;
public Alpm.Signature.Level localfilesiglevel_mask;
public Alpm.Signature.Level remotefilesiglevel_mask;
public GLib.List<AlpmRepo> repo_order;
public Alpm.Handle? handle;
class AlpmConfig {
string conf_path;
string? rootdir;
string? dbpath;
string? logfile;
string? gpgdir;
string? arch;
double deltaratio;
int usesyslog;
int checkspace;
GLib.List<string> cachedirs;
GLib.List<string> hookdirs;
GLib.List<string> ignoregroups;
GLib.List<string> ignorepkgs;
GLib.List<string> noextracts;
GLib.List<string> noupgrades;
GLib.List<string> holdpkgs;
GLib.List<string> syncfirsts;
Alpm.Signature.Level siglevel;
Alpm.Signature.Level localfilesiglevel;
Alpm.Signature.Level remotefilesiglevel;
Alpm.Signature.Level siglevel_mask;
Alpm.Signature.Level localfilesiglevel_mask;
Alpm.Signature.Level remotefilesiglevel_mask;
GLib.List<AlpmRepo> repo_order;
public AlpmConfig (string path) {
conf_path = path;
reload ();
}
public unowned GLib.List<string> get_holdpkgs () {
return holdpkgs;
}
public unowned GLib.List<string> get_syncfirsts () {
return syncfirsts;
}
public void reload () {
// set default options
cachedirs = new GLib.List<string> ();
hookdirs = new GLib.List<string> ();
ignoregroups = new GLib.List<string> ();
ignorepkgs = new GLib.List<string> ();
noextracts = new GLib.List<string> ();
noupgrades = new GLib.List<string> ();
holdpkgs = new GLib.List<string> ();
syncfirsts = new GLib.List<string> ();
// free internal data of alpm lists
if (cachedirs != null) {
cachedirs.free_data ();
cachedirs = new Alpm.List<string> ();
}
if (hookdirs != null) {
hookdirs.free_data ();
hookdirs = new Alpm.List<string?> ();
}
if (ignoregroups != null) {
ignoregroups.free_data ();
ignoregroups = new Alpm.List<string> ();
}
if (ignorepkgs != null) {
ignorepkgs.free_data ();
ignorepkgs = new Alpm.List<string> ();
}
if (noextracts != null) {
noextracts.free_data ();
noextracts = new Alpm.List<string> ();
}
if (noupgrades != null) {
noupgrades.free_data ();
noupgrades = new Alpm.List<string> ();
}
usesyslog = 0;
checkspace = 0;
deltaratio = 0.7;
@@ -131,11 +118,11 @@ public class AlpmConfig {
logfile = "/var/log/pacman.log";
}
}
if (cachedirs.length == 0) {
cachedirs.add ("/var/cache/pacman/pkg/");
if (cachedirs.length () == 0) {
cachedirs.append ("/var/cache/pacman/pkg/");
}
if (hookdirs.length == 0) {
hookdirs.add ("/etc/pacman.d/hooks/");
if (hookdirs.length () == 0) {
hookdirs.append ("/etc/pacman.d/hooks/");
}
if (gpgdir == null) {
// gpgdir it is not relative to rootdir, even if
@@ -147,12 +134,12 @@ public class AlpmConfig {
}
}
public void set_handle () {
public Alpm.Handle? get_handle () {
Alpm.Errno error;
handle = Alpm.Handle.new (rootdir, dbpath, out error);
Alpm.Handle? handle = new Alpm.Handle (rootdir, dbpath, out error);
if (handle == null) {
stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf(Alpm.strerror (error)));
return;
stderr.printf ("Failed to initialize alpm library" + " (%s)\n".printf (Alpm.strerror (error)));
return null;
}
// define options
handle.logfile = logfile;
@@ -166,15 +153,24 @@ public class AlpmConfig {
remotefilesiglevel = merge_siglevel (siglevel, remotefilesiglevel, remotefilesiglevel_mask);
handle.localfilesiglevel = localfilesiglevel;
handle.remotefilesiglevel = remotefilesiglevel;
handle.cachedirs = cachedirs;
// add hook directories 1-by-1 to avoid overwriting the system directory
foreach (unowned string cachedir in cachedirs) {
handle.add_cachedir (cachedir);
}
foreach (unowned string hookdir in hookdirs) {
handle.add_hookdir (hookdir);
}
handle.ignoregroups = ignoregroups;
handle.ignorepkgs = ignorepkgs;
handle.noextracts = noextracts;
handle.noupgrades = noupgrades;
foreach (unowned string ignoregroup in ignoregroups) {
handle.add_ignoregroup (ignoregroup);
}
foreach (unowned string ignorepkg in ignorepkgs) {
handle.add_ignorepkg (ignorepkg);
}
foreach (unowned string noextract in noextracts) {
handle.add_noextract (noextract);
}
foreach (unowned string noupgrade in noupgrades) {
handle.add_noupgrade (noupgrade);
}
// register dbs
foreach (unowned AlpmRepo repo in repo_order) {
repo.siglevel = merge_siglevel (siglevel, repo.siglevel, repo.siglevel_mask);
@@ -188,9 +184,10 @@ public class AlpmConfig {
db.usage = repo.usage;
}
}
return handle;
}
public void parse_file (string path, string? section = null) {
void parse_file (string path, string? section = null) {
string? current_section = section;
var file = GLib.File.new_for_path (path);
if (file.query_exists ()) {
@@ -236,11 +233,11 @@ public class AlpmConfig {
dbpath = val;
} else if (key == "CacheDir") {
foreach (unowned string dir in val.split (" ")) {
cachedirs.add (dir);
cachedirs.append (dir);
}
} else if (key == "HookDir") {
foreach (unowned string dir in val.split (" ")) {
hookdirs.add (dir);
hookdirs.append (dir);
}
} else if (key == "LogFile") {
logfile = val;
@@ -276,19 +273,19 @@ public class AlpmConfig {
}
} else if (key == "IgnoreGroup") {
foreach (unowned string name in val.split (" ")) {
ignoregroups.add (name);
ignoregroups.append (name);
}
} else if (key == "IgnorePkg") {
foreach (unowned string name in val.split (" ")) {
ignorepkgs.add (name);
ignorepkgs.append (name);
}
} else if (key == "Noextract") {
foreach (unowned string name in val.split (" ")) {
noextracts.add (name);
noextracts.append (name);
}
} else if (key == "NoUpgrade") {
foreach (unowned string name in val.split (" ")) {
noupgrades.add (name);
noupgrades.append (name);
}
}
} else {
@@ -364,6 +361,7 @@ public class AlpmConfig {
// writing a short string to the stream
dos.put_string (new_line);
}
reload ();
} catch (GLib.Error e) {
GLib.stderr.printf("%s\n", e.message);
}
@@ -372,7 +370,7 @@ public class AlpmConfig {
}
}
public Alpm.DB.Usage define_usage (string conf_string) {
Alpm.DB.Usage define_usage (string conf_string) {
Alpm.DB.Usage usage = 0;
foreach (unowned string directive in conf_string.split(" ")) {
if (directive == "Sync") {
@@ -390,7 +388,7 @@ public class AlpmConfig {
return usage;
}
public void process_siglevel (string conf_string, ref Alpm.Signature.Level siglevel, ref Alpm.Signature.Level siglevel_mask) {
void process_siglevel (string conf_string, ref Alpm.Signature.Level siglevel, ref Alpm.Signature.Level siglevel_mask) {
foreach (unowned string directive in conf_string.split(" ")) {
bool affect_package = false;
bool affect_database = false;
@@ -458,7 +456,7 @@ public class AlpmConfig {
siglevel &= ~Alpm.Signature.Level.USE_DEFAULT;
}
public Alpm.Signature.Level merge_siglevel(Alpm.Signature.Level sigbase, Alpm.Signature.Level sigover, Alpm.Signature.Level sigmask) {
Alpm.Signature.Level merge_siglevel(Alpm.Signature.Level sigbase, Alpm.Signature.Level sigover, Alpm.Signature.Level sigmask) {
return (sigmask != 0) ? (sigover & sigmask) | (sigbase & ~sigmask) : sigover;
}
}

View File

@@ -25,107 +25,66 @@ namespace AUR {
const string rpc_multiinfo = "&type=info";
const string rpc_multiinfo_arg = "&arg[]=";
public Json.Array search (string[] needles) {
var prev_inter = new Json.Array ();
string uri = rpc_url + rpc_search + Uri.escape_string (needles[0]);
Json.Array rpc_query (string uri) {
var results = new Json.Array ();
var session = new Soup.Session ();
// set a 15 seconds timeout because it is also the dbus daemon timeout
session.timeout = 15;
var message = new Soup.Message ("GET", uri);
var parser = new Json.Parser ();
session.send_message (message);
try {
parser.load_from_data ((string) message.response_body.flatten ().data, -1);
} catch (Error e) {
print (e.message);
critical (e.message);
}
unowned Json.Node? root = parser.get_root ();
if (root != null) {
if (root.get_object ().get_string_member ("type") == "error") {
stderr.printf ("Failed to search %s from AUR\n", needles[0]);
} else {
prev_inter = root.get_object ().get_array_member ("results");
}
}
int needles_length = needles.length;
if (needles_length == 1) {
return prev_inter;
}
int i = 1;
var inter = new Json.Array ();
var found = new Json.Array ();
while (i < needles_length) {
inter = new Json.Array ();
uri = rpc_url + rpc_search + Uri.escape_string (needles[i]);
message = new Soup.Message ("GET", uri);
session.send_message (message);
try {
parser.load_from_data ((string) message.response_body.flatten ().data, -1);
} catch (Error e) {
print (e.message);
}
root = parser.get_root ();
if (root != null) {
if (root.get_object ().get_string_member ("type") == "error") {
stderr.printf ("Failed to search %s from AUR\n", needles[i]);
} else {
found = root.get_object ().get_array_member ("results");
uint j = 0;
uint k;
uint found_length = found.get_length ();
while (j < found_length) {
unowned Json.Node found_node = found.get_element (j);
k = 0;
uint prev_inter_length = prev_inter.get_length ();
while (k < prev_inter_length) {
unowned Json.Node prev_inter_node = prev_inter.get_element (k);
if (strcmp (found_node.get_object ().get_string_member ("Name"),
prev_inter_node.get_object ().get_string_member ("Name")) == 0) {
inter.add_element (prev_inter_node);
prev_inter.remove_element (k);
break;
}
k++;
}
j++;
}
}
}
if (i != (needles_length -1)) {
prev_inter = inter;
}
i++;
}
return inter;
}
public Json.Array multiinfo (string[] pkgnames) {
Json.Array results = new Json.Array ();
if (pkgnames.length == 0) {
return results;
}
var builder = new StringBuilder ();
builder.append (rpc_url);
builder.append (rpc_multiinfo);
foreach (string pkgname in pkgnames) {
builder.append (rpc_multiinfo_arg);
builder.append (Uri.escape_string (pkgname));
}
var session = new Soup.Session ();
var message = new Soup.Message ("GET", builder.str);
session.send_message (message);
var parser = new Json.Parser ();
try {
parser.load_from_data ((string) message.response_body.flatten ().data, -1);
} catch (Error e) {
print (e.message);
}
unowned Json.Node? root = parser.get_root ();
if (root != null) {
if (root.get_object ().get_string_member ("type") == "error") {
stderr.printf ("Failed to multiinfo %s from AUR\n", builder.str);
critical ("Failed to query %s from AUR", uri);
} else {
results = root.get_object ().get_array_member ("results");
}
}
return results;
}
public async Json.Array search (string[] needles) {
if (needles.length == 0) {
return new Json.Array ();
} else if (needles.length == 1) {
return rpc_query (rpc_url + rpc_search + Uri.escape_string (needles[0]));
} else {
var inter = new Json.Array ();
var prev_inter = new Json.Array ();
foreach (unowned string needle in needles) {
inter = new Json.Array ();
var found = rpc_query (rpc_url + rpc_search + Uri.escape_string (needle));
prev_inter.foreach_element ((prev_inter_array, prev_inter_index, prev_inter_node) => {
found.foreach_element ((found_array, found_index, found_node) => {
if (strcmp (prev_inter_node.get_object ().get_string_member ("Name"),
found_node.get_object ().get_string_member ("Name")) == 0) {
inter.add_element (prev_inter_node);
}
});
});
prev_inter = (owned) inter;
}
return inter;
}
}
public async Json.Array multiinfo (string[] pkgnames) {
if (pkgnames.length == 0) {
return new Json.Array ();
}
var builder = new StringBuilder ();
builder.append (rpc_url);
builder.append (rpc_multiinfo);
foreach (unowned string pkgname in pkgnames) {
builder.append (rpc_multiinfo_arg);
builder.append (Uri.escape_string (pkgname));
}
return rpc_query (builder.str);
}
}

View File

@@ -32,17 +32,17 @@ namespace Pamac {
public ChooseDependenciesDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0);
deps_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
deps_list = new Gtk.ListStore (2, typeof (bool), typeof (string));
treeview.set_model (deps_list);
}
[GtkCallback]
void on_renderertoggle_toggled (string path) {
Gtk.TreeIter iter;
GLib.Value selected;
bool selected;
if (deps_list.get_iter_from_string (out iter, path)) {;
deps_list.get_value (iter, 0, out selected);
deps_list.set_value (iter, 0, !((bool) selected));
deps_list.get (iter, 0, out selected);
deps_list.set (iter, 0, !selected);
}
}
}

View File

@@ -18,17 +18,26 @@
*/
namespace Pamac {
public struct PackageInfos {
public struct UpdateInfos {
public string name;
public string version;
public string db_name;
public string old_version;
public string new_version;
public string repo;
public uint64 download_size;
}
public struct TransactionSummary {
public UpdateInfos[] to_install;
public UpdateInfos[] to_upgrade;
public UpdateInfos[] to_downgrade;
public UpdateInfos[] to_reinstall;
public UpdateInfos[] to_remove;
}
public struct Updates {
public bool is_syncfirst;
public PackageInfos[] repos_updates;
public PackageInfos[] aur_updates;
public UpdateInfos[] repos_updates;
public UpdateInfos[] aur_updates;
}
public struct ErrorInfos {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -18,13 +18,32 @@
*/
namespace Pamac {
[Compact]
public class MirrorsConfig {
public string conf_path;
public string mirrorlists_dir;
public string choosen_generation_method;
public string choosen_country;
public GLib.List<string> countrys;
class MirrorsConfig {
string conf_path;
GLib.List<string> _countrys ;
public string mirrorlists_dir { get; private set; }
public string choosen_generation_method { get; private set; }
public string choosen_country { get; private set; }
public unowned GLib.List<string> countrys {
get {
try {
var directory = GLib.File.new_for_path (mirrorlists_dir);
var enumerator = directory.enumerate_children (FileAttribute.STANDARD_NAME, 0);
FileInfo file_info;
_countrys = new GLib.List<string> ();
while ((file_info = enumerator.next_file ()) != null) {
_countrys.append(file_info.get_name ());
}
_countrys.sort (strcmp);
} catch (Error e) {
stderr.printf ("%s\n", e.message);
}
return _countrys;
}
}
public MirrorsConfig (string path) {
conf_path = path;
@@ -39,22 +58,7 @@ namespace Pamac {
parse_file (conf_path);
}
public void get_countrys () {
try {
var directory = GLib.File.new_for_path (mirrorlists_dir);
var enumerator = directory.enumerate_children (FileAttribute.STANDARD_NAME, 0);
FileInfo file_info;
countrys = new GLib.List<string> ();
while ((file_info = enumerator.next_file ()) != null) {
countrys.append(file_info.get_name ());
}
countrys.sort (strcmp);
} catch (Error e) {
stderr.printf ("%s\n", e.message);
}
}
public void parse_file (string path) {
void parse_file (string path) {
var file = GLib.File.new_for_path (path);
if (file.query_exists ()) {
try {

82
src/package.vala Normal file
View File

@@ -0,0 +1,82 @@
/*
* pamac-vala
*
* Copyright (C) 2014-2016 Guillaume Benoit <guillaume@manjaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a get of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Pamac {
public struct AlpmPackage {
public string name;
public string version;
public string desc;
public string repo;
public uint64 size;
public uint origin;
}
public struct AlpmPackageDetails {
public string name;
public string version;
public string desc;
public string repo;
public string url;
public string packager;
public string builddate;
public string installdate;
public string reason;
public string has_signature;
public string[] licenses;
public string[] depends;
public string[] optdepends;
public string[] requiredby;
public string[] optionalfor;
public string[] provides;
public string[] replaces;
public string[] conflicts;
public string[] groups;
public string[] backups;
public string[] files;
}
public struct AURPackage {
public string name;
public string version;
public string desc;
public double popularity;
}
public struct AURPackageDetails {
public string name;
public string version;
public string desc;
public double popularity;
public string packagebase;
public string url;
public string maintainer;
public int64 firstsubmitted;
public int64 lastmodified;
public int64 outofdate;
public int64 numvotes;
public string[] licenses;
public string[] depends;
public string[] makedepends;
public string[] checkdepends;
public string[] optdepends;
public string[] provides;
public string[] replaces;
public string[] conflicts;
}
}

View File

@@ -18,43 +18,48 @@
*/
namespace Pamac {
[Compact]
public class Config {
public string conf_path;
public bool recurse;
public uint64 refresh_period;
public bool no_update_hide_icon;
public bool enable_aur;
public bool search_aur;
public bool check_aur_updates;
public bool no_confirm_build;
public HashTable<string,string> environment_variables;
class Config {
string conf_path;
HashTable<string,string> _environment_variables;
public bool recurse { get; private set; }
public uint64 refresh_period { get; private set; }
public bool no_update_hide_icon { get; private set; }
public bool enable_aur { get; private set; }
public bool search_aur { get; private set; }
public bool check_aur_updates { get; private set; }
public bool no_confirm_build { get; private set; }
public unowned HashTable<string,string> environment_variables {
get {
return _environment_variables;
}
}
public Config (string path) {
conf_path = path;
//get environment variables
environment_variables = new HashTable<string,string> (str_hash, str_equal);
_environment_variables = new HashTable<string,string> (str_hash, str_equal);
var utsname = Posix.utsname();
environment_variables.insert ("HTTP_USER_AGENT", "pamac (%s %s)".printf (utsname.sysname, utsname.machine));
_environment_variables.insert ("HTTP_USER_AGENT", "pamac (%s %s)".printf (utsname.sysname, utsname.machine));
unowned string? variable = Environment.get_variable ("http_proxy");
if (variable != null) {
environment_variables.insert ("http_proxy", variable);
_environment_variables.insert ("http_proxy", variable);
}
variable = Environment.get_variable ("https_proxy");
if (variable != null) {
environment_variables.insert ("https_proxy", variable);
_environment_variables.insert ("https_proxy", variable);
}
variable = Environment.get_variable ("ftp_proxy");
if (variable != null) {
environment_variables.insert ("ftp_proxy", variable);
_environment_variables.insert ("ftp_proxy", variable);
}
variable = Environment.get_variable ("socks_proxy");
if (variable != null) {
environment_variables.insert ("socks_proxy", variable);
_environment_variables.insert ("socks_proxy", variable);
}
variable = Environment.get_variable ("no_proxy");
if (variable != null) {
environment_variables.insert ("no_proxy", variable);
_environment_variables.insert ("no_proxy", variable);
}
// set default option
refresh_period = 6;
@@ -72,7 +77,7 @@ namespace Pamac {
parse_file (conf_path);
}
public void parse_file (string path) {
void parse_file (string path) {
var file = GLib.File.new_for_path (path);
if (file.query_exists ()) {
try {

View File

@@ -37,8 +37,6 @@ namespace Pamac {
[GtkChild]
Gtk.Box ignorepkgs_box;
[GtkChild]
Gtk.ListStore ignorepkgs_liststore;
[GtkChild]
Gtk.TreeView ignorepkgs_treeview;
[GtkChild]
Gtk.Box mirrors_config_box;
@@ -59,6 +57,7 @@ namespace Pamac {
[GtkChild]
Gtk.CheckButton no_confirm_build_checkbutton;
Gtk.ListStore ignorepkgs_liststore;
Transaction transaction;
uint64 previous_refresh_period;
@@ -67,9 +66,9 @@ namespace Pamac {
this.transaction = transaction;
refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":");
remove_unrequired_deps_button.active = transaction.pamac_config.recurse;
check_space_button.active = (transaction.alpm_utils.get_checkspace () == 1);
if (transaction.pamac_config.refresh_period == 0) {
remove_unrequired_deps_button.active = transaction.recurse;
check_space_button.active = transaction.get_checkspace ();
if (transaction.refresh_period == 0) {
check_updates_button.active = false;
refresh_period_label.sensitive = false;
// set default value
@@ -80,15 +79,16 @@ namespace Pamac {
ignorepkgs_box.sensitive = false;
} else {
check_updates_button.active = true;
refresh_period_spin_button.value = transaction.pamac_config.refresh_period;
previous_refresh_period = transaction.pamac_config.refresh_period;
refresh_period_spin_button.value = transaction.refresh_period;
previous_refresh_period = transaction.refresh_period;
}
no_update_hide_icon_checkbutton.active = transaction.pamac_config.no_update_hide_icon;
no_update_hide_icon_checkbutton.active = transaction.no_update_hide_icon;
// populate ignorepkgs_liststore
Gtk.TreeIter iter;
foreach (unowned string ignorepkg in transaction.alpm_utils.get_ignorepkgs ()) {
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, ignorepkg);
ignorepkgs_liststore = new Gtk.ListStore (1, typeof (string));
ignorepkgs_treeview.set_model (ignorepkgs_liststore);
foreach (unowned string ignorepkg in transaction.get_ignorepkgs ()) {
ignorepkgs_liststore.insert_with_values (null, -1, 0, ignorepkg);
}
remove_unrequired_deps_button.state_set.connect (on_remove_unrequired_deps_button_state_set);
check_space_button.state_set.connect (on_check_space_button_state_set);
@@ -98,15 +98,14 @@ namespace Pamac {
no_update_hide_icon_checkbutton.toggled.connect (on_no_update_hide_icon_checkbutton_toggled);
transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished);
unowned Alpm.Package? pkg = Alpm.find_satisfier (transaction.alpm_utils.get_installed_pkgs (), "pacman-mirrorlist");
if (pkg == null) {
AlpmPackage pkg = transaction.find_installed_satisfier ("pacman-mirrorlist");
if (pkg.name == "") {
mirrors_config_box.visible = false;
} else {
var mirrors_config = new MirrorsConfig ("/etc/pacman-mirrors.conf");
mirrors_country_comboboxtext.append_text (dgettext (null, "Worldwide"));
mirrors_country_comboboxtext.active = 0;
int index = 1;
mirrors_config.get_countrys ();
foreach (unowned string country in mirrors_config.countrys) {
mirrors_country_comboboxtext.append_text (country);
if (country == mirrors_config.choosen_country) {
@@ -126,17 +125,17 @@ namespace Pamac {
transaction.write_mirrors_config_finished.connect (on_write_mirrors_config_finished);
}
pkg = Alpm.find_satisfier (transaction.alpm_utils.get_installed_pkgs (), "yaourt");
if (pkg == null) {
pkg = transaction.find_installed_satisfier ("yaourt");
if (pkg.name == "") {
aur_config_box.visible = false;
} else {
enable_aur_button.active = transaction.pamac_config.enable_aur;
search_aur_checkbutton.active = transaction.pamac_config.search_aur;
search_aur_checkbutton.sensitive = transaction.pamac_config.enable_aur;
check_aur_updates_checkbutton.active = transaction.pamac_config.check_aur_updates;
check_aur_updates_checkbutton.sensitive = transaction.pamac_config.enable_aur;
no_confirm_build_checkbutton.active = transaction.pamac_config.no_confirm_build;
no_confirm_build_checkbutton.sensitive = transaction.pamac_config.enable_aur;
enable_aur_button.active = transaction.enable_aur;
search_aur_checkbutton.active = transaction.search_aur;
search_aur_checkbutton.sensitive = transaction.enable_aur;
check_aur_updates_checkbutton.active = transaction.check_aur_updates;
check_aur_updates_checkbutton.sensitive = transaction.enable_aur;
no_confirm_build_checkbutton.active = transaction.no_confirm_build;
no_confirm_build_checkbutton.sensitive = transaction.enable_aur;
enable_aur_button.state_set.connect (on_enable_aur_button_state_set);
search_aur_checkbutton.toggled.connect (on_search_aur_checkbutton_toggled);
check_aur_updates_checkbutton.toggled.connect (on_check_aur_updates_checkbutton_toggled);
@@ -248,40 +247,45 @@ namespace Pamac {
[GtkCallback]
void on_add_ignorepkgs_button_clicked () {
var choose_ignorepkgs_dialog = new ChooseIgnorepkgsDialog (this);
foreach (var pkg in transaction.alpm_utils.get_installed_pkgs ()) {
Gtk.TreeIter iter;
if (transaction.alpm_utils.get_ignorepkgs ().find_str (pkg.name) == null) {
choose_ignorepkgs_dialog.pkgs_list.insert_with_values (out iter, -1, 0, false, 1, pkg.name);
} else {
choose_ignorepkgs_dialog.pkgs_list.insert_with_values (out iter, -1, 0, true, 1, pkg.name);
}
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
if (choose_ignorepkgs_dialog.run () == Gtk.ResponseType.OK) {
var ignorepkg_string = new StringBuilder ();
choose_ignorepkgs_dialog.pkgs_list.foreach ((model, path, iter) => {
GLib.Value val;
// get value at column 0 to know if it is selected
choose_ignorepkgs_dialog.pkgs_list.get_value (iter, 0, out val);
if ((bool) val) {
// get value at column 1 to get the pkg name
choose_ignorepkgs_dialog.pkgs_list.get_value (iter, 1, out val);
if (ignorepkg_string.len != 0) {
ignorepkg_string.append (" ");
}
ignorepkg_string.append ((string) val);
transaction.get_installed_pkgs.begin ((obj, res) => {
var pkgs = transaction.get_installed_pkgs.end (res);
foreach (unowned AlpmPackage pkg in pkgs) {
if (pkg.name in transaction.get_ignorepkgs ()) {
choose_ignorepkgs_dialog.pkgs_list.insert_with_values (null, -1, 0, true, 1, pkg.name);
} else {
choose_ignorepkgs_dialog.pkgs_list.insert_with_values (null, -1, 0, false, 1, pkg.name);
}
return false;
});
if (ignorepkg_string.len != 0) {
}
this.get_window ().set_cursor (null);
if (choose_ignorepkgs_dialog.run () == Gtk.ResponseType.OK) {
var ignorepkg_string = new StringBuilder ();
choose_ignorepkgs_dialog.pkgs_list.foreach ((model, path, iter) => {
GLib.Value val;
// get value at column 0 to know if it is selected
model.get_value (iter, 0, out val);
if ((bool) val) {
// get value at column 1 to get the pkg name
model.get_value (iter, 1, out val);
if (ignorepkg_string.len != 0) {
ignorepkg_string.append (" ");
}
ignorepkg_string.append ((string) val);
}
return false;
});
var new_alpm_conf = new HashTable<string,Variant> (str_hash, str_equal);
new_alpm_conf.insert ("IgnorePkg", new Variant.string (ignorepkg_string.str));
transaction.start_write_alpm_config (new_alpm_conf);
}
}
choose_ignorepkgs_dialog.destroy ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
choose_ignorepkgs_dialog.destroy ();
while (Gtk.events_pending ()) {
Gtk.main_iteration ();
}
});
}
[GtkCallback]
@@ -293,7 +297,7 @@ namespace Pamac {
var ignorepkg_string = new StringBuilder ();
ignorepkgs_liststore.foreach ((model, path, iter) => {
GLib.Value name;
ignorepkgs_liststore.get_value (iter, 0, out name);
model.get_value (iter, 0, out name);
if (ignorepkg_string.len != 0) {
ignorepkg_string.append (" ");
}
@@ -303,16 +307,15 @@ namespace Pamac {
var new_alpm_conf = new HashTable<string,Variant> (str_hash, str_equal);
new_alpm_conf.insert ("IgnorePkg", new Variant.string (ignorepkg_string.str));
transaction.start_write_alpm_config (new_alpm_conf);
}
}
void on_write_alpm_config_finished (bool checkspace) {
check_space_button.state = checkspace;
// re-populate ignorepkgs_liststore
Gtk.TreeIter iter;
ignorepkgs_liststore.clear ();
foreach (unowned string ignorepkg in transaction.alpm_utils.get_ignorepkgs ()) {
ignorepkgs_liststore.insert_with_values (out iter, -1, 0, ignorepkg);
foreach (unowned string ignorepkg in transaction.get_ignorepkgs ()) {
ignorepkgs_liststore.insert_with_values (null, -1, 0, ignorepkg);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -34,7 +34,7 @@ namespace Pamac {
public TransactionSumDialog (Gtk.ApplicationWindow? window) {
Object (transient_for: window, use_header_bar: 0);
sum_list = new Gtk.ListStore (2, typeof (string), typeof (string));
sum_list = new Gtk.ListStore (4, typeof (string), typeof (string), typeof (string), typeof (string));
treeview.set_model (sum_list);
}
}

View File

@@ -27,6 +27,7 @@ const string noupdate_info = _("Your system is up-to-date");
namespace Pamac {
[DBus (name = "org.manjaro.pamac")]
interface Daemon : Object {
public abstract string get_lockfile () throws IOError;
public abstract void start_refresh (bool force) throws IOError;
public abstract void start_get_updates (bool check_aur_updates) throws IOError;
[DBus (no_reply = true)]
@@ -320,10 +321,14 @@ namespace Pamac {
Notify.init (_("Update Manager"));
var alpm_config = new AlpmConfig ("/etc/pacman.conf");
alpm_config.set_handle ();
lockfile = GLib.File.new_for_path (alpm_config.handle.lockfile);
start_daemon ();
try {
lockfile = GLib.File.new_for_path (daemon.get_lockfile ());
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
//try standard lock file
lockfile = GLib.File.new_for_path ("var/lib/pacman/db.lck");
}
Timeout.add (200, check_pacman_running);
start_refresh ();
launch_refresh_timeout (pamac_config.refresh_period);

View File

@@ -25,7 +25,7 @@ namespace Pamac {
[GtkChild]
Gtk.Label top_label;
[GtkChild]
Gtk.Notebook notebook;
Gtk.StackSwitcher stackswitcher;
[GtkChild]
Gtk.ScrolledWindow repos_scrolledwindow;
[GtkChild]
@@ -51,10 +51,10 @@ namespace Pamac {
public UpdaterWindow (Gtk.Application application) {
Object (application: application);
bottom_label.set_visible (false);
apply_button.set_sensitive (false);
notebook.set_show_tabs (false);
aur_scrolledwindow.set_visible (false);
bottom_label.visible = false;
apply_button.sensitive = false;
stackswitcher.visible = false;
aur_scrolledwindow.visible = false;
Timeout.add (100, populate_window);
}
@@ -62,9 +62,9 @@ namespace Pamac {
bool populate_window () {
this.get_window ().set_cursor (new Gdk.Cursor.for_display (Gdk.Display.get_default (), Gdk.CursorType.WATCH));
repos_updates_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
repos_updates_list = new Gtk.ListStore (6, typeof (bool), typeof (string), typeof (string), typeof (string),typeof (string), typeof (string));
repos_updates_treeview.set_model (repos_updates_list);
aur_updates_list = new Gtk.ListStore (2, typeof (bool), typeof (string));
aur_updates_list = new Gtk.ListStore (3, typeof (bool), typeof (string), typeof (string));
aur_updates_treeview.set_model (aur_updates_list);
transaction = new Transaction (this as Gtk.ApplicationWindow);
@@ -80,31 +80,29 @@ namespace Pamac {
void set_apply_button_sensitive () {
bool sensitive = false;
repos_updates_list.foreach ((model, path, iter) => {
GLib.Value selected;
repos_updates_list.get_value (iter, 0, out selected);
sensitive = (bool) selected;
bool selected;
repos_updates_list.get (iter, 0, out selected);
sensitive = selected;
return sensitive;
});
if (!sensitive) {
aur_updates_list.foreach ((model, path, iter) => {
GLib.Value selected;
aur_updates_list.get_value (iter, 0, out selected);
sensitive = (bool) selected;
bool selected;
aur_updates_list.get (iter, 0, out selected);
sensitive = selected;
return sensitive;
});
}
apply_button.set_sensitive (sensitive);
apply_button.sensitive = sensitive;
}
[GtkCallback]
void on_repos_select_update_toggled (string path) {
Gtk.TreePath treepath = new Gtk.TreePath.from_string (path);
Gtk.TreeIter iter;
GLib.Value name_string;
string pkgname;
repos_updates_list.get_iter (out iter, treepath);
repos_updates_list.get_value (iter, 1, out name_string);
// string has the form "pkgname pkgversion"
string pkgname = name_string.get_string ().split (" ", 2)[0];
repos_updates_list.get (iter, 1, out pkgname);
if (repos_select_update.active) {
repos_updates_list.set (iter, 0, false);
transaction.temporary_ignorepkgs.add (pkgname);
@@ -119,11 +117,9 @@ namespace Pamac {
void on_aur_select_update_toggled (string path) {
Gtk.TreePath treepath = new Gtk.TreePath.from_string (path);
Gtk.TreeIter iter;
GLib.Value name_string;
string pkgname;
aur_updates_list.get_iter (out iter, treepath);
aur_updates_list.get_value (iter, 1, out name_string);
// string has the form "pkgname pkgversion"
string pkgname = name_string.get_string ().split (" ", 2)[0];
aur_updates_list.get (iter, 1, out pkgname);
if (aur_select_update.active) {
aur_updates_list.set (iter, 0, false);
transaction.temporary_ignorepkgs.add (pkgname);
@@ -166,34 +162,32 @@ namespace Pamac {
void on_get_updates_finished (Updates updates) {
top_label.set_markup ("");
repos_updates_list.clear ();
notebook.set_show_tabs (false);
repos_scrolledwindow.set_visible (true);
stackswitcher.visible = false;
repos_scrolledwindow.visible = true;
aur_updates_list.clear ();
aur_scrolledwindow.set_visible (false);
bottom_label.set_visible (false);
Gtk.TreeIter iter;
aur_scrolledwindow.visible = false;
bottom_label.visible = false;
uint64 dsize = 0;
uint repos_updates_nb = 0;
uint aur_updates_nb = 0;
foreach (unowned PackageInfos infos in updates.repos_updates) {
string name = infos.name + " " + infos.version;
foreach (unowned UpdateInfos infos in updates.repos_updates) {
string size = infos.download_size != 0 ? format_size (infos.download_size) : "";
dsize += infos.download_size;
repos_updates_nb++;
if (infos.name in transaction.temporary_ignorepkgs) {
repos_updates_list.insert_with_values (out iter, -1, 0, false, 1, name, 2, size);
} else {
repos_updates_list.insert_with_values (out iter, -1, 0, true, 1, name, 2, size);
}
repos_updates_list.insert_with_values (null, -1,
0, !transaction.temporary_ignorepkgs.contains (infos.name),
1, infos.name,
2, infos.new_version,
3, "(%s)".printf (infos.old_version),
4, infos.repo,
5, size);
}
foreach (unowned PackageInfos infos in updates.aur_updates) {
string name = infos.name + " " + infos.version;
foreach (unowned UpdateInfos infos in updates.aur_updates) {
aur_updates_nb++;
if (infos.name in transaction.temporary_ignorepkgs) {
aur_updates_list.insert_with_values (out iter, -1, 0, false, 1, name);
} else {
aur_updates_list.insert_with_values (out iter, -1, 0, true, 1, name);
}
aur_updates_list.insert_with_values (null, -1,
0, !transaction.temporary_ignorepkgs.contains (infos.name),
1, infos.name,
2, "%s\t (%s)".printf (infos.new_version, infos.old_version));
}
uint updates_nb = repos_updates_nb + aur_updates_nb;
if (updates_nb == 0) {
@@ -204,16 +198,16 @@ namespace Pamac {
set_apply_button_sensitive ();
if (dsize != 0) {
bottom_label.set_markup("<b>%s: %s</b>".printf (dgettext (null, "Total download size"), format_size(dsize)));
bottom_label.set_visible (true);
bottom_label.visible = true;
} else {
bottom_label.set_visible (false);
bottom_label.visible = false;
}
if (aur_updates_nb != 0) {
aur_scrolledwindow.set_visible (true);
aur_scrolledwindow.visible = true;
if (repos_updates_nb == 0) {
repos_scrolledwindow.set_visible (false);
repos_scrolledwindow.visible = false;
}
notebook.set_show_tabs (true);
stackswitcher.visible = true;
}
this.get_window ().set_cursor (null);
}