mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-04-11 19:31:31 +00:00
fix: Fix the help messages in all the scripts
Signed-off-by: Daniel Hilst Selli <392820+dhilst@users.noreply.github.com>
This commit is contained in:
44
buildrpms.pl
44
buildrpms.pl
@@ -48,8 +48,10 @@ my %opts = (
|
||||
nproc => int(`nproc --all`),
|
||||
force => 0,
|
||||
verbose => 0,
|
||||
deps => "$PWD/../xcat-dep/",
|
||||
regennginxconf => 0,
|
||||
xcat_dep_path => "$PWD/../xcat-dep/",
|
||||
configure_nginx => 0,
|
||||
help => 0,
|
||||
nginx_port => 8080,
|
||||
);
|
||||
|
||||
GetOptions(
|
||||
@@ -58,8 +60,10 @@ GetOptions(
|
||||
"nproc=i" => \$opts{nproc},
|
||||
"verbose" => \$opts{verbose},
|
||||
"force" => \$opts{force},
|
||||
"deps=s" => \$opts{deps},
|
||||
"regennginxconf" => \$opts{regennginxconf},
|
||||
"xcat_dep_path=s" => \$opts{xcat_dep_path},
|
||||
"configure_nginx" => \$opts{configure_nginx},
|
||||
"help" => \$opts{help},
|
||||
"nginx_port" => \$opts{nginx_port},
|
||||
) or usage();
|
||||
|
||||
sub sh {
|
||||
@@ -205,11 +209,12 @@ sub buildall {
|
||||
}
|
||||
|
||||
sub configure_nginx {
|
||||
my $deps = $opts{deps};
|
||||
my $xcat_dep_path = $opts{xcat_dep_path};
|
||||
my $port = $opts{nginx_port};
|
||||
my $conf = <<"EOF";
|
||||
server {
|
||||
listen 8080;
|
||||
listen [::]:8080;
|
||||
listen $port;
|
||||
listen [::]:$port;
|
||||
EOF
|
||||
|
||||
# We always generate the nginx config for all
|
||||
@@ -228,7 +233,7 @@ EOF
|
||||
# TODO:I need one xcat-dep for each target
|
||||
$conf .= <<"EOF";
|
||||
location /xcat-dep/ {
|
||||
alias $deps;
|
||||
alias $xcat_dep_path;
|
||||
autoindex on;
|
||||
index off;
|
||||
allow all;
|
||||
@@ -250,13 +255,34 @@ sub update_repo {
|
||||
sub usage {
|
||||
my ($errmsg) = @_;
|
||||
say STDERR "Usage: $0 [--package=<pkg1>] [--target=<tgt1>] [--package=<pgk2>] [--target=<tgt2>] ...";
|
||||
say STDERR "";
|
||||
say STDERR " RPM builder script";
|
||||
say STDERR " .. build xCAT RPMs for these targets:";
|
||||
say STDERR map { " $_\n" } @TARGETS;
|
||||
say STDERR "";
|
||||
say STDERR " Options:";
|
||||
say STDERR "";
|
||||
say STDERR " --target <tgt> .................. build only these targets";
|
||||
say STDERR " --package <pkg> ................. build only these packages";
|
||||
say STDERR " --force ......................... override built RPMS";
|
||||
say STDERR " --configure_nginx ............... update nginx configuration";
|
||||
say STDERR " --nginx_port=8080 ............... change the nginx port in";
|
||||
say STDERR " (use with --configure_nginx)";
|
||||
say STDERR " --nproc <N> ..................... run up to N jobs in parallel";
|
||||
say STDERR " --xcat_dep_path=../xcat-dep ..... path to xcat-dep repositories";
|
||||
say STDERR "";
|
||||
say STDERR " If no --target or --package is given all combinations are built";
|
||||
say STDERR "";
|
||||
say STDERR " See test/README.md for more information";
|
||||
|
||||
say STDERR $errmsg if $errmsg;
|
||||
exit -1;
|
||||
}
|
||||
|
||||
sub main {
|
||||
return configure_nginx() if $opts{regennginxconf};
|
||||
return usage() if $opts{help};
|
||||
return configure_nginx() if $opts{configure_nginx};
|
||||
|
||||
my @rpms = product($opts{packages}, $opts{targets});
|
||||
my $pm = Parallel::ForkManager->new($opts{nproc});
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ podman exec -it xcattest-el10 scripts/testxcat.pl --all
|
||||
|
||||
- Replace `xcattest-el10` with the appropriate container name. The script configures the repository inside the container, installs xCAT, ensures `xcatd` is running, and finally runs `lsdef` to verify daemon connectivity.
|
||||
- You can safely rerun the command; it will reuse the container state unless `--force` is supplied to the helper scripts.
|
||||
- In this case you call combine `--force` with `--reinstallxcat` to make it remove xCAT completely and reinstalling again.
|
||||
- In this case you call combine `--force` with `--reinstall` to make it remove xCAT completely and reinstalling again.
|
||||
|
||||
## End-to-End Checklist
|
||||
- Dependencies extracted to `../xcat-dep` for all EL versions you plan to build.
|
||||
|
||||
@@ -21,25 +21,25 @@ sub sh {
|
||||
}
|
||||
|
||||
sub usage {
|
||||
say STDERR "Usage: $0 [--setupcontainer --target rhel+epel-9-x86_64]";
|
||||
say STDERR "Usage: $0 --setup_container --target <target> [--force]";
|
||||
exit -1;
|
||||
}
|
||||
|
||||
sub parseopts {
|
||||
my %opts = (
|
||||
target => "",
|
||||
setupcontainer => 0,
|
||||
setup_container => 0,
|
||||
force => 0,
|
||||
);
|
||||
|
||||
GetOptions(
|
||||
"target=s" => \$opts{target},
|
||||
"setupcontainer" => \$opts{setupcontainer},
|
||||
"setup_container" => \$opts{setup_container},
|
||||
"force" => \$opts{force},
|
||||
) or usage();
|
||||
|
||||
usage()
|
||||
if $opts{setupcontainer}
|
||||
if $opts{setup_container}
|
||||
and not $opts{target};
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ podman rmi -f $image
|
||||
EOF
|
||||
}
|
||||
|
||||
sub setupcontainer {
|
||||
sub setup_container {
|
||||
my ($opts) = @_;
|
||||
my $target = $opts->{target};
|
||||
|
||||
@@ -96,7 +96,7 @@ EOF
|
||||
sub main {
|
||||
my $opts = parseopts();
|
||||
|
||||
return setupcontainer($opts) if $opts->{setupcontainer};
|
||||
return setup_container($opts) if $opts->{setup_container};
|
||||
|
||||
|
||||
usage();
|
||||
|
||||
@@ -10,13 +10,14 @@ use File::Slurper qw(read_text write_text);
|
||||
my %opts = (
|
||||
releasever => int(`rpm --eval '%{rhel}'`),
|
||||
verbose => 0,
|
||||
setuprepos => 0,
|
||||
installxcat => 0,
|
||||
uninstallxcat => 0,
|
||||
reinstallxcat => 0,
|
||||
validatexcat => 0,
|
||||
setup_repos => 0,
|
||||
install => 0,
|
||||
uninstall => 0,
|
||||
reinstall => 0,
|
||||
validate => 0,
|
||||
quiet => 0,
|
||||
all => 0,
|
||||
nginx_port => 8080,
|
||||
);
|
||||
|
||||
GetOptions(
|
||||
@@ -24,12 +25,13 @@ GetOptions(
|
||||
verbose => \$opts{verbose},
|
||||
quiet => \$opts{quiet},
|
||||
quiet => \$opts{quiet},
|
||||
setuprepos => \$opts{setuprepos},
|
||||
installxcat => \$opts{installxcat},
|
||||
uninstallxcat => \$opts{uninstallxcat},
|
||||
reinstallxcat => \$opts{reinstallxcat},
|
||||
validatexcat => \$opts{validatexcat},
|
||||
setup_repos => \$opts{setup_repos},
|
||||
install => \$opts{install},
|
||||
uninstall => \$opts{uninstall},
|
||||
reinstall => \$opts{reinstall},
|
||||
validate => \$opts{validate},
|
||||
all => \$opts{all},
|
||||
nginx_port => \$opts{nginx_port},
|
||||
) or usage();
|
||||
|
||||
sub sh {
|
||||
@@ -47,23 +49,24 @@ sub sh {
|
||||
}
|
||||
|
||||
sub usage {
|
||||
say STDERR "usage $0: [--releasever=9] [--verbose] [--quiet] {--setuprepos|--isntallxcat|--uninstallxcat|--reinstallxcat|--validatexcat|--all}";
|
||||
say STDERR "usage $0: [--releasever=9] [--verbose] [--quiet] {--setup_repos|--install|--uninstall|--reinstall|--validate|--all} [--nginx-port=8080]";
|
||||
}
|
||||
|
||||
sub setuprepos {
|
||||
sub setup_repos {
|
||||
say "Setting up repositories"
|
||||
unless $opts{quiet};
|
||||
my $releasever = $opts{releasever};
|
||||
my $port = $opts{nginx_port};
|
||||
my $content = <<"EOF";
|
||||
[xcat3]
|
||||
name=xcat3
|
||||
baseurl=http://host.containers.internal:8080/rhel+epel-$releasever-x86_64/
|
||||
baseurl=http://host.containers.internal:$port/rhel+epel-$releasever-x86_64/
|
||||
gpgcheck=0
|
||||
enabled=1
|
||||
|
||||
[xcat3-deps]
|
||||
name=xcat3-deps
|
||||
baseurl=http://host.containers.internal:8080/xcat-dep/el$releasever/x86_64/
|
||||
baseurl=http://host.containers.internal:$port/xcat-dep/el$releasever/x86_64/
|
||||
gpgcheck=0
|
||||
enabled=1
|
||||
EOF
|
||||
@@ -71,39 +74,39 @@ EOF
|
||||
sh("dnf makecache --repo=xcat3 --repo=xcat3-deps");
|
||||
}
|
||||
|
||||
sub uninstallxcat {
|
||||
sub uninstall {
|
||||
sh("dnf remove -y xCAT");
|
||||
sh("rm -rf /opt/xcat /etc/xcat /var/run/xcat /root/.xcat /install /tftpboot");
|
||||
}
|
||||
|
||||
sub installxcat {
|
||||
sub install {
|
||||
sh("dnf install -y xCAT");
|
||||
}
|
||||
|
||||
sub validatexcat {
|
||||
sub validate {
|
||||
# Put commands to validate xcat installation here
|
||||
sh("systemctl is-active xcatd") == 0 or die("xcatd not running?");
|
||||
sh("lsdef") == 0 or die("lsdef not working");
|
||||
}
|
||||
|
||||
sub main {
|
||||
return setuprepos() if $opts{setuprepos};
|
||||
return installxcat() if $opts{installxcat};
|
||||
return uninstallxcat() if $opts{uninstallxcat};
|
||||
return validatexcat() if $opts{validatexcat};
|
||||
return setup_repos() if $opts{setup_repos};
|
||||
return install() if $opts{install};
|
||||
return uninstall() if $opts{uninstall};
|
||||
return validate() if $opts{validate};
|
||||
|
||||
return do {
|
||||
setuprepos();
|
||||
uninstallxcat()
|
||||
if ($opts{reinstallxcat} or $opts{uninstallxcat});
|
||||
installxcat();
|
||||
validatexcat();
|
||||
setup_repos();
|
||||
uninstall()
|
||||
if ($opts{reinstall} or $opts{uninstall});
|
||||
install();
|
||||
validate();
|
||||
} if $opts{all};
|
||||
|
||||
return do {
|
||||
uninstallxcat();
|
||||
installxcat();
|
||||
} if $opts{reinstallxcat};
|
||||
uninstall();
|
||||
install();
|
||||
} if $opts{reinstall};
|
||||
|
||||
usage();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user