From 2a3af4c34a2df2c3e4c0712d55360b21e796e5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Sat, 8 Aug 2026 01:08:52 -0300 Subject: [PATCH] fix(packimage): report the missing image name instead of a rejected option packimage rejects -o, -p and -a before anything else runs, which leaves three things below it that cannot be reached. The branch handling a missing image name asks for -o and reports "Please specify a os version with the -o flag", so passing the option is rejected and omitting it is reported as the option being absent. The check for those options alongside an image name re-tests a condition already rejected, and the block that built an image from them can no longer be entered. Report the missing image name instead, and drop the parts that cannot run. Passing -o, -p or -a is rejected exactly as before, and packing a named image is unchanged. --- xCAT-server/lib/xcat/plugins/packimage.pm | 32 ++--------------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 5c10ea80e..00b36c866 100644 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -132,10 +132,6 @@ sub process_request { if (@ARGV > 0) { $imagename = $ARGV[0]; - if ($arch or $osver or $profile) { - $callback->({ error => ["-o, -p and -a options are not allowed when a image name is specified."], errorcode => [1] }); - return 1; - } # load the module in memory eval { require("$::XCATROOT/lib/perl/xCAT/Table.pm") }; @@ -186,21 +182,8 @@ sub process_request { $exlistloc = $ref1->{'exlist'}; $destdir = $ref1->{'rootimgdir'}; } else { - $provmethod = "netboot"; - unless ($osver) { - $callback->({ error => ["Please specify a os version with the -o flag"], errorcode => [1] }); - return 1; - } - unless ($arch) { - $arch = `uname -m`; - chomp($arch); - $arch = "x86" if ($arch =~ /i.86$/); - } - - unless ($profile) { - $callback->({ error => ["Please specify a profile name with -p flag"], errorcode => [1] }); - return 1; - } + $callback->({ error => ["An image name is required, use 'packimage '."], errorcode => [1] }); + return 1; } unless ($destdir) { @@ -233,17 +216,6 @@ sub process_request { return 1; } my $oldpath = cwd(); - unless ($imagename) { - $exlistloc = xCAT::SvrUtils->get_exlist_file_name("$installroot/custom/netboot/$distname", $profile, $osver, $arch); - unless ($exlistloc) { $exlistloc = xCAT::SvrUtils->get_exlist_file_name("$::XCATROOT/share/xcat/netboot/$distname", $profile, $osver, $arch); } - - #save the settings into DB, it will not update if the image already exist - my @ret = xCAT::SvrUtils->update_tables_with_diskless_image($osver, $arch, $profile, "netboot"); - unless ($ret[0] eq 0) { - $callback->({ error => [ "Error when updating the osimage tables: " . $ret[1] ], errorcode => [1] }); - return 1; - } - } #before generating rootimg.$suffix, copy $installroot/postscripts into the image at /xcatpost if (-e "$rootimg_dir/xcatpost") {