Ticket #23382: 0001-Bug-23382-create-tmp_dir-if-it-does-not-exist.patch

File 0001-Bug-23382-create-tmp_dir-if-it-does-not-exist.patch, 4.0 KB (added by boklm, 2 years ago)
  • lib/RBM.pm

    From 6dcaa962f27086ed6304e00c60bfaa357b6e8de9 Mon Sep 17 00:00:00 2001
    From: Nicolas Vigier <boklm@torproject.org>
    Date: Wed, 6 Sep 2017 16:54:07 +0200
    Subject: [PATCH] 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 b sub exit_error { 
    259259    exit (exists $_[1] ? $_[1] : 1);
    260260}
    261261
     262sub get_tmp_dir {
     263    my ($project, $options) = @_;
     264    my $tmp_dir = project_config($project, 'tmp_dir', $options);
     265    make_path($tmp_dir);
     266    return $tmp_dir;
     267}
     268
    262269sub set_git_gpg_wrapper {
    263270    my ($project) = @_;
    264271    my $w = project_config($project, 'gpg_wrapper');
    265     my (undef, $tmp) = File::Temp::tempfile(DIR =>
    266                         project_config($project, 'tmp_dir'));
     272    my (undef, $tmp) = File::Temp::tempfile(DIR => get_tmp_dir($project));
    267273    write_file($tmp, $w);
    268274    chmod 0700, $tmp;
    269275    system('git', 'config', 'gpg.program', $tmp) == 0
    sub git_tag_sign_id { 
    314320sub file_sign_id {
    315321    my ($project, $options) = @_;
    316322    my (undef, $gpg_wrapper) = File::Temp::tempfile(DIR =>
    317                         project_config($project, 'tmp_dir', $options));
     323                                get_tmp_dir($project, $options));
    318324    write_file($gpg_wrapper, project_config($project, 'gpg_wrapper', $options));
    319325    chmod 0700, $gpg_wrapper;
    320326    my ($stdout, $stderr, $success, $exit_code) =
    sub run_script { 
    445451    $f //= \&capture_exec;
    446452    my @res;
    447453    if ($cmd =~ m/^#/) {
    448         my (undef, $tmp) = File::Temp::tempfile(DIR =>
    449                                 project_config($project, 'tmp_dir'));
     454        my (undef, $tmp) = File::Temp::tempfile(DIR => get_tmp_dir($project));
    450455        write_file($tmp, $cmd);
    451456        chmod 0700, $tmp;
    452457        @res = $f->($tmp);
    sub maketar { 
    540545                || exit_error 'Error running git archive.';
    541546        if (project_config($project, 'git_submodule', $options)) {
    542547            my $tmpdir = File::Temp->newdir(
    543                 project_config($project, 'tmp_dir', $options) . '/rbm-XXXXX');
     548                get_tmp_dir($project, $options) . '/rbm-XXXXX');
    544549            my ($stdout, $stderr, $success, $exit_code)
    545550                = capture_exec('git', 'checkout', $commit_hash);
    546551            exit_error "Cannot checkout $commit_hash: $stderr" unless $success;
    sub build_run { 
    952957    my $old_cwd = getcwd;
    953958    my $srcdir = project_config($project, 'build_srcdir', $options);
    954959    my $use_srcdir = $srcdir;
    955     my $tmpdir = File::Temp->newdir(project_config($project, 'tmp_dir', $options)
     960    my $tmpdir = File::Temp->newdir(get_tmp_dir($project, $options)
    956961                                . '/rbm-XXXXX');
    957962    my @cfiles;
    958963    if ($use_srcdir) {
    sub publish { 
    11191124    project_config($project, 'publish', { error_if_undef => 1 });
    11201125    my $publish_src_dir = project_config($project, 'publish_src_dir');
    11211126    if (!$publish_src_dir) {
    1122         $publish_src_dir = File::Temp->newdir(project_config($project, 'tmp_dir')
     1127        $publish_src_dir = File::Temp->newdir(get_tmp_dir($project)
    11231128                                . '/rbm-XXXXXX');
    11241129        build_pkg($project, {output_dir => $publish_src_dir});
    11251130    }
  • lib/RBM/DefaultConfig.pm

    diff --git a/lib/RBM/DefaultConfig.pm b/lib/RBM/DefaultConfig.pm
    index b1f97cb..d0d893a 100644
    a b sub rbm_tmp_dir { 
    106106    my ($project, $options) = @_;
    107107    CORE::state $rbm_tmp_dir;
    108108    return $rbm_tmp_dir->dirname if $rbm_tmp_dir;
    109     my $tmp_dir = RBM::project_config($project, 'tmp_dir', $options)
     109    my $tmp_dir = RBM::get_tmp_dir($project, $options)
    110110                  || RBM::exit_error('No tmp_dir specified');
    111111    $rbm_tmp_dir = File::Temp->newdir(TEMPLATE => 'rbm-XXXXXX',
    112112                                      DIR => $tmp_dir);