diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index c6d96ebb5..82e4411f3 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -484,14 +484,14 @@ sub process_request { $oldmask = umask 0077; } elsif ($method =~ /tar/) { if (!$exlistloc) { - $excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --null -T - -c | $compress -c - > ../rootimg.$suffix"; + $excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress --null -T - -cf ../rootimg.$suffix"; } else { chdir("$rootimg_dir"); system("$excludestr >> $xcat_packimg_tmpfile"); if ($includestr) { system("$includestr >> $xcat_packimg_tmpfile"); } - $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' -T - -c | $compress -c - > ../rootimg.$suffix"; + $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress -T - -cf ../rootimg.$suffix"; } $oldmask = umask 0077; } elsif ($method =~ /squashfs/) { @@ -508,8 +508,15 @@ sub process_request { return 1; } chdir("$rootimg_dir"); - my $outputmsg = `$excludestr`; - $callback->({ info => ["$outputmsg"] }); + my $outputmsg = `$excludestr 2>&1`; + unless($?){ + $callback->({ info => ["$outputmsg"] }); + }else{ + $callback->({ info => ["$outputmsg"] }); + $callback->({ error => ["packimage failed while running: \n $excludestr"], errorcode => [1] }); + system("rm -rf $xcat_packimg_tmpfile"); + return 1; + } if ($method =~ /cpio/) { chmod 0644, "$destdir/rootimg.$suffix"; if ($dotorrent) {