Commit b598924f authored by guinux's avatar guinux

many improvements

parent 13f51597
......@@ -11,10 +11,10 @@ RefreshPeriod = 6
#NoUpdateHideIcon
## Allow Pamac to search and install packages from AUR:
EnableAUR
#EnableAUR
## When AUR support is enabled check for updates from AUR:
CheckAURUpdates
#CheckAURUpdates
## AUR build directory:
BuildDirectory = /var/tmp
......
......@@ -26,7 +26,7 @@ if __name__ == "__main__":
for pkg in pkgs:
print_pkg_name (pkg)
print ("")
details = db.get_pkg_details(pkgname, appname)
details = db.get_pkg_details(pkgname, appname, False)
print_pkg_details (details)
print ("")
......@@ -36,5 +36,5 @@ if __name__ == "__main__":
for pkg in pkgs:
print_pkg_name (pkg)
print ("")
details = db.get_pkg_details(pkgname, appname)
details = db.get_pkg_details(pkgname, appname, False)
print_pkg_details (details)
......@@ -57,23 +57,23 @@ class GetInfosCase(unittest.TestCase):
def test_pacman_installed(self):
"""pacman installed for tests"""
pkg = self.db.get_pkg_details("pacman", "")
pkg = self.db.get_pkg_details("pacman", "", False)
self.assertEqual("pacman", pkg.get_name())
self.assertIsNotNone(pkg.props.installed_version)
def test_not_installed(self):
"""detect not installed"""
# package not exist
pkg = self.db.get_pkg_details("toto-test", "")
pkg = self.db.get_pkg_details("toto-test", "", False)
self.assertNotEqual("toto-test", pkg.get_name())
self.assertEqual(pkg.props.installed_version, "")
# package exist
pkg = self.db.get_pkg_details("ruby-yard", "")
pkg = self.db.get_pkg_details("ruby-yard", "", False)
self.assertEqual(pkg.props.installed_version, "")
def test_giobject_detail_name(self):
"""attrs .props are same as fonctions"""
pkg = self.db.get_pkg_details("pacman", "")
pkg = self.db.get_pkg_details("pacman", "", False)
self.assertEqual(pkg.props.name, pkg.get_name())
def test_giobject_search_name(self):
......@@ -127,7 +127,7 @@ class GetInfosCase(unittest.TestCase):
with self.subTest(pkg=pkg):
fdesc = f"/var/lib/pacman/local/{pkg.props.name}-{pkg.props.version}/desc"
self.assertTrue(os.path.exists(fdesc))
package = self.db.get_pkg_details(pkg.props.name, "")
package = self.db.get_pkg_details(pkg.props.name, "", False)
result = get_item_desc(fdesc, "%DEPENDS%")
for dep in result:
self.assertIn(dep, package.props.depends)
......@@ -149,7 +149,7 @@ class GetInfosCase(unittest.TestCase):
def test_date_detail_pacman(self):
"""valid date and locale date"""
pkg = self.db.get_pkg_details("pacman", "")
pkg = self.db.get_pkg_details("pacman", "", False)
fdesc = f"/var/lib/pacman/local/{pkg.props.name}-{pkg.props.version}/desc"
self.assertTrue(os.path.exists(fdesc))
result = get_item_desc(fdesc, "%BUILDDATE%")
......@@ -159,7 +159,7 @@ class GetInfosCase(unittest.TestCase):
def test_files(self):
"""files same as pacman db"""
pkg = self.db.get_pkg_details("pacman", "")
pkg = self.db.get_pkg_details("pacman", "", False)
fdesc = f"/var/lib/pacman/local/{pkg.props.name}-{pkg.props.version}/files"
self.assertTrue(os.path.exists(fdesc))
myfiles = self.db.get_pkg_files("pacman")
......
data/polkit/org.manjaro.pamac.policy.in
src/alpm_utils.vala
src/system_daemon.vala
src/database.vala
src/transaction.vala
src/transaction-gtk.vala
src/installer.vala
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Pamac\n"
"Report-Msgid-Bugs-To: guillaume@manjaro.org\n"
"POT-Creation-Date: 2018-09-08 17:58+0200\n"
"POT-Creation-Date: 2018-10-13 11:01+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -21,30 +21,10 @@ msgstr ""
msgid "Authentication is required"
msgstr ""
#: src/alpm_utils.vala
#: src/alpm_utils.vala src/database.vala
msgid "Failed to initialize alpm library"
msgstr ""
#: src/alpm_utils.vala
msgid "Unknown"
msgstr ""
#: src/alpm_utils.vala src/manager_window.vala
msgid "Explicitly installed"
msgstr ""
#: src/alpm_utils.vala src/manager_window.vala
msgid "Installed as a dependency for another package"
msgstr ""
#: src/alpm_utils.vala
msgid "Yes"
msgstr ""
#: src/alpm_utils.vala
msgid "No"
msgstr ""
#: src/alpm_utils.vala
msgid "Failed to synchronize any databases"
msgstr ""
......@@ -53,11 +33,11 @@ msgstr ""
msgid "Failed to init transaction"
msgstr ""
#: src/alpm_utils.vala
#: src/alpm_utils.vala src/transaction.vala src/transaction-gtk.vala
msgid "Failed to prepare transaction"
msgstr ""
#: src/alpm_utils.vala src/cli.vala
#: src/alpm_utils.vala src/transaction.vala src/cli.vala
#, c-format
msgid "target not found: %s"
msgstr ""
......@@ -125,20 +105,46 @@ msgstr ""
msgid "Authentication failed"
msgstr ""
#: src/database.vala src/manager_window.vala
msgid "Explicitly installed"
msgstr ""
#: src/database.vala src/manager_window.vala
msgid "Installed as a dependency for another package"
msgstr ""
#: src/database.vala
msgid "Unknown"
msgstr ""
#: src/database.vala
msgid "Yes"
msgstr ""
#: src/database.vala
msgid "No"
msgstr ""
#: src/transaction.vala
msgid "Refreshing mirrors list"
#, c-format
msgid "Generating %s informations"
msgstr ""
#: src/transaction.vala
msgid "Synchronizing package databases"
msgid "Refreshing mirrors list"
msgstr ""
#: src/transaction.vala
msgid "Starting full system upgrade"
msgstr ""
#: src/transaction.vala src/tray.vala src/manager_window.vala src/cli.vala
msgid "Your system is up-to-date"
#: src/transaction.vala
msgid "Synchronizing package databases"
msgstr ""
#: src/transaction.vala
#, c-format
msgid "Checking %s dependencies"
msgstr ""
#: src/transaction.vala
......@@ -352,6 +358,21 @@ msgstr ""
msgid "Total download size"
msgstr ""
#: src/transaction-gtk.vala src/transaction-cli.vala
#, c-format
msgid "Edit %s build files"
msgstr ""
#: src/transaction-gtk.vala src/manager_window.vala
#: resources/transaction_sum_dialog.ui resources/manager_window.ui
#: resources/choose_ignorepkgs_dialog.ui
msgid "_Cancel"
msgstr ""
#: src/transaction-gtk.vala
msgid "Save"
msgstr ""
#: src/transaction-gtk.vala resources/progress_dialog.ui
#: resources/history_dialog.ui resources/preferences_dialog.ui
msgid "_Close"
......@@ -373,6 +394,10 @@ msgstr ""
msgid "package(s)"
msgstr ""
#: src/tray.vala src/manager_window.vala src/cli.vala
msgid "Your system is up-to-date"
msgstr ""
#: src/tray.vala
msgid "_Quit"
msgstr ""
......@@ -409,6 +434,10 @@ msgstr ""
msgid "Install"
msgstr ""
#: src/manager_window.vala resources/manager_window.ui
msgid "Build"
msgstr ""
#: src/manager_window.vala resources/manager_window.ui
msgid "Remove"
msgstr ""
......@@ -508,6 +537,10 @@ msgstr ""
msgid "Files"
msgstr ""
#: src/manager_window.vala
msgid "Build files"
msgstr ""
#: src/manager_window.vala src/cli.vala
msgid "Install Reason"
msgstr ""
......@@ -616,11 +649,6 @@ msgstr ""
msgid "Install Local Packages"
msgstr ""
#: src/manager_window.vala resources/transaction_sum_dialog.ui
#: resources/manager_window.ui resources/choose_ignorepkgs_dialog.ui
msgid "_Cancel"
msgstr ""
#: src/manager_window.vala
msgid "_Open"
msgstr ""
......@@ -655,27 +683,36 @@ msgid "Enter a number (default=%d)"
msgstr ""
#: src/transaction-cli.vala
msgid "Total installed size"
msgid "[y/N]"
msgstr ""
#: src/transaction-cli.vala
msgid "Total removed size"
msgid "y"
msgstr ""
#: src/transaction-cli.vala
msgid "Commit transaction"
msgid "yes"
msgstr ""
#: src/transaction-cli.vala resources/transaction_sum_dialog.ui
msgid "Edit build files"
msgstr ""
#: src/transaction-cli.vala
msgid "[y/N]"
msgid "Total installed size"
msgstr ""
#: src/transaction-cli.vala
msgid "y"
msgid "Total removed size"
msgstr ""
#: src/transaction-cli.vala
msgid "yes"
msgid "Commit transaction"
msgstr ""
#: src/transaction-cli.vala
#, c-format
msgid "View %s build files diff"
msgstr ""
#: src/cli.vala
......@@ -771,6 +808,12 @@ msgstr ""
msgid "dir"
msgstr ""
#: src/cli.vala
msgid ""
"ignore a package upgrade, multiple packages can be specified by separating "
"them with a comma"
msgstr ""
#: src/cli.vala
msgid ""
"overwrite conflicting files, multiple patterns can be specified by "
......@@ -825,12 +868,6 @@ msgstr ""
msgid "enable package downgrades"
msgstr ""
#: src/cli.vala
msgid ""
"ignore a package upgrade, multiple packages can be specified by separating "
"them with a comma"
msgstr ""
#: src/cli.vala resources/manager_window.ui
msgid "Version"
msgstr ""
......@@ -908,6 +945,10 @@ msgstr ""
msgid "About"
msgstr ""
#: resources/manager_window.ui
msgid "Select All"
msgstr ""
#: resources/manager_window.ui
msgid "State"
msgstr ""
......@@ -925,11 +966,11 @@ msgid "Reinstall"
msgstr ""
#: resources/manager_window.ui
msgid "_Apply"
msgid "Reset build files"
msgstr ""
#: resources/manager_window.ui
msgid "Select All"
msgid "_Apply"
msgstr ""
#: resources/preferences_dialog.ui
......
......@@ -54,7 +54,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="review_button">
<object class="GtkButton" id="edit_button">
<property name="label" translatable="yes">Edit build files</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
......@@ -164,7 +164,7 @@
<action-widgets>
<action-widget response="-6">cancel_button</action-widget>
<action-widget response="-5">apply_button</action-widget>
<action-widget response="-2">review_button</action-widget>
<action-widget response="-2">edit_button</action-widget>
</action-widgets>
</template>
</interface>
......@@ -138,14 +138,19 @@ internal class AlpmConfig {
Alpm.Errno error = 0;
Alpm.Handle? handle = null;
if (tmp_db) {
string tmp_dbpath = "/tmp/pamac-checkdbs";
string tmp_path = "/tmp/pamac";
string tmp_dbpath = "/tmp/pamac/dbs-%s".printf (Environment.get_user_name ());
try {
var file = GLib.File.new_for_path (tmp_dbpath);
var file = GLib.File.new_for_path (tmp_path);
if (!file.query_exists ()) {
Process.spawn_command_line_sync ("mkdir -p %s/sync".printf (tmp_dbpath));
Process.spawn_command_line_sync ("chmod -R ugo+w %s".printf (tmp_dbpath));
Process.spawn_command_line_sync ("mkdir -p %s".printf (tmp_path));
Process.spawn_command_line_sync ("chmod a+w %s".printf (tmp_path));
}
file = GLib.File.new_for_path (tmp_dbpath);
if (!file.query_exists ()) {
Process.spawn_command_line_sync ("mkdir -p %s".printf (tmp_dbpath));
Process.spawn_command_line_sync ("ln -s %slocal %s".printf (dbpath, tmp_dbpath));
}
Process.spawn_command_line_sync ("ln -sf %slocal %s".printf (dbpath, tmp_dbpath));
Process.spawn_command_line_sync ("cp -ru %ssync %s".printf (dbpath, tmp_dbpath));
handle = new Alpm.Handle (rootdir, tmp_dbpath, out error);
if (error == Alpm.Errno.DB_VERSION) {
......
......@@ -25,6 +25,7 @@ namespace Pamac {
internal AlpmConfig alpm_config;
internal Alpm.Handle? alpm_handle;
internal Alpm.Handle? files_handle;
internal string tmp_path;
internal Cond provider_cond;
internal Mutex provider_mutex;
internal int? choosen_provider;
......@@ -51,6 +52,7 @@ namespace Pamac {
public signal void emit_event (uint primary_event, uint secondary_event, string[] details);
public signal void emit_providers (string depend, string[] providers);
public signal void emit_unresolvables (string[] unresolvables);
public signal void emit_progress (uint progress, string pkgname, uint percent, uint n_targets, uint current_target);
public signal void emit_download (string filename, uint64 xfered, uint64 total);
public signal void emit_totaldownload (uint64 total);
......@@ -64,6 +66,7 @@ namespace Pamac {
public AlpmUtils (Config config) {
this.config = config;
alpm_config = new AlpmConfig ("/etc/pacman.conf");
tmp_path = "/tmp/pamac";
aur_pkgbases_to_build = new GLib.List<string> ();
to_install_as_dep = new HashTable<string, string> (str_hash, str_equal);
timer = new Timer ();
......@@ -161,20 +164,19 @@ namespace Pamac {
write_log_file ("synchronizing package lists");
cancellable.reset ();
int force = (force_refresh) ? 1 : 0;
string tmp_dbpath = "/tmp/pamac-checkdbs";
if (force_refresh) {
// remove dbs in tmp
try {
Process.spawn_command_line_sync ("rm -rf %s".printf (tmp_dbpath));
Process.spawn_command_line_sync ("bash -c 'rm -rf %s/dbs*'".printf (tmp_path));
} catch (SpawnError e) {
stderr.printf ("SpawnError: %s\n", e.message);
}
} else {
// try to copy refresh dbs in tmp
var file = GLib.File.new_for_path (tmp_dbpath);
var file = GLib.File.new_for_path (tmp_path);
if (file.query_exists ()) {
try {
Process.spawn_command_line_sync ("cp -ru %s/sync %s".printf (tmp_dbpath, alpm_handle.dbpath));
Process.spawn_command_line_sync ("bash -c 'cp -u %s/dbs*/sync/*.{db,files} %ssync'".printf (tmp_path, alpm_handle.dbpath));
} catch (SpawnError e) {
stderr.printf ("SpawnError: %s\n", e.message);
}
......@@ -590,6 +592,7 @@ namespace Pamac {
internal void trans_prepare () {
to_build_pkgs = {};
aur_pkgbases_to_build = new GLib.List<string> ();
to_install_as_dep.remove_all ();
launch_trans_prepare_real ();
}
......@@ -653,6 +656,7 @@ namespace Pamac {
internal void build_prepare () {
to_build_pkgs = {};
aur_pkgbases_to_build = new GLib.List<string> ();
to_install_as_dep.remove_all ();
// get an handle with fake aur db and without emit signal callbacks
alpm_handle = alpm_config.get_handle ();
if (alpm_handle == null) {
......@@ -665,9 +669,8 @@ namespace Pamac {
// emit warnings here
alpm_handle.logcb = (Alpm.LogCallBack) cb_log;
// fake aur db
string tmp_dbpath = "/tmp/pamac-checkdbs";
try {
Process.spawn_command_line_sync ("cp %s/sync/aur.db %ssync".printf (tmp_dbpath, alpm_handle.dbpath));
Process.spawn_command_line_sync ("cp %s/aur.db %ssync".printf (tmp_path, alpm_handle.dbpath));
} catch (SpawnError e) {
stderr.printf ("SpawnError: %s\n", e.message);
}
......@@ -805,7 +808,8 @@ namespace Pamac {
launch_trans_prepare_real ();
alpm_handle.logcb = (Alpm.LogCallBack) cb_log;
}
} else {
}
if (!success) {
trans_release ();
}
}
......@@ -1172,6 +1176,14 @@ void cb_question (Alpm.Question.Data data) {
data.conflict_remove = 1;
break;
case Alpm.Question.Type.REMOVE_PKGS:
string[] unresolvables = {};
unowned Alpm.List<unowned Alpm.Package> list = data.remove_pkgs_packages;
while (list != null) {
unowned Alpm.Package pkg = list.data;
unresolvables += pkg.name;
list.next ();
}
alpm_utils.emit_unresolvables (unresolvables);
// Return an error if there are top-level packages which have unresolvable dependencies
data.remove_pkgs_skip = 0;
break;
......
......@@ -210,6 +210,11 @@ namespace Pamac {
overwrite_files += name;
}
i++;
} else if (arg == "--ignore") {
foreach (unowned string name in args[i + 1].split(",")) {
temporary_ignorepkgs += name;
}
i++;
} else {
targets += arg;
}
......@@ -588,7 +593,7 @@ namespace Pamac {
i++;
}
cuts = split_string (dgettext (null, "list files owned by the given packages"), max_length + 2);
print_aligned (" %s [%s]".printf ("-f, --files", dgettext (null, "file(s)")), ": %s".printf (cuts[0]), max_length);
print_aligned (" %s <%s>".printf ("-f, --files", dgettext (null, "package(s)")), ": %s".printf (cuts[0]), max_length);
i = 1;
while (i < cuts.length) {
print_aligned ("", "%s".printf (cuts[i]), max_length + 2);
......@@ -619,13 +624,20 @@ namespace Pamac {
stdout.printf ("\n\n");
stdout.printf (dgettext (null, "options") + ":\n");
int max_length = 25;
string[] cuts = split_string (dgettext (null, "overwrite conflicting files, multiple patterns can be specified by separating them with a comma"), max_length + 2);
print_aligned (" %s <%s>".printf ("--overwrite", dgettext (null, "glob")), ": %s".printf (cuts[0]), max_length);
string[] cuts = split_string (dgettext (null, "ignore a package upgrade, multiple packages can be specified by separating them with a comma"), max_length + 2);
print_aligned (" %s <%s>".printf ("--ignore", dgettext (null, "package(s)")), ": %s".printf (cuts[0]), max_length);
int i = 1;
while (i < cuts.length) {
print_aligned ("", "%s".printf (cuts[i]), max_length + 2);
i++;
}
cuts = split_string (dgettext (null, "overwrite conflicting files, multiple patterns can be specified by separating them with a comma"), max_length + 2);
print_aligned (" %s <%s>".printf ("--overwrite", dgettext (null, "glob")), ": %s".printf (cuts[0]), max_length);
i = 1;
while (i < cuts.length) {
print_aligned ("", "%s".printf (cuts[i]), max_length + 2);
i++;
}
}
void display_reinstall_help () {
......@@ -705,7 +717,7 @@ namespace Pamac {
i++;
}
cuts = split_string (dgettext (null, "ignore a package upgrade, multiple packages can be specified by separating them with a comma"), max_length + 2);
print_aligned (" %s [%s]".printf ("--ignore", dgettext (null, "package(s)")), ": %s".printf (cuts[0]), max_length);
print_aligned (" %s <%s>".printf ("--ignore", dgettext (null, "package(s)")), ": %s".printf (cuts[0]), max_length);
i = 1;
while (i < cuts.length) {
print_aligned ("", "%s".printf (cuts[i]), max_length + 2);
......@@ -1619,13 +1631,36 @@ namespace Pamac {
try_lock_and_run (start_transaction);
}
async bool check_build_pkgs () {
bool success = true;
foreach (unowned string pkgname in to_build) {
var aur_pkg = yield database.get_aur_pkg (pkgname);
if (aur_pkg.name == "") {
print_error (dgettext (null, "target not found: %s").printf (pkgname) + "\n");
success = false;
}
if (!success) {
break;
}
}
return success;
}
void build_pkgs (string[] to_build) {
this.to_build = to_build;
try_lock_and_run (start_transaction);
bool success = false;
check_build_pkgs.begin ((obj, res) => {
success = check_build_pkgs.end (res);
loop.quit ();
});
loop.run ();
if (success) {
try_lock_and_run (start_transaction);
}
}
void start_transaction () {
transaction.start (to_install, to_remove, to_load, to_build, overwrite_files);
transaction.start (to_install, to_remove, to_load, to_build, temporary_ignorepkgs, overwrite_files);
loop.run ();
}
......
......@@ -69,13 +69,12 @@ namespace Pamac {
public void refresh () {
alpm_config = new AlpmConfig ("/etc/pacman.conf");
// use tmp dbs
alpm_handle = alpm_config.get_handle (false, true);
alpm_handle = alpm_config.get_handle ();
if (alpm_handle == null) {
critical (dgettext (null, "Failed to initialize alpm library"));
return;
} else {
files_handle = alpm_config.get_handle (true, true);
files_handle = alpm_config.get_handle (true);
}
refreshed ();
}
......@@ -121,10 +120,6 @@ namespace Pamac {
return country;
}
internal string get_tmp_db_path () {
return alpm_handle.dbpath;
}
public bool get_checkspace () {
return alpm_handle.checkspace == 1 ? true : false;
}
......@@ -958,11 +953,11 @@ namespace Pamac {
}
// reason
if (alpm_pkg.reason == Alpm.Package.Reason.EXPLICIT) {
reason = _("Explicitly installed");
reason = dgettext (null, "Explicitly installed");
} else if (alpm_pkg.reason == Alpm.Package.Reason.DEPEND) {
reason = _("Installed as a dependency for another package");
reason = dgettext (null, "Installed as a dependency for another package");
} else {
reason = _("Unknown");
reason = dgettext (null, "Unknown");
}
// install_date
time = GLib.Time.local ((time_t) alpm_pkg.installdate);
......@@ -994,7 +989,7 @@ namespace Pamac {
// repos
repo = alpm_pkg.db.name;
// signature
has_signature = alpm_pkg.base64_sig != null ? _("Yes") : _("No");
has_signature = alpm_pkg.base64_sig != null ? dgettext (null, "Yes") : dgettext (null, "No");
}
// depends
list = alpm_pkg.depends;
......@@ -1097,29 +1092,6 @@ namespace Pamac {
return get_pkg_files (pkgname);
}
string get_srcinfo_version (string pkgdir_name) {
StringBuilder version = new StringBuilder ();
// assume file exists
var srcinfo = File.new_for_path (pkgdir_name + "/.SRCINFO");
try {
var dis = new DataInputStream (srcinfo.read ());
string line;
while ((line = dis.read_line ()) != null) {
if ("pkgver = " in line) {
version.append (line.split ("pkgver = ", 2)[1]);
} else if ("pkgrel = " in line) {
version.append ("-");
version.append (line.split ("pkgrel = ", 2)[1]);
// we have all we want
break;
}
}
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);