Browse Source

add build dir

tags/v5.2.0
Chris Cromer 2 years ago
parent
commit
8a1f88d8f9
7 changed files with 103 additions and 10 deletions
  1. +3
    -0
      data/config/pamac.conf
  2. +4
    -0
      po/pamac.pot
  3. +42
    -0
      resources/preferences_dialog.ui
  4. +15
    -0
      src/pamac_config.vala
  5. +24
    -1
      src/preferences_dialog.vala
  6. +2
    -2
      src/system_daemon.vala
  7. +13
    -7
      src/transaction.vala

+ 3
- 0
data/config/pamac.conf View File

@@ -19,5 +19,8 @@ RefreshPeriod = 6
## When AUR support is enabled check for updates from AUR:
#CheckAURUpdates

## AUR build directory:
BuildDirectory = /tmp

## Do not ask for confirmation when building packages:
#NoConfirmBuild

+ 4
- 0
po/pamac.pot View File

@@ -549,6 +549,10 @@ msgstr ""
msgid "Number of versions of each package to keep in the cache"
msgstr ""

#: ../src/preferences_dialog.vala
msgid "Build directory"
msgstr ""

#: ../src/preferences_dialog.vala
msgid "Worldwide"
msgstr ""

+ 42
- 0
resources/preferences_dialog.ui View File

@@ -620,6 +620,48 @@ All AUR users should be familiar with the build process.</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">26</property>
<property name="spacing">12</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkLabel" id="aur_build_dir_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="aur_build_dir_file_chooser">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="margin_left">24</property>
<property name="action">select-folder</property>
<property name="title" translatable="yes"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_aur_updates_checkbutton">
<property name="label" translatable="yes">Check for updates from AUR</property>

+ 15
- 0
src/pamac_config.vala View File

