From b518a1522978312844b23daa8bbdd58fd5ea939a Mon Sep 17 00:00:00 2001 From: matthiakl Date: Thu, 8 Jul 2021 16:09:00 +0200 Subject: [PATCH] Option to store built AUR packages in a custom directory --- data/interface/preferences_dialog.ui | 59 ++++++++++++++++++++++++++++ data/org.pamac.aur.gschema.xml | 14 +++++++ po/de.po | 40 +++++++++++-------- src/pamac_config.vala | 4 ++ src/preferences_dialog.vala | 33 ++++++++++++++++ src/transaction.vala | 13 ++++-- 6 files changed, 143 insertions(+), 20 deletions(-) diff --git a/data/interface/preferences_dialog.ui b/data/interface/preferences_dialog.ui index 135c5c2..15e65b1 100644 --- a/data/interface/preferences_dialog.ui +++ b/data/interface/preferences_dialog.ui @@ -847,6 +847,65 @@ All AUR users should be familiar with the build process. 3 + + + True + False + 26 + 12 + True + + + True + True + Keep built packages + end + 6 + 6 + 6 + 6 + + + False + True + 1 + + + + + True + False + start + True + + + False + True + 0 + + + + + True + False + end + 24 + select-folder + + + + False + True + 2 + + + + + False + True + 3 + + aur diff --git a/data/org.pamac.aur.gschema.xml b/data/org.pamac.aur.gschema.xml index aef3a61..7129f24 100644 --- a/data/org.pamac.aur.gschema.xml +++ b/data/org.pamac.aur.gschema.xml @@ -28,5 +28,19 @@ Directory where to build packages that come from the AUR + + false + Copy AUR packages + + Save built packages on disk + + + + "" + AUR package directory + + Directory where to move built packages that come from the AUR + + diff --git a/po/de.po b/po/de.po index 4e69fda..da9b130 100644 --- a/po/de.po +++ b/po/de.po @@ -92,17 +92,17 @@ msgstr "Paket %s hat keine gültige Architektur" #: ../src/pamac-system-daemon/system_daemon.vala #, c-format msgid "unable to satisfy dependency '%s' required by %s" -msgstr "" +msgstr "Kann Abhängigkeit '%s' von %s nicht erfüllen" #: ../src/pamac-system-daemon/system_daemon.vala #, c-format msgid "installing %s (%s) breaks dependency '%s' required by %s" -msgstr "" +msgstr "Installation von %s (%s) verletzt Abhängigkeit '%s' von %s" #: ../src/pamac-system-daemon/system_daemon.vala #, c-format msgid "removing %s breaks dependency '%s' required by %s" -msgstr "" +msgstr "Entfernen von %s verletzt Abhängigkeit '%s' von %s" #: ../src/pamac-system-daemon/system_daemon.vala #, c-format @@ -190,7 +190,7 @@ msgstr "Wird neu installiert" #: ../src/transaction.vala msgid "To upgrade" -msgstr "" +msgstr "Zu aktualisieren" #: ../src/transaction.vala ../src/pamac-manager/manager_window.vala msgid "Total download size" @@ -364,7 +364,7 @@ msgstr "" #: ../src/pamac-install/installer.vala msgid "Unable to lock database!" -msgstr "" +msgstr "Kann Datenbank nicht sperren!" #: ../src/pamac-tray/tray.vala ../src/pamac-manager/manager_window.vala msgid "Your system is up-to-date" @@ -396,7 +396,7 @@ msgstr "Pamac wird bereits ausgeführt" #: ../src/pamac-manager/manager.vala msgid "Refresh Databases" -msgstr "" +msgstr "Datenbanken aktualisieren" #: ../src/pamac-manager/manager.vala ../data/interface/manager_window.ui msgid "View History" @@ -417,7 +417,7 @@ msgstr "Über" #: ../src/pamac-manager/manager.vala msgid "Quit" -msgstr "" +msgstr "Schließen" #: ../src/pamac-manager/manager_window.vala msgid "Deselect" @@ -425,7 +425,7 @@ msgstr "Abwählen" #: ../src/pamac-manager/manager_window.vala msgid "Upgrade" -msgstr "" +msgstr "Aktualisieren" #: ../src/pamac-manager/manager_window.vala ../data/interface/manager_window.ui msgid "Install" @@ -480,11 +480,11 @@ msgstr "Paketquelle" #: ../src/pamac-manager/manager_window.vala msgid "Download size" -msgstr "" +msgstr "Download Größe" #: ../src/pamac-manager/manager_window.vala msgid "Installed size" -msgstr "" +msgstr "Installierte Größe" #: ../src/pamac-manager/manager_window.vala ../data/interface/manager_window.ui msgid "Groups" @@ -603,7 +603,11 @@ msgstr "Anzahl der im Cache verbleibenden Paketversionen" #: ../src/preferences_dialog.vala msgid "Build directory" -msgstr "" +msgstr "Build Verzeichnis" + +#: ../src/preferences_dialog.vala +msgid "Package directory" +msgstr "Paket Verzeichnis" #: ../src/preferences_dialog.vala msgid "Worldwide" @@ -664,7 +668,7 @@ msgstr "Paketquellen" #: ../data/interface/manager_window.ui msgid "Updates" -msgstr "" +msgstr "Aktualisierungen" #: ../data/interface/manager_window.ui msgid "Version" @@ -724,7 +728,7 @@ msgstr "Suche nach Aktualisierungen" #: ../data/interface/preferences_dialog.ui msgid "Update files databases (more details but slower)" -msgstr "" +msgstr "Aktualisiere Datei-Datenbanken (mehr Details, aber langsamer)" #: ../data/interface/preferences_dialog.ui msgid "Hide tray icon when no update available" @@ -742,15 +746,15 @@ msgstr "Allgemein" #: ../data/interface/preferences_dialog.ui msgid "Background color:" -msgstr "" +msgstr "Hintergrund Farbe:" #: ../data/interface/preferences_dialog.ui msgid "Text color:" -msgstr "" +msgstr "Text Farbe:" #: ../data/interface/preferences_dialog.ui msgid "Font:" -msgstr "" +msgstr "Schrift:" #: ../data/interface/preferences_dialog.ui msgid "Terminal" @@ -798,6 +802,10 @@ msgstr "Suche standardmäßig im AUR" msgid "Check for updates from AUR" msgstr "Suche nach Aktualisierungen aus dem AUR" +#: ../data/interface/preferences_dialog.ui +msgid "Keep built packages" +msgstr "Behalte erstellte Pakete" + #: ../data/interface/preferences_dialog.ui msgid "Remove only the versions of uninstalled packages" msgstr "Entferne nur Versionen von deinstallierten Paketen" diff --git a/src/pamac_config.vala b/src/pamac_config.vala index 28284d0..d907293 100644 --- a/src/pamac_config.vala +++ b/src/pamac_config.vala @@ -31,6 +31,8 @@ namespace Pamac { public bool search_aur { get; private set; } public string aur_build_dir { get; private set; } public bool check_aur_updates { get; private set; } + public bool aur_keep_pkgs { get; private set; } + public string aur_move_dir { get; private set; } #endif public uint64 keep_num_pkgs { get; private set; } public bool rm_only_uninstalled { get; private set; } @@ -92,6 +94,8 @@ namespace Pamac { search_aur = settings.get_boolean ("search-in-aur"); check_aur_updates = settings.get_boolean ("check-aur-updates"); aur_build_dir = settings.get_string ("build-directory"); + aur_keep_pkgs = settings.get_boolean("aur-keep-pkgs"); + aur_move_dir = settings.get_string("move-directory"); #endif } } diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala index 487df6d..a50a123 100644 --- a/src/preferences_dialog.vala +++ b/src/preferences_dialog.vala @@ -65,6 +65,12 @@ namespace Pamac { Gtk.FileChooserButton aur_build_dir_file_chooser; [GtkChild] Gtk.CheckButton check_aur_updates_checkbutton; + [GtkChild] + Gtk.Switch aur_keep_pkgs_button; + [GtkChild] + Gtk.Label aur_move_dir_label; + [GtkChild] + Gtk.FileChooserButton aur_move_dir_file_chooser; #endif [GtkChild] Gtk.Label cache_keep_nb_label; @@ -94,6 +100,7 @@ namespace Pamac { stack.remove (aur_config_box); #else aur_build_dir_label.set_markup (dgettext (null, "Build directory") +":"); + aur_move_dir_label.set_markup (dgettext (null, "Package directory") +":"); #endif remove_unrequired_deps_button.active = transaction.recurse; update_files_db_button.active = transaction.update_files_db; @@ -193,6 +200,13 @@ namespace Pamac { search_aur_checkbutton.toggled.connect (on_search_aur_checkbutton_toggled); aur_build_dir_file_chooser.file_set.connect (on_aur_build_dir_set); check_aur_updates_checkbutton.toggled.connect (on_check_aur_updates_checkbutton_toggled); + aur_keep_pkgs_button.sensitive = transaction.enable_aur; + aur_keep_pkgs_button.active = transaction.aur_keep_pkgs; + aur_keep_pkgs_button.state_set.connect(on_aur_keep_pkgs_button_state_set); + aur_move_dir_label.sensitive = transaction.enable_aur && transaction.aur_keep_pkgs; + aur_move_dir_file_chooser.sensitive = transaction.enable_aur && transaction.aur_keep_pkgs; + aur_move_dir_file_chooser.set_filename(transaction.aur_move_dir); + aur_move_dir_file_chooser.file_set.connect(on_aur_move_dir_set); #endif } @@ -289,6 +303,14 @@ namespace Pamac { transaction.start_save_pamac_config (); return true; } + + bool on_aur_keep_pkgs_button_state_set (bool new_state) { + var settings = new Settings ("org.pamac.aur"); + settings.set_boolean ("aur-keep-pkgs", new_state); + config_changed(); + transaction.start_save_pamac_config (); + return true; + } void on_search_aur_checkbutton_toggled () { var settings = new Settings ("org.pamac.aur"); @@ -303,6 +325,13 @@ namespace Pamac { config_changed(); transaction.start_save_pamac_config (); } + + void on_aur_move_dir_set () { + var settings = new Settings ("org.pamac.aur"); + settings.set_string ("move-directory", aur_move_dir_file_chooser.get_filename ()); + config_changed(); + transaction.start_save_pamac_config (); + } void on_check_aur_updates_checkbutton_toggled () { var settings = new Settings ("org.pamac.aur"); @@ -341,6 +370,10 @@ namespace Pamac { aur_build_dir_file_chooser.sensitive = transaction.enable_aur; check_aur_updates_checkbutton.active = transaction.check_aur_updates; check_aur_updates_checkbutton.sensitive = transaction.enable_aur; + aur_keep_pkgs_button.sensitive = transaction.enable_aur; + aur_keep_pkgs_button.state = transaction.aur_keep_pkgs; + aur_move_dir_label.sensitive = transaction.enable_aur && transaction.aur_keep_pkgs; + aur_move_dir_file_chooser.sensitive = transaction.enable_aur && transaction.aur_keep_pkgs; #endif } diff --git a/src/transaction.vala b/src/transaction.vala index 28688d6..1effa7a 100644 --- a/src/transaction.vala +++ b/src/transaction.vala @@ -114,7 +114,7 @@ namespace Pamac { public signal void save_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon); #else public signal void save_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, - bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates); + bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates, bool aur_keep_pkgs, string aur_move_dir); #endif public signal void write_alpm_config_finished (bool checkspace); public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method); @@ -146,6 +146,8 @@ namespace Pamac { public bool enable_aur { get { return pamac_config.enable_aur; } } public bool search_aur { get { return pamac_config.search_aur; } } public string aur_build_dir { get { return pamac_config.aur_build_dir; } } + public bool aur_keep_pkgs { get { return pamac_config.aur_keep_pkgs; } } + public string aur_move_dir { get { return pamac_config.aur_move_dir; } } #endif public uint64 keep_num_pkgs { get { return pamac_config.keep_num_pkgs; } } public bool rm_only_uninstalled { get { return pamac_config.rm_only_uninstalled; } } @@ -228,7 +230,7 @@ namespace Pamac { public signal void save_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon); #else public signal void save_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, - bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates); + bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates, bool aur_keep_pkgs, string aur_move_dir); #endif public signal void write_alpm_config_finished (bool checkspace); public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method); @@ -1401,6 +1403,9 @@ namespace Pamac { foreach (unowned string path in standard_output.split ("\n")) { if (path != "" && !(path in built_pkgs)) { built_pkgs += path; + if(aur_keep_pkgs) { + yield spawn_in_term ({"cp", path, aur_move_dir}); + } } } } @@ -2094,7 +2099,7 @@ namespace Pamac { void on_save_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon) { #else void on_save_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon, - bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates) { + bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates, bool aur_keep_pkgs, string aur_move_dir) { #endif system_daemon.save_pamac_config_finished.disconnect (on_save_pamac_config_finished); pamac_config.reload (); @@ -2106,7 +2111,7 @@ namespace Pamac { save_pamac_config_finished (recurse, refresh_period, no_update_hide_icon); #else save_pamac_config_finished (recurse, refresh_period, no_update_hide_icon, - enable_aur, search_aur, aur_build_dir, check_aur_updates); + enable_aur, search_aur, aur_build_dir, check_aur_updates, aur_keep_pkgs, aur_move_dir); #endif }