From be77e5f43f5f55e26da22b9d226972367e4f7287 Mon Sep 17 00:00:00 2001 From: immarvin Date: Sat, 13 Aug 2016 02:53:05 -0400 Subject: [PATCH] fix issue [DEV] it is ambiguous to determine which compressed rootimg to use among rootimg.tar.gz,rootimg.cpio.gz,rootimg.tar.xz... #1695; update the manpage and usage info of packimage --- .../admin-guides/references/man1/packimage.1.rst | 14 +++++++++++--- xCAT-client/pods/man1/packimage.1.pod | 9 ++++++--- xCAT-server/lib/xcat/plugins/packimage.pm | 12 +++++++++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/packimage.1.rst b/docs/source/guides/admin-guides/references/man1/packimage.1.rst index 20651fbda..4507bdc5c 100644 --- a/docs/source/guides/admin-guides/references/man1/packimage.1.rst +++ b/docs/source/guides/admin-guides/references/man1/packimage.1.rst @@ -23,7 +23,7 @@ SYNOPSIS \ **packimage [-v| -**\ **-version]**\ -\ **packimage**\ \ *imagename*\ +\ **packimage**\ [\ **-m | -**\ **-method**\ \ *cpio|tar*\ ] [\ **-c | -**\ **-compress**\ \ *gzip|pigz|xz*\ ] \ *imagename*\ *********** @@ -62,9 +62,9 @@ OPTIONS \ **-a**\ Architecture (ppc64,x86_64,etc) -\ **-m**\ Archive Method (cpio,tar,squashfs, default is cpio) +\ **-m| -**\ **-method**\ Archive Method (cpio,tar,squashfs, default is cpio) -\ **-c**\ Compress Method (pigz,gzip,xz, default is pigz) +\ **-c| -**\ **-compress**\ Compress Method (pigz,gzip,xz, default is pigz/gzip) ************ @@ -90,6 +90,14 @@ EXAMPLES packimage rhels7.1-x86_64-netboot-compute +2. To pack the osimage rhels7.1-x86_64-netboot-compute with "tar" to archive and "pigz" to compress: + + +.. code-block:: perl + + packimage -m tar -c pigz rhels7.1-x86_64-netboot-compute + + ***** FILES diff --git a/xCAT-client/pods/man1/packimage.1.pod b/xCAT-client/pods/man1/packimage.1.pod index 60b34fe6f..4daa2d03a 100644 --- a/xCAT-client/pods/man1/packimage.1.pod +++ b/xCAT-client/pods/man1/packimage.1.pod @@ -8,7 +8,7 @@ B B -B I +B [B<-m>|B<--method> I] [B<-c>|B<--compress> I] I =head1 DESCRIPTION @@ -36,9 +36,9 @@ B<-p> Profile (compute,service) B<-a> Architecture (ppc64,x86_64,etc) -B<-m> Archive Method (cpio,tar,squashfs, default is cpio) +B<-m| --method> Archive Method (cpio,tar,squashfs, default is cpio) -B<-c> Compress Method (pigz,gzip,xz, default is pigz) +B<-c| --compress> Compress Method (pigz,gzip,xz, default is pigz/gzip) =head1 RETURN VALUE @@ -53,6 +53,9 @@ B<-c> Compress Method (pigz,gzip,xz, default is pigz) packimage rhels7.1-x86_64-netboot-compute +2. To pack the osimage rhels7.1-x86_64-netboot-compute with "tar" to archive and "pigz" to compress: + + packimage -m tar -c pigz rhels7.1-x86_64-netboot-compute =head1 FILES diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 82e4411f3..60062d26d 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -79,7 +79,7 @@ sub process_request { @ARGV = @{$args}; } if (scalar(@ARGV) == 0) { - $callback->({ info => ["Usage:\n packimage \n packimage [-h| --help]\n packimage [-v| --version]"] }); + $callback->({ info => ["Usage:\n packimage [-m| --method=cpio|tar] [-c| --compress=gzip|pigz|xz] \n packimage [-h| --help]\n packimage [-v| --version]"] }); return 0; } @@ -114,7 +114,7 @@ sub process_request { return 0; } if ($help) { - $callback->({ info => ["Usage:\n packimage \n packimage [-h| --help]\n packimage [-v| --version]"] }); + $callback->({ info => ["Usage:\n packimage [-m| --method=cpio|tar] [-c| --compress=gzip|pigz|xz] \n packimage [-h| --help]\n packimage [-v| --version]"] }); return 0; } @@ -468,8 +468,12 @@ sub process_request { } $suffix = $method.".".$suffix; - unlink("$destdir/rootimg.$suffix"); unlink("$destdir/rootimg.sfs"); + unlink("$destdir/rootimg.cpio.xz"); + unlink("$destdir/rootimg.cpio.gz"); + unlink("$destdir/rootimg.tar.xz"); + unlink("$destdir/rootimg.tar.gz"); + if ($method =~ /cpio/) { if (!$exlistloc) { $excludestr = "find . -xdev -print0 | cpio -H newc -o -0 | $compress -c - > ../rootimg.$suffix"; @@ -507,6 +511,7 @@ sub process_request { $callback->({ error => ["Invalid archive method '$method' requested"], errorcode => [1] }); return 1; } + chdir("$rootimg_dir"); my $outputmsg = `$excludestr 2>&1`; unless($?){ @@ -517,6 +522,7 @@ sub process_request { system("rm -rf $xcat_packimg_tmpfile"); return 1; } + if ($method =~ /cpio/) { chmod 0644, "$destdir/rootimg.$suffix"; if ($dotorrent) {