2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-04 20:17:55 +00:00

refactor(build): install the genesis postscripts through write_script

builddebs.pl stages the genesis bmcsetup and getipmi helpers into the xCAT
package by writing the rewritten text and then chmod'ing it, which is the third
copy of the write-then-make-executable pair the previous change collapsed. It
was left out because it uses 0755 while the published repo helper uses 0775.

Give write_script an optional mode, defaulting to the 0775 it already used, and
use it for the postscripts with 0755. The two modes stay exactly as they were
-- the postscripts are deliberately not group-writable -- and the test asserts
that the caller's mode is honoured rather than overwritten by the default.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-09-01 16:46:31 -03:00
parent e30437cc4b
commit 3f229cac4c
3 changed files with 15 additions and 7 deletions
+8 -5
View File
@@ -85,13 +85,16 @@ sub write_file {
}
# Write a helper script and make it executable. Both builders ship a
# mklocalrepo.sh beside the packages they publish; a script written without the
# executable bit is published broken, so the mode is not left to the caller to
# remember.
# mklocalrepo.sh beside the packages they publish, and builddebs.pl installs the
# genesis postscripts the same way; a script written without the executable bit
# is shipped broken, so the mode is not left to the caller to remember. It
# still varies -- the published repo helper is group-writable, the postscripts
# are not -- so the caller may say, and 0775 is only the default.
sub write_script {
my ($path, $content) = @_;
my ($path, $content, $mode) = @_;
$mode = 0775 unless defined $mode;
write_file($path, $content);
chmod 0775, $path or die "Cannot chmod $path: $!\n";
chmod $mode, $path or die "Cannot chmod $path: $!\n";
return;
}
+1 -2
View File
@@ -199,8 +199,7 @@ sub with_prepared_tree {
$claim->("postscripts/$f");
my $text = read_file($src);
$text =~ s/xcat\.genesis\.\Q$f\E/$f/g;
write_file($dst, $text);
chmod 0755, $dst;
write_script($dst, $text, 0755);
}
}
# xCAT-genesis-scripts keeps a control file per architecture.
+6
View File
@@ -373,6 +373,12 @@ isnt( git_revision( git => sub { '' }, read_file => sub { '' } ), '',
ok( -x $path, 'and is executable, which is the point of writing it this way' );
is( (stat $path)[2] & 07777, 0775,
'with the mode both builders published before' );
# The genesis postscripts builddebs.pl installs are 0755, not 0775, so the
# mode has to stay the caller's to choose.
my $ps = File::Spec->catfile($dir, 'bmcsetup');
BuildUtils::write_script($ps, "#!/bin/sh\n", 0755);
is( (stat $ps)[2] & 07777, 0755, 'a caller may ask for a different mode' );
}
# ---------------------------------------------------------------- sh() --