mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-05 07:49:59 +00:00
test(xcat-core): xCATsn installs its templates under share/xcat/xCAT
xCATsn.spec extracts templates.tar.gz in %{prefix}/share/xcat. buildrpms.pl
creates that archive from the checkout root, so its members start with
xCAT/templates and the templates install under share/xcat/xCAT/templates.
With one shared SOURCES directory the xCAT build often wrote the archive
first, rooted at templates/, and the existence check kept it.
The tar step moves unchanged into stage_xcatsn_templates in
XCAT::BuildUtils. xcatsn_templates_staged.t stages the archive and reads its
members. It fails on this commit: the members start with xCAT/, and a second
staging keeps the old archive.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -26,7 +26,7 @@ use feature 'say';
|
||||
our @EXPORT_OK = qw(
|
||||
source_date_epoch snap_release deb_version
|
||||
stage_probe_helpers XCAT_PROBE_HELPERS stage_genesis_base_sources
|
||||
stage_xcat_probe_sources
|
||||
stage_xcat_probe_sources stage_xcatsn_templates
|
||||
deb_package_arches dist_arches default_dists
|
||||
orig_tarball_name upstream_version resolve_dest
|
||||
pin_control_version rewrite_changelog_header
|
||||
@@ -476,6 +476,36 @@ sub stage_xcat_probe_sources {
|
||||
return $tarball;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 stage_xcatsn_templates
|
||||
|
||||
Descriptions: Write the templates archive that xCATsn.spec extracts into
|
||||
%{prefix}/share/xcat.
|
||||
|
||||
Arguments:
|
||||
$checkout - the xcat-core source tree
|
||||
$sources_dir - the staging directory of the xCATsn build
|
||||
$epoch - SOURCE_DATE_EPOCH for the archive mtimes
|
||||
|
||||
Returns: the path of the archive.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
sub stage_xcatsn_templates {
|
||||
my ($checkout, $sources_dir, $epoch) = @_;
|
||||
die "stage_xcatsn_templates: no staging directory\n"
|
||||
unless defined $sources_dir && -d $sources_dir;
|
||||
|
||||
my $tarball = "$sources_dir/templates.tar.gz";
|
||||
sh_or_die(qq(tar --sort=name --owner=0 --group=0 --mtime="\@$epoch" )
|
||||
. qq(-czf "$tarball" -C "$checkout" xCAT/templates),
|
||||
"Error creating $tarball")
|
||||
unless -f $tarball;
|
||||
return $tarball;
|
||||
}
|
||||
|
||||
# deb_package_arches: the architectures to build a package for.
|
||||
# 'all' is a single arch-independent build; the three arch packages get one per arch.
|
||||
sub deb_package_arches {
|
||||
|
||||
+2
-3
@@ -55,7 +55,7 @@ use File::Temp qw(tempdir tempfile);
|
||||
use FindBin qw($Bin);
|
||||
use lib "$Bin/build-utils/lib";
|
||||
use XCAT::BuildUtils qw(git_revision source_date_epoch sh sh_or_die usage buildinfo_text
|
||||
prepare_build_sources_dir stage_xcat_probe_sources
|
||||
prepare_build_sources_dir stage_xcat_probe_sources stage_xcatsn_templates
|
||||
stage_genesis_base_sources
|
||||
write_script read_line targetarch_from_target
|
||||
openeuler_build_target openeuler_repo_subdir);
|
||||
@@ -412,8 +412,7 @@ EOF
|
||||
system('build-utils/sync-xcat-apache-configs', '--stage', $SOURCES) == 0
|
||||
or die "FATAL: unable to stage canonical Apache configurations\n";
|
||||
cp "$pkg/xCATSN", $SOURCES;
|
||||
# xCATsn.spec consumes templates from xCAT shared templates payload.
|
||||
sh qq(tar --sort=name --owner=0 --group=0 --mtime="\@$SOURCE_DATE_EPOCH" -czf "$SOURCES/templates.tar.gz" xCAT/templates) unless -f "$SOURCES/templates.tar.gz";
|
||||
stage_xcatsn_templates(".", $SOURCES, $SOURCE_DATE_EPOCH);
|
||||
} elsif ($pkg eq "xCAT-probe") {
|
||||
stage_xcat_probe_sources(".", $SOURCES, $VERSION, $SOURCE_DATE_EPOCH);
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env perl
|
||||
# xCATsn.spec extracts templates.tar.gz in %{prefix}/share/xcat, so every member must
|
||||
# start with templates/.
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Archive::Tar ();
|
||||
use File::Path qw(make_path);
|
||||
use File::Slurper qw(read_text write_text);
|
||||
use File::Temp qw(tempdir);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../../build-utils/lib";
|
||||
use Test::More;
|
||||
|
||||
use XCAT::BuildUtils qw(stage_xcatsn_templates);
|
||||
|
||||
my $epoch = 1600000000;
|
||||
my $checkout = tempdir(CLEANUP => 1);
|
||||
make_path("$checkout/xCAT/templates/install/rh");
|
||||
write_text("$checkout/xCAT/templates/install/rh/compute.tmpl", "first\n");
|
||||
|
||||
my $sources = tempdir(CLEANUP => 1);
|
||||
my $tarball = stage_xcatsn_templates($checkout, $sources, $epoch);
|
||||
is($tarball, "$sources/templates.tar.gz", 'the archive is the Source5 that xCATsn.spec names');
|
||||
|
||||
my @members = Archive::Tar->new($tarball)->list_files;
|
||||
ok(scalar @members, 'the archive is not empty');
|
||||
is_deeply([grep { !m{^templates(/|$)} } @members], [],
|
||||
'every member is rooted at templates/, so it extracts to share/xcat/templates');
|
||||
is_deeply([grep { m{^xCAT/} } @members], [],
|
||||
'no member is rooted at xCAT/, which would extract to share/xcat/xCAT/templates');
|
||||
ok((grep { $_ eq 'templates/install/rh/compute.tmpl' } @members),
|
||||
'a template extracts to share/xcat/templates/install/rh');
|
||||
|
||||
# A staging directory survives between builds. A second build must ship the current templates.
|
||||
write_text("$checkout/xCAT/templates/install/rh/compute.tmpl", "second\n");
|
||||
stage_xcatsn_templates($checkout, $sources, $epoch);
|
||||
my ($file) = Archive::Tar->new($tarball)->get_files('templates/install/rh/compute.tmpl');
|
||||
is($file && $file->get_content, "second\n", 'a later build replaces the archive with the current templates');
|
||||
|
||||
done_testing;
|
||||
Reference in New Issue
Block a user