From 6112f5b8b3296ee8b5a877ccdc3171ea912a10a1 Mon Sep 17 00:00:00 2001 From: vallard Date: Mon, 2 Jun 2008 20:27:02 +0000 Subject: [PATCH] copycds to do percentages git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1556 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/lib/xcat/plugins/anaconda.pm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/xCAT-server-2.0/lib/xcat/plugins/anaconda.pm b/xCAT-server-2.0/lib/xcat/plugins/anaconda.pm index f3fd0e6e8..e3bf30bba 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/anaconda.pm @@ -793,6 +793,7 @@ sub copycd }; my $KID; chdir $path; + my $numFiles = `find . -print | wc -l`; my $child = open($KID, "|-"); unless (defined $child) { @@ -813,7 +814,19 @@ sub copycd else { nice 10; - exec "nice -n 20 cpio -dump $installroot/$distname/$arch"; + my $c = "nice -n 20 cpio -vdump $installroot/$distname/$arch"; + open(PIPE, "$c 2>&1 |") || + $callback->({error => "Media copy operation fork failure"}); + my $copied = 0; + my ($percent, $fout); + while(){ + next if /^cpio:/; + $percent = $copied / $numFiles; + $fout = sprintf "%0.2f%%", $percent * 100; + $callback->({sinfo => "$fout"}); + ++$copied; + } + exit; } #my $rc = system("cd $path; find . | nice -n 20 cpio -dump $installroot/$distname/$arch");