From 950f31d80656da74977f3a77f4a48c61ae78a9f2 Mon Sep 17 00:00:00 2001 From: mxi1 Date: Fri, 9 Jul 2010 09:36:36 +0000 Subject: [PATCH] imgutils::get_package_names() is used now git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6688 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/share/xcat/netboot/sles/genimage | 95 +------------------- 1 file changed, 2 insertions(+), 93 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 718fc0091..dbe2885ae 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -245,7 +245,7 @@ unless ($onlyinitrd) { } my %extra_hash=(); if ($otherpkglist) { - %extra_hash=get_package_names($otherpkglist); + %extra_hash=imgutils::get_package_names($otherpkglist); } @@ -353,7 +353,7 @@ unless ($onlyinitrd) { exit 1; } - my %pkg_hash=get_package_names($pkglist); + my %pkg_hash=imgutils::get_package_names($pkglist); my $index=1; foreach $pass (sort (keys(%pkg_hash))) { $pkgnames = ""; @@ -1271,94 +1271,3 @@ sub generic_post { #This function is meant to leave the image in a state approxi } -sub get_package_names { - my $plist_file_name=shift; - my %pkgnames=(); - my @tmp_array=(); - - - if ($plist_file_name) { - my $pkgfile; - open($pkgfile,"<","$plist_file_name"); - while (<$pkgfile>) { - chomp; - s/\s+$//; #remove trailing white spaces - next if /^\s*$/; #-- skip empty lines - push(@tmp_array,$_); - } - close($pkgfile); - - if ( @tmp_array > 0) { - my $pkgtext=join(',',@tmp_array); - - #handle the #INLCUDE# tag recursively - my $idir = dirname($plist_file_name); - my $doneincludes=0; - while (not $doneincludes) { - $doneincludes=1; - if ($pkgtext =~ /#INCLUDE:[^#^\n]+#/) { - $doneincludes=0; - $pkgtext =~ s/#INCLUDE:([^#^\n]+)#/include_file($1,$idir)/eg; - } - } - - #print "pkgtext=$pkgtext\n"; - my @tmp=split(',', $pkgtext); - my $pass=1; - foreach (@tmp) { - my $idir; - if (/^--/) { - $idir="POST_REMOVE"; #line starts with -- means the package should be removed after otherpkgs are installed - s/^--//; - } elsif (/^-/) { - $idir="PRE_REMOVE"; #line starts with single - means the package should be removed before otherpkgs are installed - s/^-//; - } elsif (/^#NEW_INSTALL_LIST#/) { - $pass++; - next; - } elsif (/^#/) { - # ignore all other comment lines - next; - } else { - $idir=dirname($_); - } - my $fn=basename($_); - if (exists($pkgnames{$pass}{$idir})) { - my $pa=$pkgnames{$pass}{$idir}; - push(@$pa, $fn); - } else { - $pkgnames{$pass}{$idir}=[$fn]; - } - } - } - } - - return %pkgnames; -} - - -sub include_file -{ - my $file = shift; - my $idir = shift; - my @text = (); - unless ($file =~ /^\//) { - $file = $idir."/".$file; - } - - open(INCLUDE,$file) || \ - return "#INCLUDEBAD:cannot open $file#"; - - while() { - chomp($_); - s/\s+$//; #remove trailing spaces - next if /^\s*$/; #-- skip empty lines - push(@text, $_); - } - - close(INCLUDE); - - return join(',', @text); -} - -