Commit 141099af authored by guinux's avatar guinux

v9.2.0beta

parent 197a8a00
......@@ -13,6 +13,9 @@ RefreshPeriod = 6
## When applying updates, enable packages downgrade:
#EnableDowngrade
## When installing packages, do not check for updates:
#SimpleInstall
## Allow Pamac to search and install packages from AUR:
#EnableAUR
......@@ -34,8 +37,8 @@ KeepNumPackages = 3
## Remove only the versions of uninstalled packages when clean cache:
#OnlyRmUninstalled
## Download updates in background
## Download updates in background:
#DownloadUpdates
## Maximum Parallel Downloads
## Maximum Parallel Downloads:
MaxParallelDownloads = 4
This diff is collapsed.
......@@ -50,14 +50,15 @@ internal class AlpmConfig {
string? gpgdir;
string? arch;
int usesyslog;
public bool checkspace;
GLib.List<string> cachedirs;
GLib.List<string> hookdirs;
GLib.List<string> ignoregroups;
GLib.List<string> ignorepkgs;
public GenericSet<string?> ignorepkgs = new GenericSet<string?> (str_hash, str_equal);
GLib.List<string> noextracts;
GLib.List<string> noupgrades;
GLib.List<string> holdpkgs;
GLib.List<string> syncfirsts;
public GLib.List<string> holdpkgs;
public GLib.List<string> syncfirsts;
Alpm.Signature.Level siglevel;
Alpm.Signature.Level localfilesiglevel;
Alpm.Signature.Level remotefilesiglevel;
......@@ -71,25 +72,18 @@ internal class AlpmConfig {
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> ();
ignorepkgs.remove_all ();
noextracts = new GLib.List<string> ();
noupgrades = new GLib.List<string> ();
holdpkgs = new GLib.List<string> ();
syncfirsts = new GLib.List<string> ();
usesyslog = 0;
checkspace = false;
siglevel = Alpm.Signature.Level.PACKAGE | Alpm.Signature.Level.PACKAGE_OPTIONAL | Alpm.Signature.Level.DATABASE | Alpm.Signature.Level.DATABASE_OPTIONAL;
localfilesiglevel = Alpm.Signature.Level.USE_DEFAULT;
remotefilesiglevel = Alpm.Signature.Level.USE_DEFAULT;
......@@ -192,7 +186,7 @@ internal class AlpmConfig {
handle.gpgdir = gpgdir;
handle.arch = arch;
handle.usesyslog = usesyslog;
handle.checkspace = 1;
handle.checkspace = checkspace ? 1 : 0;
handle.defaultsiglevel = siglevel;
localfilesiglevel = merge_siglevel (siglevel, localfilesiglevel, localfilesiglevel_mask);
remotefilesiglevel = merge_siglevel (siglevel, remotefilesiglevel, remotefilesiglevel_mask);
......@@ -254,6 +248,10 @@ internal class AlpmConfig {
}
if (line[0] == '[' && line[line.length-1] == ']') {
current_section = line[1:-1];
if (current_section == null) {
// error
continue;
}
if (current_section != "options") {
var repo = new AlpmRepo (current_section);
if (repo_order.find_custom (repo, AlpmRepo.compare_name) == null) {
......@@ -298,6 +296,8 @@ internal class AlpmConfig {
}
} else if (key == "UseSysLog") {
usesyslog = 1;
} else if (key == "CheckSpace") {
checkspace = true;
} else if (key == "SigLevel") {
process_siglevel (val, ref siglevel, ref siglevel_mask);
} else if (key == "LocalFileSigLevel") {
......@@ -318,7 +318,7 @@ internal class AlpmConfig {
}
} else if (key == "IgnorePkg") {
foreach (unowned string name in val.split (" ")) {
ignorepkgs.append (name);
ignorepkgs.add (name);
}
} else if (key == "Noextract") {
foreach (unowned string name in val.split (" ")) {
......@@ -351,53 +351,65 @@ internal class AlpmConfig {
}
}
//~ public void write (HashTable<string,Variant> new_conf) {
//~ var file = GLib.File.new_for_path (conf_path);
//~ if (file.query_exists ()) {
//~ try {
//~ // Open file for reading and wrap returned FileInputStream into a
//~ // DataInputStream, so we can read line by line
//~ var dis = new DataInputStream (file.read ());
//~ string? line;
//~ var data = new StringBuilder ();
//~ // Read lines until end of file (null) is reached
//~ while ((line = dis.read_line ()) != null) {
//~ if (line.length == 0) {
//~ data.append ("\n");
//~ continue;
//~ }
//~ if (line.contains ("IgnorePkg")) {
//~ if (new_conf.contains ("IgnorePkg")) {
//~ string val = new_conf.get ("IgnorePkg").get_string ();
//~ if (val == "") {
//~ data.append ("#IgnorePkg =\n");
//~ } else {
//~ data.append ("IgnorePkg = %s\n".printf (val));
//~ }
//~ // simply comment other IgnorePkg lines
//~ new_conf.replace ("IgnorePkg", "");
//~ } else {
//~ data.append (line);
//~ data.append ("\n");
//~ }
//~ } else {
//~ 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));
//~ dos.put_string (data.str);
//~ reload ();
//~ } catch (GLib.Error e) {
//~ GLib.stderr.printf("%s\n", e.message);
//~ }
//~ } else {
//~ GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path);
//~ }
//~ }
public void write (HashTable<string,Variant> new_conf) {
var file = GLib.File.new_for_path (conf_path);
if (file.query_exists ()) {
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
var dis = new DataInputStream (file.read ());
string? line;
var data = new StringBuilder ();
// Read lines until end of file (null) is reached
while ((line = dis.read_line ()) != null) {
if (line.length == 0) {
data.append ("\n");
continue;
}
if (line.contains ("IgnorePkg")) {
if (new_conf.contains ("IgnorePkg")) {
string val = new_conf.get ("IgnorePkg").get_string ();
if (val == "") {
data.append ("#IgnorePkg =\n");
} else {
data.append ("IgnorePkg = %s\n".printf (val));
}
// simply comment other IgnorePkg lines
new_conf.replace ("IgnorePkg", "");
} else {
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.append ("CheckSpace\n");
} else {
data.append ("#CheckSpace\n");
}
new_conf.remove ("CheckSpace");
} else {
data.append (line);
data.append ("\n");
}
} else {
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));
dos.put_string (data.str);
} catch (GLib.Error e) {
GLib.stderr.printf("%s\n", e.message);
}
} else {
GLib.stderr.printf ("File '%s' doesn't exist.\n", conf_path);
}
}
Alpm.DB.Usage define_usage (string conf_string) {
Alpm.DB.Usage usage = 0;
......
......@@ -135,14 +135,11 @@ namespace Pamac {
foreach (unowned PackageStruct pkg_struct in summary_struct.to_remove) {
to_remove_priv.append (pkg_struct.to_pkg ());
}
to_remove_priv.sort (compare_name_pkg);
foreach (unowned PackageStruct pkg_struct in summary_struct.to_build) {
to_build_priv.append (pkg_struct.to_pkg ());
}
to_build_priv.sort (compare_name_pkg);
foreach (unowned PackageStruct pkg_struct in summary_struct.aur_conflicts_to_remove) {
to_remove_priv.append (pkg_struct.to_pkg ());
}
to_remove_priv.sort (compare_name_pkg);
foreach (unowned string str in summary_struct.aur_pkgbases_to_build) {
aur_pkgbases_to_build_priv.append (str);
}
......@@ -151,21 +148,27 @@ namespace Pamac {
public class Updates: Object {
List<AlpmPackage> repos_updates_priv;
List<AlpmPackage> ignored_repos_updates_priv;
List<AURPackage> aur_updates_priv;
List<AURPackage> ignored_aur_updates_priv;
List<AURPackage> outofdate_priv;
public List<AlpmPackage> repos_updates { get {return repos_updates_priv;} }
public List<AlpmPackage> ignored_repos_updates { get {return ignored_repos_updates_priv;} }
public List<AURPackage> aur_updates { get {return aur_updates_priv;} }
public List<AURPackage> ignored_aur_updates { get {return ignored_aur_updates_priv;} }
public List<AURPackage> outofdate { get {return outofdate_priv;} }
internal Updates () {
repos_updates_priv = new List<AlpmPackage> ();
aur_updates_priv = new List<AURPackage> ();
outofdate_priv = new List<AURPackage> ();
}
internal Updates () {}
internal Updates.from_lists (owned List<AlpmPackage> repos_updates, owned List<AURPackage> aur_updates, owned List<AURPackage> outofdate) {
internal Updates.from_lists (owned List<AlpmPackage> repos_updates,
owned List<AlpmPackage> ignored_repos_updates,
owned List<AURPackage> aur_updates,
owned List<AURPackage> ignored_aur_updates,
owned List<AURPackage> outofdate) {
repos_updates_priv = (owned) repos_updates;
ignored_repos_updates_priv = (owned) ignored_repos_updates;
aur_updates_priv = (owned) aur_updates;
ignored_aur_updates_priv = (owned) ignored_aur_updates;
outofdate_priv = (owned) outofdate;
}
}
......
......@@ -92,6 +92,8 @@ namespace Pamac {
bool sysupgrade;
bool force_refresh;
bool enable_downgrade;
bool simple_install;
bool check_aur_updates;
bool no_confirm_commit;
bool keep_built_pkgs;
int trans_flags;
......@@ -105,7 +107,7 @@ namespace Pamac {
GenericArray<PackageStruct?> to_build_pkgs;
GenericArray<string> aur_pkgbases_to_build;
GenericSet<string?> to_syncfirst;
GenericArray<PackageStruct?> aur_conflicts_to_remove;
List<PackageStruct?> aur_conflicts_to_remove;
public Cancellable cancellable;
public bool downloading_updates;
// download data
......@@ -137,14 +139,14 @@ namespace Pamac {
public AlpmUtils (Config config) {
this.config = config;
alpm_config = new AlpmConfig ("/etc/pacman.conf");
alpm_config = config.alpm_config;
tmp_path = "/tmp/pamac";
to_syncfirst = new GenericSet<string?> (str_hash, str_equal);
to_install = new GenericSet<string?> (str_hash, str_equal);
to_remove = new GenericSet<string?> (str_hash, str_equal);
to_install_as_dep = new HashTable<string, string> (str_hash, str_equal);
to_build_pkgs = new GenericArray<PackageStruct?> ();
aur_conflicts_to_remove = new GenericArray<PackageStruct?> ();
aur_conflicts_to_remove = new List<PackageStruct?> ();
aur_pkgbases_to_build = new GenericArray<string> ();
current_filename = "";
current_action = "";
......@@ -218,7 +220,7 @@ namespace Pamac {
}
public void refresh_handle () {
alpm_config = new AlpmConfig ("/etc/pacman.conf");
alpm_config.reload ();
alpm_handle = alpm_config.get_handle ();
if (alpm_handle == null) {
critical ("%s\n", _("Failed to initialize alpm library"));
......@@ -489,7 +491,7 @@ namespace Pamac {
}
// check syncfirsts
to_syncfirst.remove_all ();
foreach (unowned string name in alpm_config.get_syncfirsts ()) {
foreach (unowned string name in alpm_config.syncfirsts) {
unowned Alpm.Package? pkg = Alpm.find_satisfier (alpm_handle.localdb.pkgcache, name);
if (pkg != null) {
unowned Alpm.Package? candidate = pkg.get_new_version (alpm_handle.syncdbs);
......@@ -753,7 +755,7 @@ namespace Pamac {
unowned Alpm.List<unowned Alpm.Package> to_remove = alpm_handle.trans_to_remove ();
while (to_remove != null) {
unowned Alpm.Package pkg = to_remove.data;
if (alpm_config.get_holdpkgs ().find_custom (pkg.name, strcmp) != null) {
if (alpm_config.holdpkgs.find_custom (pkg.name, strcmp) != null) {
details += _("%s needs to be removed but it is a locked package").printf (pkg.name);
found_locked_pkg = true;
}
......@@ -776,6 +778,8 @@ namespace Pamac {
bool sysupgrade,
bool force_refresh,
bool enable_downgrade,
bool simple_install,
bool check_aur_updates,
bool no_confirm_commit,
bool keep_built_pkgs,
int trans_flags,
......@@ -790,6 +794,8 @@ namespace Pamac {
this.sysupgrade = sysupgrade;
this.force_refresh = force_refresh;
this.enable_downgrade = enable_downgrade;
this.simple_install = simple_install;
this.check_aur_updates = check_aur_updates;
this.no_confirm_commit = no_confirm_commit;
this.keep_built_pkgs = keep_built_pkgs;
this.trans_flags = trans_flags;
......@@ -811,7 +817,33 @@ namespace Pamac {
bool trans_run_real () {
bool success;
if (to_build.length > 0) {
// check if we need to sysupgrade
if (!sysupgrade && !simple_install && to_install.length > 0) {
foreach (unowned string name in to_install) {
unowned Alpm.Package? local_pkg = alpm_handle.localdb.get_pkg (name);
if (local_pkg == null) {
sysupgrade = true;
break;
} else {
unowned Alpm.Package? sync_pkg = get_syncpkg (name);
if (sync_pkg != null) {
if (local_pkg.version != sync_pkg.version) {
sysupgrade = true;
break;
}
}
}
}
}
if (sysupgrade) {
if (!get_authorization (sender)) {
return false;
}
if (!refresh ()) {
return false;
}
}
if (to_build.length > 0 || check_aur_updates) {
success = build_prepare ();
} else {
success = trans_prepare ();
......@@ -830,7 +862,7 @@ namespace Pamac {
trans_release ();
edit_build_files (sender, summary.aur_pkgbases_to_build);
to_build_pkgs = new GenericArray<PackageStruct?> ();
aur_conflicts_to_remove = new GenericArray<PackageStruct?> ();
aur_conflicts_to_remove = new List<PackageStruct?> ();
aur_pkgbases_to_build = new GenericArray<string> ();
emit_script_output (sender, "");
compute_aur_build_list (sender);
......@@ -886,7 +918,7 @@ namespace Pamac {
edit_build_files (sender, unresolvables.data);
unresolvables = new GenericArray<string> ();
to_build_pkgs = new GenericArray<PackageStruct?> ();
aur_conflicts_to_remove = new GenericArray<PackageStruct?> ();
aur_conflicts_to_remove = new List<PackageStruct?> ();
aur_pkgbases_to_build = new GenericArray<string> ();
emit_script_output (sender, "");
compute_aur_build_list (sender);
......@@ -902,7 +934,7 @@ namespace Pamac {
already_downloaded = 0;
current_filename = "";
to_build_pkgs = new GenericArray<PackageStruct?> ();
aur_conflicts_to_remove = new GenericArray<PackageStruct?> ();
aur_conflicts_to_remove = new List<PackageStruct?> ();
aur_pkgbases_to_build = new GenericArray<string> ();
to_install.remove_all ();
to_remove.remove_all ();
......@@ -922,32 +954,6 @@ namespace Pamac {
}
bool launch_trans_prepare_real () {
// check if you add upgrades to transaction
if (!sysupgrade && to_install.length > 0) {
foreach (unowned string name in to_install) {
unowned Alpm.Package? local_pkg = alpm_handle.localdb.get_pkg (name);
if (local_pkg == null) {
sysupgrade = true;
break;
} else {
unowned Alpm.Package? sync_pkg = get_syncpkg (name);
if (sync_pkg != null) {
if (local_pkg.version != sync_pkg.version) {
sysupgrade = true;
break;
}
}
}
}
}
if (sysupgrade) {
if (!get_authorization (sender)) {
return false;
}
if (!refresh ()) {
return false;
}
}
bool success = trans_init (trans_flags);
if (success && sysupgrade) {
success = trans_sysupgrade ();
......@@ -1049,6 +1055,9 @@ namespace Pamac {
}
success = false;
}
if (success && sysupgrade) {
success = trans_sysupgrade ();
}
if (success) {
foreach (unowned string name in to_install) {
success = trans_add_pkg (name);
......@@ -1100,21 +1109,29 @@ namespace Pamac {
if (db != null) {
if (db.name == "aur") {
// it is a aur pkg to build
uint index;
bool found = aur_pkgbases_to_build.find_with_equal_func (trans_pkg.pkgbase, str_equal, out index);
if (found) {
aur_pkgbases_to_build.remove_index (index);
}
//uint index;
//bool found = aur_pkgbases_to_build.find_with_equal_func (trans_pkg.pkgbase, str_equal, out index);
//if (found) {
// aur_pkgbases_to_build.remove_index (index);
//}
aur_pkgbases_to_build.add (trans_pkg.pkgbase);
to_build_pkgs.add (initialise_pkg_struct (trans_pkg));
if (!(trans_pkg.name in to_build)) {
to_install_as_dep.insert (trans_pkg.name, trans_pkg.name);
// if it is already installed, it is an update
unowned Alpm.Package? installed_pkg = alpm_handle.localdb.get_pkg (trans_pkg.name);
if (installed_pkg == null) {
to_install_as_dep.insert (trans_pkg.name, trans_pkg.name);
}
}
} else {
// it is a pkg to install
real_to_install.add (trans_pkg.name);
if (!(trans_pkg.name in to_install)) {
to_install_as_dep.insert (trans_pkg.name, trans_pkg.name);
// if it is already installed, it is an update
unowned Alpm.Package? installed_pkg = alpm_handle.localdb.get_pkg (trans_pkg.name);
if (installed_pkg == null) {
to_install_as_dep.insert (trans_pkg.name, trans_pkg.name);
}
}
}
}
......@@ -1125,7 +1142,7 @@ namespace Pamac {
unowned Alpm.Package trans_pkg = pkgs_to_remove.data;
// it is a pkg to remove
if (!(trans_pkg.name in to_remove)) {
aur_conflicts_to_remove.add (initialise_pkg_struct (trans_pkg));
aur_conflicts_to_remove.append (initialise_pkg_struct (trans_pkg));
}
pkgs_to_remove.next ();
}
......@@ -1162,7 +1179,7 @@ namespace Pamac {
}
}
public TransactionSummaryStruct get_transaction_summary () {
TransactionSummaryStruct get_transaction_summary () {
var to_install = new GenericArray<PackageStruct?> ();
var to_upgrade = new GenericArray<PackageStruct?> ();
var to_downgrade = new GenericArray<PackageStruct?> ();
......@@ -1192,6 +1209,13 @@ namespace Pamac {
to_remove.add (initialise_pkg_struct (trans_pkg));
pkgs_to_remove.next ();
}
foreach (unowned PackageStruct pkg_struct in aur_conflicts_to_remove) {
if (!to_remove.find_with_equal_func (pkg_struct, (strct_a, strct_b) => {
return strct_a.name == strct_b.name;
})) {
to_remove.add (pkg_struct);
}
}
var summary = TransactionSummaryStruct () {
to_install = (owned) to_install.data,
to_upgrade = (owned) to_upgrade.data,
......@@ -1199,7 +1223,6 @@ namespace Pamac {
to_reinstall = (owned) to_reinstall.data,
to_remove = (owned) to_remove.data,
to_build = to_build_pkgs.data,
aur_conflicts_to_remove = aur_conflicts_to_remove.data,
aur_pkgbases_to_build = aur_pkgbases_to_build.data
};
return summary;
......
......@@ -222,6 +222,8 @@ namespace Pamac {
} else if (arg == "--builddir") {
if (args[i + 1] != null) {
database.config.aur_build_dir = args[i + 1];
// keep built pkgs in the custom build dir
database.config.keep_built_pkgs = true;
}
i++;
} else if (arg == "--no-confirm") {
......@@ -297,6 +299,8 @@ namespace Pamac {
i++;
} else if (arg == "--no-confirm") {
transaction.no_confirm = true;
} else if (arg == "--no-upgrade") {
transaction.database.config.simple_install = true;
} else if (arg.has_prefix ("-")) {
// wrong arg
error = true;
......@@ -971,6 +975,7 @@ namespace Pamac {
int max_length = 0;
string[] options = {" %s <%s>".printf ("--ignore", dgettext (null, "package(s)")),
" %s <%s>".printf ("--overwrite", dgettext (null, "glob")),
" --no-upgrade",
" --no-confirm"};
foreach (unowned string option in options) {
int length = option.char_count ();
......@@ -980,6 +985,7 @@ namespace Pamac {
}
string[] details = {dgettext (null, "ignore a package upgrade, multiple packages can be specified by separating them with a comma"),
dgettext (null, "overwrite conflicting files, multiple patterns can be specified by separating them with a comma"),
dgettext (null, "do not check for updates"),
dgettext (null, "bypass any and all confirmation messages")};
int i = 0;
foreach (unowned string option in options) {
......@@ -1717,23 +1723,40 @@ namespace Pamac {
}
if (quiet) {
foreach (unowned AlpmPackage pkg in updates.repos_updates) {
stdout.printf ("%s %s -> %s\n", pkg.name, pkg.installed_version, pkg.version);
}
foreach (unowned AURPackage pkg in updates.aur_updates) {
// do not show out of date packages
if (pkg.outofdate == 0) {
if (pkg.installed_version != "") {
stdout.printf ("%s %s -> %s\n", pkg.name, pkg.installed_version, pkg.version);
} else {
// it's a replacer
stdout.printf ("%s %s\n", pkg.name, pkg.version);
}
}
foreach (unowned AURPackage pkg in updates.aur_updates) {
stdout.printf ("%s %s -> %s\n", pkg.name, pkg.installed_version, pkg.version);
}
return;
}
// print pkgs
int name_length = 0;
int installed_version_length = 0;
int version_length = 0;
foreach (unowned AlpmPackage pkg in updates.repos_updates) {
if (pkg.name.length > name_length) {
name_length = pkg.name.length;
}
if (pkg.installed_version.length > installed_version_length) {
installed_version_length = pkg.installed_version.length;
}
if (pkg.version.length > version_length) {
version_length = pkg.version.length;
}
}
foreach (unowned AlpmPackage pkg in updates.ignored_repos_updates) {
if (pkg.name.length > name_length) {
name_length = pkg.name.length;
}
if (pkg.installed_version.length > installed_version_length) {
installed_version_length = pkg.installed_version.length;
}
if (pkg.version.length > version_length) {
version_length = pkg.version.length;
}
......@@ -1742,6 +1765,20 @@ namespace Pamac {
if (pkg.name.length > name_length) {
name_length = pkg.name.length;
}
if (pkg.installed_version.length > installed_version_length) {
installed_version_length = pkg.installed_version.length;
}
if (pkg.version.length > version_length) {
version_length = pkg.version.length;
}
}
foreach (unowned AURPackage pkg in updates.ignored_aur_updates) {
if (pkg.name.length > name_length) {
name_length = pkg.name.length;
}
if (pkg.installed_version.length > installed_version_length) {
installed_version_length = pkg.installed_version.length;
}
if (pkg.version.length > version_length) {
version_length = pkg.version.length;
}
......@@ -1757,17 +1794,39 @@ namespace Pamac {
string info = ngettext ("%u available update", "%u available updates", updates_nb).printf (updates_nb);
stdout.printf ("%s:\n", info);
foreach (unowned AlpmPackage pkg in updates.repos_updates) {
stdout.printf ("%-*s %-*s %s\n",
stdout.printf ("%-*s %-*s -> %-*s %s\n",
name_length, pkg.name,
installed_version_length, pkg.installed_version,
version_length, pkg.version,
pkg.repo);
}
foreach (unowned AURPackage pkg in updates.aur_updates) {
stdout.printf ("%-*s %-*s %s\n",
stdout.printf ("%-*s %-*s -> %-*s %s\n",
name_length, pkg.name,