From 354dd7bcb01e03e290ecc7f214135dbe3f18db89 Mon Sep 17 00:00:00 2001 From: linggao Date: Fri, 19 Nov 2010 19:05:41 +0000 Subject: [PATCH] bug fix git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8213 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/packimage.pm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 41a310f82..35f7f1a72 100644 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -209,13 +209,14 @@ sub process_request { } } + my $xcat_packimg_tmpfile = "/tmp/xcat_packimg.$$"; my $excludestr = "find . "; my $includestr; if ($exlistloc) { my $exlist; my $excludetext; open($exlist,"<",$exlistloc); - system("echo -n > /tmp/xcat_packimg.txt"); + system("echo -n > $xcat_packimg_tmpfile"); while (<$exlist>) { $excludetext .= $_; } @@ -323,23 +324,23 @@ sub process_request { $excludestr = "find . |cpio -H newc -o | gzip -c - > ../rootimg.gz"; }else { chdir("$rootimg_dir"); - system("$excludestr >> /tmp/xcat_packimg.txt"); + system("$excludestr >> $xcat_packimg_tmpfile"); if ($includestr) { - system("$includestr >> /tmp/xcat_packimg.txt"); + system("$includestr >> $xcat_packimg_tmpfile"); } #$excludestr =~ s!-a \z!|cpio -H newc -o | gzip -c - > ../rootimg.gz!; - $excludestr = "cat /tmp/xcat_packimg.txt|cpio -H newc -o | gzip -c - > ../rootimg.gz"; + $excludestr = "cat $xcat_packimg_tmpfile|cpio -H newc -o | gzip -c - > ../rootimg.gz"; } $oldmask = umask 0077; } elsif ($method =~ /squashfs/) { $temppath = mkdtemp("/tmp/packimage.$$.XXXXXXXX"); chmod 0755,$temppath; chdir("$rootimg_dir"); - system("$excludestr >> /tmp/xcat_packimg.txt"); + system("$excludestr >> $xcat_packimg_tmpfile"); if ($includestr) { - system("$includestr >> /tmp/xcat_packimg.txt"); + system("$includestr >> $xcat_packimg_tmpfile"); } - $excludestr = "cat /tmp/xcat_packimg.txt|cpio -dump $temppath"; + $excludestr = "cat $xcat_packimg_tmpfile|cpio -dump $temppath"; } else { $callback->({error=>["Invalid method '$method' requested"],errorcode=>[1]}); } @@ -371,7 +372,8 @@ sub process_request { } chmod(0644,"../rootimg.sfs"); } - + system("rm -f $xcat_packimg_tmpfile"); + # move the files in /.statebackup back to rootimg_dir if ($rootimg_status) { # statelite mode foreach my $entry (keys %liteHash) {