diff --git a/src/alpm_config.vala b/src/alpm_config.vala index 4b288def0ce0ec664743c51b0f57e618fc4e198b..0d01b16578ccacde7f0a9019dfbdb4c11de787b0 100644 --- a/src/alpm_config.vala +++ b/src/alpm_config.vala @@ -361,50 +361,50 @@ internal class AlpmConfig { // DataInputStream, so we can read line by line var dis = new DataInputStream (file.read ()); string? line; - string[] data = {}; + var data = new StringBuilder (); // Read lines until end of file (null) is reached while ((line = dis.read_line ()) != null) { if (line.length == 0) { - data += "\n"; + data.append ("\n"); continue; } if (line.contains ("IgnorePkg")) { if (new_conf.contains ("IgnorePkg")) { string val = new_conf.get ("IgnorePkg").get_string (); if (val == "") { - data += "#IgnorePkg =\n"; + data.append ("#IgnorePkg =\n"); } else { - data += "IgnorePkg = %s\n".printf (val); + data.append ("IgnorePkg = %s\n".printf (val)); } // simply comment other IgnorePkg lines new_conf.replace ("IgnorePkg", ""); } else { - data += line + "\n"; + data.append (line); + data.append ("\n"); } } else if (line.contains ("CheckSpace")) { if (new_conf.contains ("CheckSpace")) { bool val = new_conf.get ("CheckSpace").get_boolean (); if (val) { - data += "CheckSpace\n"; + data.append ("CheckSpace\n"); } else { - data += "#CheckSpace\n"; + data.append ("#CheckSpace\n"); } new_conf.remove ("CheckSpace"); } else { - data += line + "\n"; + data.append (line); + data.append ("\n"); } } else { - data += line + "\n"; + data.append (line); + data.append ("\n"); } } // delete the file before rewrite it file.delete (); // creating a DataOutputStream to the file var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); - foreach (unowned string new_line in data) { - // writing a short string to the stream - dos.put_string (new_line); - } + dos.put_string (data.str); reload (); } catch (GLib.Error e) { GLib.stderr.printf("%s\n", e.message); diff --git a/src/alpm_utils.vala b/src/alpm_utils.vala index 951aeaac940a338a20f137576aba05756f8e004e..d0e32b5806d661574eb62516ed42710300126783 100644 --- a/src/alpm_utils.vala +++ b/src/alpm_utils.vala @@ -94,14 +94,14 @@ namespace Pamac { internal bool force_refresh; internal bool enable_downgrade; internal int flags; - string[] to_syncfirst; + GenericSet<string?> to_syncfirst; internal string[] to_install; internal string[] to_remove; internal string[] to_load; internal string[] to_build; internal bool sysupgrade; AURPackageStruct[] to_build_pkgs; - GLib.List<string> aur_pkgbases_to_build; + GenericSet<string?> aur_pkgbases_to_build; HashTable<string, string> to_install_as_dep; internal string[] temporary_ignorepkgs; internal string[] overwrite_files; @@ -130,7 +130,8 @@ namespace Pamac { this.config = config; alpm_config = new AlpmConfig ("/etc/pacman.conf"); tmp_path = "/tmp/pamac"; - aur_pkgbases_to_build = new GLib.List<string> (); + to_syncfirst = new GenericSet<string?> (str_hash, str_equal); + aur_pkgbases_to_build = new GenericSet<string?> (str_hash, str_equal); to_install_as_dep = new HashTable<string, string> (str_hash, str_equal); timer = new Timer (); current_error = ErrorInfos (); @@ -413,13 +414,13 @@ namespace Pamac { return false; } // check syncfirsts - to_syncfirst = {}; + to_syncfirst.remove_all (); foreach (unowned string name in alpm_config.get_syncfirsts ()) { unowned Alpm.Package? pkg = Alpm.find_satisfier (alpm_handle.localdb.pkgcache, name); if (pkg != null) { unowned Alpm.Package? candidate = pkg.sync_newversion (alpm_handle.syncdbs); if (candidate != null) { - to_syncfirst += candidate.name; + to_syncfirst.add (candidate.name); } } } @@ -676,7 +677,8 @@ namespace Pamac { internal void trans_prepare () { to_build_pkgs = {}; - aur_pkgbases_to_build = new GLib.List<string> (); + aur_conflicts_to_remove = {}; + aur_pkgbases_to_build.remove_all (); to_install_as_dep.remove_all (); launch_trans_prepare_real (); } @@ -740,7 +742,7 @@ namespace Pamac { internal void build_prepare () { to_build_pkgs = {}; - aur_pkgbases_to_build = new GLib.List<string> (); + aur_pkgbases_to_build.remove_all (); to_install_as_dep.remove_all (); // get an handle with fake aur db and without emit signal callbacks alpm_handle = alpm_config.get_handle (); @@ -847,9 +849,7 @@ namespace Pamac { if (db != null) { if (db.name == "aur") { // it is a aur pkg to build - if (aur_pkgbases_to_build.find_custom (trans_pkg.pkgbase, strcmp) == null) { - aur_pkgbases_to_build.append (trans_pkg.pkgbase); - } + aur_pkgbases_to_build.add (trans_pkg.pkgbase); to_build_pkgs += AURPackageStruct () { name = trans_pkg.name, version = trans_pkg.version, @@ -946,11 +946,6 @@ namespace Pamac { to_remove += initialise_pkg_struct (trans_pkg); pkgs_to_remove.next (); } - PackageStruct[] conflicts_to_remove = {}; - foreach (unowned PackageStruct pkg in aur_conflicts_to_remove){ - conflicts_to_remove += pkg; - } - aur_conflicts_to_remove = {}; string[] pkgbases_to_build = {}; foreach (unowned string name in aur_pkgbases_to_build) { pkgbases_to_build += name; @@ -962,7 +957,7 @@ namespace Pamac { to_reinstall = (owned) to_reinstall, to_remove = (owned) to_remove, to_build = to_build_pkgs, - aur_conflicts_to_remove = (owned) conflicts_to_remove, + aur_conflicts_to_remove = aur_conflicts_to_remove, aur_pkgbases_to_build = (owned) pkgbases_to_build }; return summary; diff --git a/src/aur.vala b/src/aur.vala index 5c90dc948bd12229a1189f48e6ba67e5ef442796..3bae26f01da38e76298db4266299ba48e7731d12 100644 --- a/src/aur.vala +++ b/src/aur.vala @@ -56,12 +56,16 @@ namespace Pamac { if (needles.length == 0) { return new Json.Array (); } else { - Json.Array[] found_array = {}; + var all_found = new SList<Json.Array> (); foreach (unowned string needle in needles) { - found_array += yield rpc_query (rpc_url + rpc_search + Uri.escape_string (needle)); + var builder = new StringBuilder (); + builder.append (rpc_url); + builder.append (rpc_search); + builder.append (Uri.escape_string (needle)); + all_found.append (yield rpc_query (builder.str)); } var result = new Json.Array (); - foreach (unowned Json.Array found in found_array) { + foreach (unowned Json.Array found in all_found) { if (found.get_length () == 0) { continue; } diff --git a/src/cli.vala b/src/cli.vala index 9b957c79305d12b920181456faac927137a5e493..ed092372472381c99ac99d77a7f0e5915903b2af 100644 --- a/src/cli.vala +++ b/src/cli.vala @@ -1797,6 +1797,7 @@ namespace Pamac { } // get user input while (true) { + stdout.printf ("\n"); stdout.printf ("%s: ", dgettext (null, "Enter a selection (default=%s)").printf (dgettext (null, "all"))); string ans = stdin.read_line (); uint64 nb; @@ -1836,7 +1837,6 @@ namespace Pamac { } } } - stdout.printf ("\n"); if (numbers.length > 0) { foreach (uint64 number in numbers) { to_install += pkgs.nth_data ((uint) number -1).name; diff --git a/src/database.vala b/src/database.vala index de3f76a6877ea9d8720dc58f42e53492e8bf6dd0..fd252187c5bb2a3f16e7036874ca792cc53efba1 100644 --- a/src/database.vala +++ b/src/database.vala @@ -252,14 +252,14 @@ namespace Pamac { return screenshot; } - As.App[] get_pkgname_matching_apps (string pkgname) { - As.App[] matching_apps = {}; + SList<As.App> get_pkgname_matching_apps (string pkgname) { + var matching_apps = new SList<As.App> (); app_store.get_apps ().foreach ((app) => { if (app.get_pkgname_default () == pkgname) { - matching_apps += app; + matching_apps.append (app); } }); - return matching_apps; + return (owned) matching_apps; } PackageStruct initialise_pkg_struct (Alpm.Package? alpm_pkg) { @@ -294,9 +294,9 @@ namespace Pamac { } if (repo_name != "" && repo_name != dgettext (null, "AUR")) { // find if pkgname provides only one app - As.App[] matching_apps = get_pkgname_matching_apps (alpm_pkg.name); - if (matching_apps.length == 1) { - As.App app = matching_apps[0]; + var matching_apps = get_pkgname_matching_apps (alpm_pkg.name); + if (matching_apps.length () == 1) { + As.App app = matching_apps.nth_data (0); app_name = get_app_name (app); desc = get_app_summary (app); icon = get_app_icon (app, repo_name); @@ -355,8 +355,8 @@ namespace Pamac { repo_name = alpm_pkg.db.name; } if (repo_name != "" && repo_name != dgettext (null, "AUR")) { - As.App[] apps = get_pkgname_matching_apps (alpm_pkg.name); - if (apps.length > 0) { + var apps = get_pkgname_matching_apps (alpm_pkg.name); + if (apps.length () > 0) { // alpm_pkg provide some apps foreach (unowned As.App app in apps) { pkgs.append (new Package.from_struct (PackageStruct () { @@ -975,9 +975,9 @@ namespace Pamac { }); } else { // find if pkgname provides only one app - As.App[] matching_apps = get_pkgname_matching_apps (pkgname); - if (matching_apps.length == 1) { - As.App app = matching_apps[0]; + var matching_apps = get_pkgname_matching_apps (pkgname); + if (matching_apps.length () == 1) { + As.App app = matching_apps.nth_data (0); app_name = get_app_name (app); desc = get_app_summary (app); try { @@ -1668,7 +1668,7 @@ namespace Pamac { string line; string current_section = ""; bool current_section_is_pkgbase = true; - var version = new StringBuilder (); + var version = new StringBuilder (""); string pkgbase = ""; string desc = ""; var pkgnames_found = new SList<string> (); diff --git a/src/pamac_config.vala b/src/pamac_config.vala index c094f9c6682a1fc002ce61826dd37c480922a3e3..843cb7ddf92a72470c244075d66c9fc4fde62062 100644 --- a/src/pamac_config.vala +++ b/src/pamac_config.vala @@ -174,7 +174,7 @@ namespace Pamac { public void write (HashTable<string,Variant> new_conf) { var file = GLib.File.new_for_path (conf_path); - var data = new GLib.List<string> (); + var data = new StringBuilder(); if (file.query_exists ()) { try { // Open file for reading and wrap returned FileInputStream into a @@ -197,21 +197,24 @@ namespace Pamac { } new_conf.remove ("RemoveUnrequiredDeps"); } else { - data.append (line + "\n"); + data.append (line); + data.append ("\n"); } } else if (line.contains ("RefreshPeriod")) { if (new_conf.lookup_extended ("RefreshPeriod", null, out variant)) { data.append ("RefreshPeriod = %llu\n".printf (variant.get_uint64 ())); new_conf.remove ("RefreshPeriod"); } else { - data.append (line + "\n"); + data.append (line); + data.append ("\n"); } } else if (line.contains ("KeepNumPackages")) { if (new_conf.lookup_extended ("KeepNumPackages", null, out variant)) { data.append ("KeepNumPackages = %llu\n".printf (variant.get_uint64 ())); new_conf.remove ("KeepNumPackages"); } else { - data.append (line + "\n"); + data.append (line); + data.append ("\n"); } } else if (line.contains ("OnlyRmUninstalled")) { if (new_conf.lookup_extended ("OnlyRmUninstalled", null, out variant)) { @@ -222,7 +225,8 @@ namespace Pamac { } new_conf.remove ("OnlyRmUninstalled"); } else { - data.append (line + "\n"); + data.append (line); + data.append ("\n"); } } else if (line.contains ("NoUpdateHideIcon")) { if (new_conf.lookup_extended ("NoUpdateHideIcon", null, out variant)) { @@ -233,7 +237,8 @@ namespace Pamac { } new_conf.remove ("NoUpdateHideIcon"); } else { - data.append (line + "\n"); + data.append (line); + data.append ("\n"); } } else if (line.contains ("EnableAUR")) { if (new_conf.lookup_extended ("EnableAUR", null, out variant)) { @@ -244,14 +249,16 @@ namespace Pamac { } new_conf.remove ("EnableAUR"); } else { - data.append (line + "\n"); + data.append (line); + data.append ("\n"); } } else if (line.contains ("BuildDirectory")) { if (new_conf.lookup_extended ("BuildDirectory", null, out variant)) { data.append ("BuildDirectory = %s\n".printf (variant.get_string ())); new_conf.remove ("BuildDirectory"); } else { - data.append (line + "\n"); + data.append (line); + data.append ("\n"); } } else if (line.contains ("CheckAURUpdates")) { if (new_conf.lookup_extended ("CheckAURUpdates", null, out variant)) { @@ -262,7 +269,8 @@ namespace Pamac { } new_conf.remove ("CheckAURUpdates"); } else { - data.append (line + "\n"); + data.append (line); + data.append ("\n"); } } else if (line.contains ("CheckAURVCSUpdates")) { if (new_conf.lookup_extended ("CheckAURVCSUpdates", null, out variant)) { @@ -273,7 +281,8 @@ namespace Pamac { } new_conf.remove ("CheckAURVCSUpdates"); } else { - data.append (line + "\n"); + data.append (line); + data.append ("\n"); } } else if (line.contains ("DownloadUpdates")) { if (new_conf.lookup_extended ("DownloadUpdates", null, out variant)) { @@ -284,17 +293,20 @@ namespace Pamac { } new_conf.remove ("DownloadUpdates"); } else { - data.append (line + "\n"); + data.append (line); + data.append ("\n"); } } else if (line.contains ("MaxParallelDownloads")) { if (new_conf.lookup_extended ("MaxParallelDownloads", null, out variant)) { data.append ("MaxParallelDownloads = %llu\n".printf (variant.get_uint64 ())); new_conf.remove ("MaxParallelDownloads"); } else { - data.append (line + "\n"); + data.append (line); + data.append ("\n"); } } else { - data.append (line + "\n"); + data.append (line); + data.append ("\n"); } } // delete the file before rewrite it @@ -369,10 +381,7 @@ namespace Pamac { try { // creating a DataOutputStream to the file var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); - foreach (unowned string new_line in data) { - // writing a short string to the stream - dos.put_string (new_line); - } + dos.put_string (data.str); } catch (GLib.Error e) { GLib.stderr.printf("%s\n", e.message); } diff --git a/src/transaction-cli.vala b/src/transaction-cli.vala index 68363c92fff5c232ad7f0601d03a9d7950d1cf21..caa740d40a5a5c1d87bd8d602c2ec81835358d2a 100644 --- a/src/transaction-cli.vala +++ b/src/transaction-cli.vala @@ -179,10 +179,10 @@ namespace Pamac { } } - protected override List<string> choose_optdeps (string pkgname, List<string> optdeps) { + protected override List<string> choose_optdeps (string pkgname, string[] optdeps) { var optdeps_to_install = new List<string> (); // print pkgs - int num_length = optdeps.length ().to_string ().length + 1; + int num_length = optdeps.length.to_string ().length + 1; stdout.printf ("%s:\n".printf (dgettext (null, "Choose optional dependencies for %s").printf (pkgname))); int num = 1; foreach (unowned string name in optdeps) { @@ -193,6 +193,7 @@ namespace Pamac { } // get user input while (true) { + stdout.printf ("\n"); stdout.printf ("%s: ", dgettext (null, "Enter a selection (default=%s)").printf (dgettext (null, "none"))); string ans = stdin.read_line (); uint64 nb; @@ -215,7 +216,7 @@ namespace Pamac { if (int64.try_parse (splitted2[1], out end_num)) { nb = beg_num; while (nb <= end_num) { - if (nb >= 1 && nb < optdeps.length ()) { + if (nb >= 1 && nb <= optdeps.length) { numbers += nb; } nb++; @@ -223,16 +224,15 @@ namespace Pamac { } } } else if (uint64.try_parse (part, out nb)) { - if (nb >= 1 && nb < optdeps.length ()) { + if (nb >= 1 && nb <= optdeps.length) { numbers += nb; } } } } - stdout.printf ("\n"); if (numbers.length > 0) { foreach (uint64 number in numbers) { - optdeps_to_install.append (optdeps.nth_data ((uint) number -1)); + optdeps_to_install.append (optdeps[number -1]); } break; } @@ -242,11 +242,11 @@ namespace Pamac { } protected override int choose_provider (string depend, string[] providers) { - Package[] pkgs = {}; + var pkgs = new SList<Package> (); foreach (unowned string pkgname in providers) { var pkg = database.get_sync_pkg (pkgname); if (pkg.name != "") { - pkgs += pkg; + pkgs.append (pkg); } } // print pkgs @@ -273,6 +273,7 @@ namespace Pamac { } // get user input while (true) { + stdout.printf ("\n"); stdout.printf ("%s: ", dgettext (null, "Enter a number (default=%d)").printf (1)); string ans = stdin.read_line (); int64 nb; @@ -284,7 +285,6 @@ namespace Pamac { } else if (!int64.try_parse (ans, out nb)) { nb = 0; } - stdout.printf ("\n"); if (nb >= 1 && nb <= providers.length) { int index = (int) nb - 1; stdout.printf ("\n"); diff --git a/src/transaction-gtk.vala b/src/transaction-gtk.vala index e5bfc0aae3e91b16b2397358eeb8c9d508625189..d13b2dd763131d368cad9206f087a587d15bb490 100644 --- a/src/transaction-gtk.vala +++ b/src/transaction-gtk.vala @@ -178,7 +178,7 @@ namespace Pamac { } } - protected override List<string> choose_optdeps (string pkgname, List<string> optdeps) { + protected override List<string> choose_optdeps (string pkgname, string[] optdeps) { var optdeps_to_install = new List<string> (); choose_pkgs_dialog.title = dgettext (null, "Choose optional dependencies for %s").printf (pkgname); choose_pkgs_dialog.pkgs_list.clear (); diff --git a/src/transaction.vala b/src/transaction.vala index 6a380104886adeb3830f8b092a68494d15456adf..35d1bbe30d7b14d3dd00c86d620c8bcb8a6acfa3 100644 --- a/src/transaction.vala +++ b/src/transaction.vala @@ -46,7 +46,7 @@ namespace Pamac { GenericSet<string?> already_checked_aur_dep; GenericSet<string?> aur_desc_list; Queue<string> to_build_queue; - string[] aur_pkgs_to_install; + GenericSet<string?> aur_pkgs_to_install; string[] aur_unresolvables; bool building; Cancellable build_cancellable; @@ -119,6 +119,7 @@ namespace Pamac { aurdb_path = "/tmp/pamac/aur-%s".printf (Environment.get_user_name ()); already_checked_aur_dep = new GenericSet<string?> (str_hash, str_equal); aur_desc_list = new GenericSet<string?> (str_hash, str_equal); + aur_pkgs_to_install = new GenericSet<string?> (str_hash, str_equal); to_build_queue = new Queue<string> (); build_cancellable = new Cancellable (); building = false; @@ -152,9 +153,9 @@ namespace Pamac { protected async string[] get_build_files (string pkgname) { string pkgdir_name = Path.build_path ("/", database.config.aur_build_dir, pkgname); - string[] files = {}; + var files = new GenericArray<string> (); // PKGBUILD - files += Path.build_path ("/", pkgdir_name, "PKGBUILD"); + files.add (Path.build_path ("/", pkgdir_name, "PKGBUILD")); var srcinfo = File.new_for_path (Path.build_path ("/", pkgdir_name, ".SRCINFO")); try { // read .SRCINFO @@ -167,7 +168,7 @@ namespace Pamac { string source_path = Path.build_path ("/", pkgdir_name, source); var source_file = File.new_for_path (source_path); if (source_file.query_exists ()) { - files += source_path; + files.add (source_path); } } } else if ("install = " in line) { @@ -175,17 +176,17 @@ namespace Pamac { string install_path = Path.build_path ("/", pkgdir_name, install); var install_file = File.new_for_path (install_path); if (install_file.query_exists ()) { - files += install_path; + files.add (install_path); } } } } catch (GLib.Error e) { stderr.printf ("Error: %s\n", e.message); } - return files; + return (owned) files.data; } - protected virtual List<string> choose_optdeps (string pkgname, List<string> optdeps) { + protected virtual List<string> choose_optdeps (string pkgname, string[] optdeps) { // do not install optdeps return new List<string> (); } @@ -334,7 +335,7 @@ namespace Pamac { } async void check_aur_dep_list (string[] pkgnames) { - string[] dep_to_check = {}; + var dep_to_check = new GenericArray<string> (); var aur_pkgs = new HashTable<string, AURPackage> (str_hash, str_equal); if (clone_build_files) { aur_pkgs = yield database.get_aur_pkgs (pkgnames); @@ -374,7 +375,7 @@ namespace Pamac { while ((info = enumerator.next_file (null)) != null) { unowned string filename = info.get_name (); if (!(filename in already_checked_aur_dep)) { - dep_to_check += filename; + dep_to_check.add (filename); } } } catch (GLib.Error e) { @@ -399,18 +400,18 @@ namespace Pamac { string line; string current_section = ""; bool current_section_is_pkgbase = true; - string version = ""; + var version = new StringBuilder (""); string pkgbase = ""; string desc = ""; string arch = Posix.utsname ().machine; - string[] pkgnames_found = {}; - string[] global_depends = {}; - string[] global_checkdepends = {}; - string[] global_makedepends = {}; - string[] global_conflicts = {}; - string[] global_provides = {}; - string[] global_replaces = {}; - string[] global_validpgpkeys = {}; + var pkgnames_found = new SList<string> (); + var global_depends = new GenericArray<string> (); + var global_checkdepends = new SList<string> (); + var global_makedepends = new SList<string> (); + var global_conflicts = new GenericArray<string> (); + var global_provides = new GenericArray<string> (); + var global_replaces = new GenericArray<string> (); + var global_validpgpkeys = new GenericArray<string> (); var pkgnames_table = new HashTable<string, AURPackageDetailsStruct?> (str_hash, str_equal); while ((line = yield dis.read_line_async ()) != null) { if ("pkgbase = " in line) { @@ -424,12 +425,13 @@ namespace Pamac { } } } else if ("pkgver = " in line) { - version = line.split ("pkgver = ", 2)[1]; + version.append (line.split (" = ", 2)[1]); } else if ("pkgrel = " in line) { - version += "-"; - version += line.split ("pkgrel = ", 2)[1]; + version.append ("-"); + version.append (line.split (" = ", 2)[1]); } else if ("epoch = " in line) { - version = "%s:%s".printf (line.split (" = ", 2)[1], version); + version.prepend (":"); + version.prepend (line.split (" = ", 2)[1]); // don't compute optdepends, it will be done by makepkg } else if ("optdepends" in line) { // pass @@ -444,11 +446,11 @@ namespace Pamac { string depend = line.split (" = ", 2)[1]; if (current_section_is_pkgbase){ if ("checkdepends" in line) { - global_checkdepends += depend; + global_checkdepends.append (depend); } else if ("makedepends" in line) { - global_makedepends += depend; + global_makedepends.append (depend); } else { - global_depends += depend; + global_depends.add (depend); } } else { unowned AURPackageDetailsStruct? details_struct = pkgnames_table.get (current_section); @@ -461,7 +463,7 @@ namespace Pamac { if ("provides = " in line || "provides_%s = ".printf (arch) in line) { string provide = line.split (" = ", 2)[1]; if (current_section_is_pkgbase) { - global_provides += provide; + global_provides.add (provide); } else { unowned AURPackageDetailsStruct? details_struct = pkgnames_table.get (current_section); if (details_struct != null) { @@ -473,7 +475,7 @@ namespace Pamac { if ("conflicts = " in line || "conflicts_%s = ".printf (arch) in line) { string conflict = line.split (" = ", 2)[1]; if (current_section_is_pkgbase) { - global_conflicts += conflict; + global_conflicts.add (conflict); } else { unowned AURPackageDetailsStruct? details_struct = pkgnames_table.get (current_section); if (details_struct != null) { @@ -485,7 +487,7 @@ namespace Pamac { if ("replaces = " in line || "replaces_%s = ".printf (arch) in line) { string replace = line.split (" = ", 2)[1]; if (current_section_is_pkgbase) { - global_replaces += replace; + global_replaces.add (replace); } else { unowned AURPackageDetailsStruct? details_struct = pkgnames_table.get (current_section); if (details_struct != null) { @@ -496,21 +498,21 @@ namespace Pamac { // grab validpgpkeys to check if they are imported } else if ("validpgpkeys" in line) { if ("validpgpkeys = " in line) { - global_validpgpkeys += line.split (" = ", 2)[1]; + global_validpgpkeys.add (line.split (" = ", 2)[1]); } } else if ("pkgname = " in line) { string pkgname_found = line.split (" = ", 2)[1]; current_section = pkgname_found; current_section_is_pkgbase = false; - pkgnames_found += pkgname_found; if (!pkgnames_table.contains (pkgname_found)) { var details_struct = AURPackageDetailsStruct () { name = pkgname_found, - version = version, + version = version.str, desc = desc, packagebase = pkgbase }; pkgnames_table.insert (pkgname_found, (owned) details_struct); + pkgnames_found.append ((owned) pkgname_found); } } } @@ -522,24 +524,24 @@ namespace Pamac { unowned AURPackageDetailsStruct? details_struct = pkgnames_table.get (pkgname_found); // populate empty list will global ones if (global_depends.length > 0 && details_struct.depends.length == 0) { - details_struct.depends = (owned) global_depends; + details_struct.depends = (owned) global_depends.data; } if (global_provides.length > 0 && details_struct.provides.length == 0) { - details_struct.provides = (owned) global_provides; + details_struct.provides = (owned) global_provides.data; } if (global_conflicts.length > 0 && details_struct.conflicts.length == 0) { - details_struct.conflicts = (owned) global_conflicts; + details_struct.conflicts = (owned) global_conflicts.data; } if (global_replaces.length > 0 && details_struct.replaces.length == 0) { - details_struct.replaces = (owned) global_replaces; + details_struct.replaces = (owned) global_replaces.data; } // add checkdepends and makedepends in depends - if (global_checkdepends.length > 0 ) { + if (global_checkdepends.length () > 0 ) { foreach (unowned string depend in global_checkdepends) { details_struct.depends += depend; } } - if (global_makedepends.length > 0 ) { + if (global_makedepends.length () > 0 ) { foreach (unowned string depend in global_makedepends) { details_struct.depends += depend; } @@ -553,7 +555,7 @@ namespace Pamac { if (pkg.name == "") { string dep_name = database.get_alpm_dep_name (dep_string); if (!(dep_name in already_checked_aur_dep)) { - dep_to_check += (owned) dep_name; + dep_to_check.add ((owned) dep_name); } } } @@ -619,7 +621,7 @@ namespace Pamac { } // check signature if (global_validpgpkeys.length > 0) { - yield check_signature (pkgname, global_validpgpkeys); + yield check_signature (pkgname, global_validpgpkeys.data); } } catch (GLib.Error e) { stderr.printf ("Error: %s\n", e.message); @@ -627,7 +629,7 @@ namespace Pamac { } } if (dep_to_check.length > 0) { - yield check_aur_dep_list (dep_to_check); + yield check_aur_dep_list (dep_to_check.data); } } @@ -730,21 +732,21 @@ namespace Pamac { this.temporary_ignorepkgs = temporary_ignorepkgs; this.overwrite_files = overwrite_files; // choose optdeps - string[] to_add_to_install = {}; + var to_add_to_install = new GenericSet<string?> (str_hash, str_equal); foreach (unowned string name in this.to_install) { // do not check if reinstall if (database.get_installed_pkg (name).name == "") { List<string> uninstalled_optdeps = database.get_uninstalled_optdeps (name); - var real_uninstalled_optdeps = new List<string> (); + var real_uninstalled_optdeps = new GenericArray<string> (); foreach (unowned string optdep in uninstalled_optdeps) { string optdep_name = optdep.split (": ", 2)[0]; if (!(optdep_name in this.to_install) && !(optdep_name in to_add_to_install)) { - real_uninstalled_optdeps.append (optdep); + real_uninstalled_optdeps.add (optdep); } } - if (real_uninstalled_optdeps.length () > 0) { - foreach (unowned string optdep in choose_optdeps (name, real_uninstalled_optdeps)) { - to_add_to_install += optdep; + if (real_uninstalled_optdeps.length > 0) { + foreach (unowned string optdep in choose_optdeps (name, real_uninstalled_optdeps.data)) { + to_add_to_install.add (optdep); } } } @@ -796,7 +798,7 @@ namespace Pamac { emit_action (dgettext (null, "Building %s").printf (pkgname) + "..."); build_cancellable.reset (); important_details_outpout (false); - string [] built_pkgs = {}; + var built_pkgs = new GenericSet<string?> (str_hash, str_equal); string pkgdir = Path.build_path ("/", database.config.aur_build_dir, pkgname); // building building = true; @@ -826,9 +828,7 @@ namespace Pamac { string name_version = name_version_release.slice (0, name_version_release.last_index_of_char ('-')); string name = name_version.slice (0, name_version.last_index_of_char ('-')); if (name in aur_pkgs_to_install) { - if (!(line in built_pkgs)) { - built_pkgs += line; - } + built_pkgs.add (line); } } } @@ -840,11 +840,15 @@ namespace Pamac { stop_building (); building = false; if (status == 0 && built_pkgs.length > 0) { + var to_load_array = new GenericArray<string> (); + foreach (unowned string name in built_pkgs) { + to_load_array.add (name); + } no_confirm_commit = true; emit_script_output (""); to_install = {}; to_remove = {}; - to_load = built_pkgs; + to_load = (owned) to_load_array.data; to_build = {}; overwrite_files = {}; trans_prepare_real (); @@ -1305,9 +1309,9 @@ namespace Pamac { foreach (unowned string name in summary_struct.aur_pkgbases_to_build) { to_build_queue.push_tail (name); } - aur_pkgs_to_install = {}; + aur_pkgs_to_install.remove_all (); foreach (unowned AURPackageStruct infos in summary_struct.to_build) { - aur_pkgs_to_install += infos.name; + aur_pkgs_to_install.add (infos.name); } if (ask_commit (summary)) { if (type == Type.BUILD) {