[tbb-commits] [rbm/master] Bug 23382: create tmp_dir if it does not exist

gk at torproject.org gk at torproject.org
Thu Sep 7 10:27:25 UTC 2017


commit 296fba79fca70b922cc6eb2be8b830d8074b70e4
Author: Nicolas Vigier <boklm at torproject.org>
Date:   Wed Sep 6 16:54:07 2017 +0200

    Bug 23382: create tmp_dir if it does not exist
---
 lib/RBM.pm               | 21 +++++++++++++--------
 lib/RBM/DefaultConfig.pm |  2 +-
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/lib/RBM.pm b/lib/RBM.pm
index df29a01..b14909f 100644
--- a/lib/RBM.pm
+++ b/lib/RBM.pm
@@ -259,11 +259,17 @@ sub exit_error {
     exit (exists $_[1] ? $_[1] : 1);
 }
 
+sub get_tmp_dir {
+    my ($project, $options) = @_;
+    my $tmp_dir = project_config($project, 'tmp_dir', $options);
+    make_path($tmp_dir);
+    return $tmp_dir;
+}
+
 sub set_git_gpg_wrapper {
     my ($project) = @_;
     my $w = project_config($project, 'gpg_wrapper');
-    my (undef, $tmp) = File::Temp::tempfile(DIR =>
-                        project_config($project, 'tmp_dir'));
+    my (undef, $tmp) = File::Temp::tempfile(DIR => get_tmp_dir($project));
     write_file($tmp, $w);
     chmod 0700, $tmp;
     system('git', 'config', 'gpg.program', $tmp) == 0
@@ -314,7 +320,7 @@ sub git_tag_sign_id {
 sub file_sign_id {
     my ($project, $options) = @_;
     my (undef, $gpg_wrapper) = File::Temp::tempfile(DIR =>
-                        project_config($project, 'tmp_dir', $options));
+                                get_tmp_dir($project, $options));
     write_file($gpg_wrapper, project_config($project, 'gpg_wrapper', $options));
     chmod 0700, $gpg_wrapper;
     my ($stdout, $stderr, $success, $exit_code) =
@@ -445,8 +451,7 @@ sub run_script {
     $f //= \&capture_exec;
     my @res;
     if ($cmd =~ m/^#/) {
-        my (undef, $tmp) = File::Temp::tempfile(DIR =>
-                                project_config($project, 'tmp_dir'));
+        my (undef, $tmp) = File::Temp::tempfile(DIR => get_tmp_dir($project));
         write_file($tmp, $cmd);
         chmod 0700, $tmp;
         @res = $f->($tmp);
@@ -540,7 +545,7 @@ sub maketar {
                 || exit_error 'Error running git archive.';
         if (project_config($project, 'git_submodule', $options)) {
             my $tmpdir = File::Temp->newdir(
-                project_config($project, 'tmp_dir', $options) . '/rbm-XXXXX');
+                get_tmp_dir($project, $options) . '/rbm-XXXXX');
             my ($stdout, $stderr, $success, $exit_code)
                 = capture_exec('git', 'checkout', $commit_hash);
             exit_error "Cannot checkout $commit_hash: $stderr" unless $success;
@@ -952,7 +957,7 @@ sub build_run {
     my $old_cwd = getcwd;
     my $srcdir = project_config($project, 'build_srcdir', $options);
     my $use_srcdir = $srcdir;
-    my $tmpdir = File::Temp->newdir(project_config($project, 'tmp_dir', $options)
+    my $tmpdir = File::Temp->newdir(get_tmp_dir($project, $options)
                                 . '/rbm-XXXXX');
     my @cfiles;
     if ($use_srcdir) {
@@ -1119,7 +1124,7 @@ sub publish {
     project_config($project, 'publish', { error_if_undef => 1 });
     my $publish_src_dir = project_config($project, 'publish_src_dir');
     if (!$publish_src_dir) {
-        $publish_src_dir = File::Temp->newdir(project_config($project, 'tmp_dir')
+        $publish_src_dir = File::Temp->newdir(get_tmp_dir($project)
                                 . '/rbm-XXXXXX');
         build_pkg($project, {output_dir => $publish_src_dir});
     }
diff --git a/lib/RBM/DefaultConfig.pm b/lib/RBM/DefaultConfig.pm
index b1f97cb..d0d893a 100644
--- a/lib/RBM/DefaultConfig.pm
+++ b/lib/RBM/DefaultConfig.pm
@@ -106,7 +106,7 @@ 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)
+    my $tmp_dir = RBM::get_tmp_dir($project, $options)
                   || RBM::exit_error('No tmp_dir specified');
     $rbm_tmp_dir = File::Temp->newdir(TEMPLATE => 'rbm-XXXXXX',
                                       DIR => $tmp_dir);



More information about the tbb-commits mailing list