Fix cleaning of tmp directories after building a project
When we build a project, all its input files are stored in a temporary directory. When the build of the project is finished, and we move to the build of the next project, the temporary directory from the previous build should be removed. However it seems it's not the case anymore, and all temporary directories are kept and only removed when rbm exits at the end.
I think this might be a bug introduced in 777bab01:
@@ -1020,20 +1009,13 @@ sub build_run {
valid_project($project);
$options = { %$options, build_id => Data::UUID->new->create_str };
my $old_cwd = getcwd;
- my $srcdir = project_config($project, 'build_srcdir', $options);
- my $use_srcdir = $srcdir;
- my $tmpdir = File::Temp->newdir(get_tmp_dir($project, $options)
+ my $srcdir = File::Temp->newdir(get_tmp_dir($project, $options)
. '/rbm-XXXXX');
my @cfiles;
- if ($use_srcdir) {
- @cfiles = ($srcdir);
- } else {
- $srcdir = $tmpdir->dirname;
- my $tarfile = maketar($project, $options, $srcdir);
- push @cfiles, $tarfile if $tarfile;
- push @cfiles, copy_files($project, $srcdir);
- push @cfiles, input_files('copy', $project, $options, $srcdir);
- }
+ my $tarfile = maketar($project, $options, $srcdir);
+ push @cfiles, $tarfile if $tarfile;
+ push @cfiles, copy_files($project, $srcdir);
+ push @cfiles, input_files('copy', $project, $options, $srcdir);
my ($remote_tmp_src, $remote_tmp_dst, %build_script);
my @scripts = ('pre', $script_name, 'post');
my %scripts_root = ( pre => 1, post => 1);
We were storing the newdir object in $tmpdir
, then converting it to a script in $srcdir
with the line $srcdir = $tmpdir->dirname;
and never using $tmpdir
after that.
After this commit we are storing the newdir object in $srcdir
and passing it to other functions. I think it is possible that the $srcdir
is cached somewhere and never destroyed (until rbm exits).