commit 690200770631f4adcfbbe7988379eb39698e11ab
Author: Nicolas Vigier <bo...@torproject.org>
Date:   Fri Aug 11 12:25:55 2017 +0200

    Add the rbm_tmp_dir option
---
 NEWS                     |  2 ++
 doc/rbm_config.asc       |  5 +++++
 lib/RBM/DefaultConfig.pm | 13 +++++++++++++
 3 files changed, 20 insertions(+)

diff --git a/NEWS b/NEWS
index 4eac374..c43dc2d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+- Add the rbm_tmp_dir option
+
 - Add the input_files_paths option
 
 - Add the ENV option
diff --git a/doc/rbm_config.asc b/doc/rbm_config.asc
index 2e9b8ab..dc3b5e4 100644
--- a/doc/rbm_config.asc
+++ b/doc/rbm_config.asc
@@ -136,6 +136,11 @@ tmp_dir::
         This directory will contains some scripts that will be executed,
         so it should not be on a partition mounted as noexec.
 
+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.
+
 output_dir::
         The directory where output files (tarballs, spec files or
         packages) are created. The default value is +out+.
diff --git a/lib/RBM/DefaultConfig.pm b/lib/RBM/DefaultConfig.pm
index cf0ed74..63021e9 100644
--- a/lib/RBM/DefaultConfig.pm
+++ b/lib/RBM/DefaultConfig.pm
@@ -13,6 +13,7 @@ use File::Basename;
 use RBM;
 use Cwd qw(getcwd);
 use IO::CaptureOutput qw(capture_exec);
+use File::Temp;
 
 sub git_describe {
     my ($project, $options) = @_;
@@ -101,10 +102,22 @@ sub docker_version {
     RBM::exit_error("Could not find docker version");
 }
 
+sub rbm_tmp_dir {
+    my ($project, $options) = @_;
+    CORE::state $rbm_tmp_dir;
+    return $rbm_tmp_dir->dirname if $rbm_tmp_dir;
+    my $tmp_dir = RBM::project_config($project, 'tmp_dir', $options)
+                  || RBM::exit_error('No tmp_dir specified');
+    $rbm_tmp_dir = File::Temp->newdir(TEMPLATE => 'rbm-XXXXXX',
+                                      DIR => $tmp_dir);
+    return $rbm_tmp_dir->dirname;
+}
+
 our %default_config = (
     sysconf_file  => '/etc/rbm.conf',
     localconf_file=> 'rbm.local.conf',
     tmp_dir       => '[% GET ENV.TMPDIR ? ENV.TMPDIR : "/tmp"; %]',
+    rbm_tmp_dir   => \&rbm_tmp_dir,
     projects_dir  => 'projects',
     output_dir    => 'out',
     git_clone_dir => 'git_clones',

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

Reply via email to