@@ -27,6 +27,7 @@ namespace Pamac {
public bool no_update_hide_icon { get; private set; }
public bool enable_aur { get; private set; }
public bool search_aur { get; private set; }
public string aur_build_dir { get; private set; }
public bool check_aur_updates { get; private set; }
public unowned HashTable<string,string> environment_variables {
get {
@@ -71,6 +72,7 @@ namespace Pamac {
no_update_hide_icon = false;
enable_aur = false;
search_aur = false;
aur_build_dir = "/tmp";
check_aur_updates = false;
parse_file (conf_path);
}
@@ -109,6 +111,10 @@ namespace Pamac {
enable_aur = true;
} else if (key == "SearchInAURByDefault") {
search_aur = true;
} else if (key == "BuildDirectory") {
if (splitted.length == 2) {
aur_build_dir = splitted[1]._strip ();
}
} else if (key == "CheckAURUpdates") {
check_aur_updates = true;
}
@@ -188,6 +194,13 @@ namespace Pamac {
} else {
data.append (line + "\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");
}
} else if (line.contains ("CheckAURUpdates")) {
if (new_conf.lookup_extended ("CheckAURUpdates", null, out variant)) {
if (variant.get_boolean ()) {
@@ -244,6 +257,8 @@ namespace Pamac {
} else {
data.append ("#SearchInAURByDefault\n");
}
} else if (key == "BuildDirectory") {
data.append ("BuildDirectory = %s\n".printf (val.get_string ()));
} else if (key == "CheckAURUpdates") {
if (val.get_boolean ()) {
data.append ("CheckAURUpdates\n");

+ 24
- 1
src/preferences_dialog.vala View File

@@ -51,6 +51,10 @@ namespace Pamac {
[GtkChild]
Gtk.CheckButton search_aur_checkbutton;
[GtkChild]
Gtk.Label aur_build_dir_label;
[GtkChild]
Gtk.FileChooserButton aur_build_dir_file_chooser;
[GtkChild]
Gtk.CheckButton check_aur_updates_checkbutton;
[GtkChild]
Gtk.Label cache_keep_nb_label;
@@ -70,6 +74,7 @@ namespace Pamac {
this.transaction = transaction;
refresh_period_label.set_markup (dgettext (null, "How often to check for updates, value in hours") +":");
cache_keep_nb_label.set_markup (dgettext (null, "Number of versions of each package to keep in the cache") +":");
aur_build_dir_label.set_markup (dgettext (null, "Build directory") +":");
remove_unrequired_deps_button.active = transaction.recurse;
check_space_button.active = transaction.get_checkspace ();
if (transaction.refresh_period == 0) {
@@ -133,10 +138,20 @@ namespace Pamac {
enable_aur_button.active = transaction.enable_aur;
search_aur_checkbutton.active = transaction.search_aur;
search_aur_checkbutton.sensitive = transaction.enable_aur;
aur_build_dir_label.sensitive = transaction.enable_aur;
aur_build_dir_file_chooser.sensitive = transaction.enable_aur;
aur_build_dir_file_chooser.set_filename (transaction.aur_build_dir);
// add /tmp choice always visible
try {
aur_build_dir_file_chooser.add_shortcut_folder ("/tmp");
} catch (GLib.Error e) {
stderr.printf ("%s\n", e.message);
}
check_aur_updates_checkbutton.active = transaction.check_aur_updates;
check_aur_updates_checkbutton.sensitive = transaction.enable_aur;
enable_aur_button.state_set.connect (on_enable_aur_button_state_set);
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);
}

@@ -187,6 +202,12 @@ namespace Pamac {
transaction.start_write_pamac_config (new_pamac_conf);
}

void on_aur_build_dir_set () {
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
new_pamac_conf.insert ("BuildDirectory", new Variant.string (aur_build_dir_file_chooser.get_filename ()));
transaction.start_write_pamac_config (new_pamac_conf);
}

void on_check_aur_updates_checkbutton_toggled () {
var new_pamac_conf = new HashTable<string,Variant> (str_hash, str_equal);
new_pamac_conf.insert ("CheckAURUpdates", new Variant.boolean (check_aur_updates_checkbutton.active));
@@ -194,7 +215,7 @@ namespace Pamac {
}

void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates) {
bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates) {
remove_unrequired_deps_button.state = recurse;
if (refresh_period == 0) {
check_updates_button.state = false;
@@ -215,6 +236,8 @@ namespace Pamac {
enable_aur_button.state = enable_aur;
search_aur_checkbutton.active = search_aur;
search_aur_checkbutton.sensitive = enable_aur;
aur_build_dir_label.sensitive = enable_aur;
aur_build_dir_file_chooser.sensitive = enable_aur;
check_aur_updates_checkbutton.active = check_aur_updates;
check_aur_updates_checkbutton.sensitive = enable_aur;
}

+ 2
- 2
src/system_daemon.vala View File

@@ -87,7 +87,7 @@ namespace Pamac {
public signal void trans_commit_finished (bool success);
public signal void get_authorization_finished (bool authorized);
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates);
bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates);
public signal void write_alpm_config_finished (bool checkspace);
public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method);
public signal void generate_mirrors_list_data (string line);
@@ -339,7 +339,7 @@ namespace Pamac {
pamac_config.reload ();
}
write_pamac_config_finished (pamac_config.recurse, pamac_config.refresh_period, pamac_config.no_update_hide_icon,
pamac_config.enable_aur, pamac_config.search_aur, pamac_config.check_aur_updates);
pamac_config.enable_aur, pamac_config.search_aur, pamac_config.aur_build_dir, pamac_config.check_aur_updates);
});
}


+ 13
- 7
src/transaction.vala View File

@@ -87,7 +87,7 @@ namespace Pamac {
public signal void trans_commit_finished (bool success);
public signal void get_authorization_finished (bool authorized);
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates);
bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates);
public signal void write_alpm_config_finished (bool checkspace);
public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method);
public signal void generate_mirrors_list_data (string line);
@@ -119,6 +119,7 @@ namespace Pamac {
public bool recurse { get { return pamac_config.recurse; } }
public uint64 refresh_period { get { return pamac_config.refresh_period; } }
public bool search_aur { get { return pamac_config.search_aur; } }
public string aur_build_dir { get { return pamac_config.aur_build_dir; } }

//Alpm.TransFlag
int flags;
@@ -171,7 +172,7 @@ namespace Pamac {
public signal void finished (bool success);
public signal void set_pkgreason_finished ();
public signal void write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates);
bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates);
public signal void write_alpm_config_finished (bool checkspace);
public signal void write_mirrors_config_finished (string choosen_country, string choosen_generation_method);
public signal void generate_mirrors_list ();
@@ -749,7 +750,7 @@ namespace Pamac {
try {
pkg = yield user_daemon.get_aur_details (pkgname);
} catch (IOError e) {
stderr.printf ("IOError: %s\n", e.message);
stderr.printf ("IOError: %s\n", e.message);
}
return pkg;
}
@@ -1079,7 +1080,12 @@ namespace Pamac {
to_build.remove_all ();
string [] built_pkgs = {};
int status = 1;
string builddir = "/tmp/pamac-build-%s".printf (Environment.get_user_name ());
string builddir;
if (aur_build_dir == "/tmp") {
builddir = "/tmp/pamac-build-%s".printf (Environment.get_user_name ());
} else {
builddir = aur_build_dir;
}
status = yield spawn_in_term ({"mkdir", "-p", builddir});
if (status == 0) {
status = yield spawn_in_term ({"rm", "-rf", pkgname}, builddir);
@@ -1472,7 +1478,7 @@ namespace Pamac {
previous_percent = 0;
previous_textbar = "";
total_download = total;
// this is emitted at the end of the total download
// this is emitted at the end of the total download
// with the value 0 so stop our timer
if (total == 0) {
timer.stop ();
@@ -1748,7 +1754,7 @@ namespace Pamac {
}

void on_write_pamac_config_finished (bool recurse, uint64 refresh_period, bool no_update_hide_icon,
bool enable_aur, bool search_aur, bool check_aur_updates) {
bool enable_aur, bool search_aur, string aur_build_dir, bool check_aur_updates) {
system_daemon.write_pamac_config_finished.disconnect (on_write_pamac_config_finished);
pamac_config.reload ();
flags = (1 << 4); //Alpm.TransFlag.CASCADE
@@ -1756,7 +1762,7 @@ namespace Pamac {
flags |= (1 << 5); //Alpm.TransFlag.RECURSE
}
write_pamac_config_finished (recurse, refresh_period, no_update_hide_icon,
enable_aur, search_aur, check_aur_updates);
enable_aur, search_aur, aur_build_dir, check_aur_updates);
}

void on_write_alpm_config_finished (bool checkspace) {

Loading…
Cancel
Save