mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 03:12:30 +00:00 
			
		
		
		
	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
This commit is contained in:
		| @@ -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(<INCLUDE>) { | ||||
|        chomp($_); | ||||
|        s/\s+$//;  #remove trailing spaces | ||||
|        next if /^\s*$/; #-- skip empty lines | ||||
|        push(@text, $_); | ||||
|    } | ||||
|     | ||||
|    close(INCLUDE); | ||||
|     | ||||
|    return join(',', @text); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user