fix: handle spaces in working directory path

Buildroot in spec file doesn't support spaces in some RPM versions
(ALT Linux). Removed it from spec since --buildroot is already passed
on command line. Also quoted cd argument.
This commit is contained in:
Anton Farygin
2025-12-23 10:46:52 +03:00
committed by Syed Shahrukh Hussain
parent de7aa3b0f8
commit decc4d75c8

View File

@@ -463,9 +463,8 @@ sub prep {
# Write out the spec file. # Write out the spec file.
my $spec="$dir/".$this->name."-".$this->version."-".$this->release.".spec"; my $spec="$dir/".$this->name."-".$this->version."-".$this->release.".spec";
open (OUT, ">$spec") || die "$spec: $!"; open (OUT, ">$spec") || die "$spec: $!";
my $pwd=`pwd`; # Note: Buildroot is passed via --buildroot command line option
chomp $pwd; # to handle paths with spaces correctly
print OUT "Buildroot: $pwd/$dir\n"; # must be absolute dirname
print OUT "Name: ".$this->name."\n"; print OUT "Name: ".$this->name."\n";
print OUT "Version: ".$this->version."\n"; print OUT "Version: ".$this->version."\n";
print OUT "Release: ".$this->release."\n"; print OUT "Release: ".$this->release."\n";
@@ -574,7 +573,7 @@ sub build {
$opts.=" $ENV{RPMBUILDOPT}" if exists $ENV{RPMBUILDOPT}; $opts.=" $ENV{RPMBUILDOPT}" if exists $ENV{RPMBUILDOPT};
my $pwd=`pwd`; my $pwd=`pwd`;
chomp $pwd; chomp $pwd;
my $command="cd $dir; $buildcmd --buildroot='$pwd/$dir' -bb $opts '".$this->name."-".$this->version."-".$this->release.".spec'"; my $command="cd '$dir'; $buildcmd --buildroot='$pwd/$dir' -bb $opts '".$this->name."-".$this->version."-".$this->release.".spec'";
my $log=$this->runpipe(1, "$command 2>&1"); my $log=$this->runpipe(1, "$command 2>&1");
if ($?) { if ($?) {
die "Package build failed. Here's the log of the command ($command):\n", $log; die "Package build failed. Here's the log of the command ($command):\n", $log;