[mirrors_config] re-enable 'pacman-mirrorlist' support
- see also: https://github.com/manjaro/pamac/issues/258 - this is only needed for Archbased Distros like Antergos
This commit is contained in:
parent
eb9cfd0aaa
commit
71edf7b773
@ -19,14 +19,17 @@
|
|||||||
|
|
||||||
namespace Pamac {
|
namespace Pamac {
|
||||||
class MirrorsConfig {
|
class MirrorsConfig {
|
||||||
|
AlpmPackage pkg = transaction.find_installed_satisfier ("pacman-mirrors");
|
||||||
string conf_path;
|
string conf_path;
|
||||||
GLib.List<string> _countries ;
|
GLib.List<string> _countries ;
|
||||||
|
|
||||||
|
public string mirrorlists_dir { get; private set; }
|
||||||
public string choosen_generation_method { get; private set; }
|
public string choosen_generation_method { get; private set; }
|
||||||
public string choosen_country { get; private set; }
|
public string choosen_country { get; private set; }
|
||||||
public unowned GLib.List<string> countries {
|
public unowned GLib.List<string> countries {
|
||||||
get {
|
get {
|
||||||
try {
|
try {
|
||||||
|
if (pkg != "") {
|
||||||
string countries_str;
|
string countries_str;
|
||||||
int status;
|
int status;
|
||||||
Process.spawn_command_line_sync ("pacman-mirrors -l",
|
Process.spawn_command_line_sync ("pacman-mirrors -l",
|
||||||
@ -39,6 +42,16 @@ namespace Pamac {
|
|||||||
_countries.append (country);
|
_countries.append (country);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
var directory = GLib.File.new_for_path (mirrorlists_dir);
|
||||||
|
var enumerator = directory.enumerate_children (FileAttribute.STANDARD_NAME, 0);
|
||||||
|
FileInfo file_info;
|
||||||
|
_countries = new GLib.List<string> ();
|
||||||
|
while ((file_info = enumerator.next_file ()) != null) {
|
||||||
|
_countries.append(file_info.get_name ());
|
||||||
|
}
|
||||||
|
_countries.sort (strcmp);
|
||||||
|
}
|
||||||
} catch (SpawnError e) {
|
} catch (SpawnError e) {
|
||||||
stdout.printf ("Error: %s\n", e.message);
|
stdout.printf ("Error: %s\n", e.message);
|
||||||
}
|
}
|
||||||
@ -47,6 +60,28 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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> countries {
|
||||||
|
get {
|
||||||
|
try {
|
||||||
|
var directory = GLib.File.new_for_path (mirrorlists_dir);
|
||||||
|
var enumerator = directory.enumerate_children (FileAttribute.STANDARD_NAME, 0);
|
||||||
|
FileInfo file_info;
|
||||||
|
_countries = new GLib.List<string> ();
|
||||||
|
while ((file_info = enumerator.next_file ()) != null) {
|
||||||
|
_countries.append(file_info.get_name ());
|
||||||
|
}
|
||||||
|
_countries.sort (strcmp);
|
||||||
|
} catch (Error e) {
|
||||||
|
stderr.printf ("%s\n", e.message);
|
||||||
|
}
|
||||||
|
return _countries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public MirrorsConfig (string path) {
|
public MirrorsConfig (string path) {
|
||||||
conf_path = path;
|
conf_path = path;
|
||||||
reload ();
|
reload ();
|
||||||
@ -56,6 +91,7 @@ namespace Pamac {
|
|||||||
// set default options
|
// set default options
|
||||||
choosen_generation_method = "rank";
|
choosen_generation_method = "rank";
|
||||||
choosen_country = "ALL";
|
choosen_country = "ALL";
|
||||||
|
mirrorlists_dir = "/etc/pacman.d/mirrors";
|
||||||
parse_file (conf_path);
|
parse_file (conf_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,8 @@ namespace Pamac {
|
|||||||
transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished);
|
transaction.write_pamac_config_finished.connect (on_write_pamac_config_finished);
|
||||||
|
|
||||||
AlpmPackage pkg = transaction.find_installed_satisfier ("pacman-mirrors");
|
AlpmPackage pkg = transaction.find_installed_satisfier ("pacman-mirrors");
|
||||||
if (pkg.name == "") {
|
AlpmPackage pkg_ml = transaction.find_installed_satisfier ("pacman-mirrorlist");
|
||||||
|
if (pkg.name == "" || pkg_ml.name == "") {
|
||||||
mirrors_config_box.visible = false;
|
mirrors_config_box.visible = false;
|
||||||
} else {
|
} else {
|
||||||
var mirrors_config = new MirrorsConfig ("/etc/pacman-mirrors.conf");
|
var mirrors_config = new MirrorsConfig ("/etc/pacman-mirrors.conf");
|
||||||
|
Loading…
Reference in New Issue
Block a user