From 2ce463ab8385cec01a4dbbdec0c0b886c6b1b867 Mon Sep 17 00:00:00 2001 From: linggao Date: Tue, 19 May 2009 18:56:27 +0000 Subject: [PATCH] added logic so that user can specify what files to keep in a excluded dir in *.exlist file git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3409 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/packimage.pm | 39 ++++++++++++++++---- xCAT-server/share/xcat/netboot/sles/genimage | 6 ++- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index a33d9c6d1..33b4e0d3b 100644 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -73,23 +73,35 @@ sub process_request { { $callback->({data=>["WARNING: Unable to find file exclusion list under $installroot/custom/netboot/$distname or $::XCATROOT/share/xcat/netboot/$distname/ for $profile/$arch/$osver\n"]}); } - #print "exlistloc=$exlistloc\n"; - + my $excludestr = "find . "; + my $includestr; if ($exlistloc) { my $exlist; open($exlist,"<",$exlistloc); - #my $excludestr = "find . "; + system("echo -n > /tmp/xcat_packimg.txt"); while (<$exlist>) { chomp $_; s/\s*#.*//; #-- remove comments next if /^\s*$/; #-- skip empty lines - $excludestr .= "'!' -path '".$_."' -a "; + if (/^\+/) { + s/^\+//; #remove '+' + $includestr .= "-path '". $_ ."' -o "; + } else { + s/^\-//; #remove '-' if any + $excludestr .= "'!' -path '".$_."' -a "; + } } close($exlist); - } + } + $excludestr =~ s/-a $//; + if ($includestr) { + $includestr =~ s/-o $//; + $includestr = "find . " . $includestr; + } + print "\nexcludestr=$excludestr\n\n includestr=$includestr\n\n"; - # add the xCAT post scripts to the image + # add the xCAT post scripts to the image if (! -d "$installroot/netboot/$osver/$arch/$profile/rootimg") { $callback->({error=>["$installroot/netboot/$osver/$arch/$profile/rootimg does not exist, run genimage -o $osver -p $profile on a server with matching architecture"]}); return; @@ -144,13 +156,24 @@ sub process_request { if (!$exlistloc) { $excludestr = "find . |cpio -H newc -o | gzip -c - > ../rootimg.gz"; }else { - $excludestr =~ s!-a \z!|cpio -H newc -o | gzip -c - > ../rootimg.gz!; + chdir("$installroot/netboot/$osver/$arch/$profile/rootimg"); + system("$excludestr >> /tmp/xcat_packimg.txt"); + if ($includestr) { + system("$includestr >> /tmp/xcat_packimg.txt"); + } + #$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"; } $oldmask = umask 0077; } elsif ($method =~ /squashfs/) { $temppath = mkdtemp("/tmp/packimage.$$.XXXXXXXX"); chmod 0755,$temppath; - $excludestr =~ s!-a \z!|cpio -dump $temppath!; + chdir("$installroot/netboot/$osver/$arch/$profile/rootimg"); + system("$excludestr >> /tmp/xcat_packimg.txt"); + if ($includestr) { + system("$includestr >> /tmp/xcat_packimg.txt"); + } + $excludestr =~ "cat /tmp/xcat_packimg.txt|cpio -dump $temppath"; } elsif ($method =~ /nfs/) { $excludestr = "touch ../rootimg.nfs"; } else { diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 6d92491f0..5add45608 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -146,9 +146,9 @@ unless ($onlyinitrd) { if(-e "$installroot/netboot/$osver/$arch/$profile/rootimg/etc/zypp/repos.d/otherpkg.repo") { system("rm -rf $installroot/netboot/$osver/$arch/$profile/rootimg/etc/zypp/repos.d/otherpkg.repo"); } - system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ ar file:$srcdir_otherpkgs otherpkg"); + system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ ar -t Plaindir file:$srcdir_otherpkgs otherpkg"); }else { - system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ sa file:$srcdir_otherpkgs"); + system("zypper -R $installroot/netboot/$osver/$arch/$profile/rootimg/ sa -t Plaindir file:$srcdir_otherpkgs"); } } @@ -680,6 +680,8 @@ sub get_extra_package_names { open($pkgfile,"<","$otherpkglist"); while (<$pkgfile>) { chomp; + s/\s*#.*//; #-- remove comments + next if /^\s*$/; #-- skip empty lines $pkgnames .= $_ . " "; } close($pkgfile);