Skip to content

Commit 19e5e20

Browse files
committed
build: Updated create_dirs api for windows packaging build
1 parent d285b29 commit 19e5e20

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

contrib/windows/glpi-agent-packaging.pl

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,8 @@ sub run {
669669

670670
use parent qw(Perl::Dist::Strawberry);
671671

672-
use File::Path qw(remove_tree);
673-
use File::Spec::Functions qw(canonpath);
672+
use File::Path qw(remove_tree make_path);
673+
use File::Spec::Functions qw(canonpath catdir);
674674
use File::Glob qw(:glob);
675675
use Time::HiRes qw(usleep);
676676
use PerlBuildJob;
@@ -694,16 +694,39 @@ sub create_dirs {
694694
foreach my $global (qw(image_dir build_dir debug_dir env_dir)) {
695695
my $dir = $self->global->{$global}
696696
or next;
697-
remove_tree($dir) if -d $dir;
697+
next unless -d $dir;
698+
699+
my $delete = '';
700+
if ($global eq 'build_dir') {
701+
$delete = catdir($dir, "msi");
702+
next unless -d $delete;
703+
} else {
704+
$delete = $dir;
705+
}
706+
707+
remove_tree($delete) or die "ERROR: cannot delete '$delete'\n";
698708

699709
# We may have some issue with fs synchro, be ready to wait a little
700710
my $timeout = time + 10;
701-
while (-d $dir && time < $timeout) {
711+
while ($delete && -d $delete && time < $timeout) {
702712
usleep(100000);
703713
}
714+
-d $dir or make_path($dir) or die "ERROR: cannot create '$dir'\n";
704715
}
705716

706-
$self->SUPER::create_dirs();
717+
my $wdir = $self->global->{working_dir};
718+
unless (-d $wdir) {
719+
make_path($wdir) or die "ERROR: cannot create '$wdir'\n";
720+
}
721+
722+
make_path(catdir($self->global->{env_dir}, 'temp'));
723+
make_path(catdir($self->global->{env_dir}, 'AppDataRoaming'));
724+
make_path(catdir($self->global->{env_dir}, 'AppDataLocal'));
725+
make_path(catdir($self->global->{env_dir}, 'UserProfile'));
726+
727+
# Create only if not exists
728+
-d $self->global->{restore_dir} or make_path($self->global->{restore_dir}) or die "ERROR: cannot create '".$self->global->{restore_dir}."'\n";
729+
-d $self->global->{output_dir} or make_path($self->global->{output_dir}) or die "ERROR: cannot create '".$self->global->{output_dir}."'\n";
707730
}
708731

709732
sub ask_about_restorepoint {

0 commit comments

Comments
 (0)