[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [rbm/master] Bug 34320: Set TMPDIR when running scripts



commit c50d8e22c4fcddc4ed567815b1b0135419c2a53c
Author: Nicolas Vigier <boklm@xxxxxxxxxxxxxx>
Date:   Fri May 29 20:34:23 2020 +0200

    Bug 34320: Set TMPDIR when running scripts
---
 doc/rbm_config.asc | 3 ++-
 lib/RBM.pm         | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/doc/rbm_config.asc b/doc/rbm_config.asc
index 1935cd3..43feb9a 100644
--- a/doc/rbm_config.asc
+++ b/doc/rbm_config.asc
@@ -139,7 +139,8 @@ tmp_dir::
 rbm_tmp_dir::
         A directory created inside +tmp_dir+ using +File::Temp+, that
         you can use to store temporary files. This directory is removed
-        automatically when rbm exits.
+        automatically when rbm exits. When running scripts, the TMPDIR
+        environment variable is also set to this directory.
 
 output_dir::
         The directory where output files (tarballs, spec files or
diff --git a/lib/RBM.pm b/lib/RBM.pm
index 7cc9e24..b9ad1ad 100644
--- a/lib/RBM.pm
+++ b/lib/RBM.pm
@@ -461,8 +461,9 @@ sub run_script {
     my ($project, $cmd, $f) = @_;
     $f //= \&capture_exec;
     my @res;
+    local $ENV{TMPDIR} = project_config($project, 'rbm_tmp_dir');
     if ($cmd =~ m/^#/) {
-        my (undef, $tmp) = File::Temp::tempfile(DIR => get_tmp_dir($project));
+        my (undef, $tmp) = File::Temp::tempfile(DIR => $ENV{TMPDIR});
         path($tmp)->spew_utf8($cmd);
         chmod 0700, $tmp;
         @res = $f->($tmp);
@@ -1146,7 +1147,7 @@ sub build_run {
         foreach my $s (@scripts) {
             my $cmd = $scripts_root{$s} ? project_config($project, 'suexec',
                 { suexec_cmd => "$srcdir/$s" }) : "$srcdir/$s";
-            if (system_log($build_log, $cmd) != 0) {
+            if (run_script($project, $cmd, sub { system_log($build_log, @_) }) != 0) {
                 $error = "Error running $script_name";
                 if (project_config($project, 'debug', $options)) {
                     print STDERR $error, "\nOpening debug shell\n";

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits