forked from cromer/pamac-classic
add new pacman-mirrors support
This commit is contained in:
@@ -20,27 +20,29 @@
|
||||
namespace Pamac {
|
||||
class MirrorsConfig {
|
||||
string conf_path;
|
||||
GLib.List<string> _countrys ;
|
||||
GLib.List<string> _countries ;
|
||||
|
||||
|
||||
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 {
|
||||
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;
|
||||
_countrys = new GLib.List<string> ();
|
||||
while ((file_info = enumerator.next_file ()) != null) {
|
||||
_countrys.append(file_info.get_name ());
|
||||
string countries_str;
|
||||
int status;
|
||||
Process.spawn_command_line_sync ("pacman-mirrors -l",
|
||||
out countries_str,
|
||||
null,
|
||||
out status);
|
||||
_countries = new GLib.List<string> ();
|
||||
if (status == 0) {
|
||||
foreach (unowned string country in countries_str.split ("\n")) {
|
||||
_countries.append (country);
|
||||
}
|
||||
}
|
||||
_countrys.sort (strcmp);
|
||||
} catch (Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
} catch (SpawnError e) {
|
||||
stdout.printf ("Error: %s\n", e.message);
|
||||
}
|
||||
return _countrys;
|
||||
return _countries;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +56,6 @@ namespace Pamac {
|
||||
// set default options
|
||||
choosen_generation_method = "rank";
|
||||
choosen_country = "ALL";
|
||||
mirrorlists_dir = "/etc/pacman.d/mirrors";
|
||||
parse_file (conf_path);
|
||||
}
|
||||
|
||||
@@ -87,8 +88,6 @@ namespace Pamac {
|
||||
choosen_generation_method = val;
|
||||
} else if (key == "OnlyCountry") {
|
||||
choosen_country = val;
|
||||
} else if (key == "MirrorlistsDir") {
|
||||
mirrorlists_dir = val.replace ("\"", "");
|
||||
}
|
||||
}
|
||||
} catch (Error e) {
|
||||
|
Reference in New Issue
Block a user