From bbf7c42e709d5fcb2650f666a86669f6aa20341a Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 24 Mar 2016 08:29:11 -0400 Subject: [PATCH] add support for multiple pkglist for ubuntu --- xCAT-server/lib/perl/xCAT/Template.pm | 86 ++++++++++++++------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index c3d86d410..f3f528232 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -134,51 +134,57 @@ sub subvars { } if (("ubuntu" eq $platform) || ("debian" eq $platform)) { - # since debian/ubuntu uses a preseed file instead of a kickstart file, pkglist - # must be included via simple string replacement instead of using includefile() + # since debian/ubuntu uses a preseed file instead of a kickstart file, pkglist + # must be included via simple string replacement instead of using includefile() - # the first line of $pkglistfile is the space-delimited package list - # the additional lines are considered preseed directives and included as is + # the first line of $pkglistfile is the space-delimited package list + # the additional lines are considered preseed directives and included as is - if ($pkglistfile) { - # handle empty and non-empty $pkglistfile's + if ($pkglistfile) { + # handle empty and non-empty $pkglistfile's + my $allpkglist; + foreach my $mypkglistfile (split(/,/, $pkglistfile)) { + my @tmp_array=(); + if (open PKGLISTFILE, "<$mypkglistfile") { + my $pkglist = ''; + # append preseed directive lines + while () { + chomp $_; + s/\s+$//; #remove trailing white spaces + next if /^\s*$/; #-- skip empty lines + next + if ( /^\s*#/ + && !/^\s*#INCLUDE:[^#^\n]+#/ + && !/^\s*#NEW_INSTALL_LIST#/ + && !/^\s*#ENV:[^#^\n]+#/); #-- skip comments + push(@tmp_array,$_); + } - my @tmp_array=(); + if ( @tmp_array > 0) { + $pkglist=join(' ',@tmp_array); + #handle the #INLCUDE# tag recursively + my $idir = dirname($mypkglistfile); + my $doneincludes=0; + while (not $doneincludes) { + $doneincludes=1; + if ($pkglist =~ /#INCLUDE:[^#^\n]+#/) { + $doneincludes=0; + $pkglist =~ s/#INCLUDE:([^#^\n]+)#/debian_includefile($1,$idir)/eg; + } + } + } - if (open PKGLISTFILE, "<$pkglistfile") { - my $pkglist = ''; - # append preseed directive lines - while () { - chomp $_; - s/\s+$//; #remove trailing white spaces - next if /^\s*$/; #-- skip empty lines - next - if ( /^\s*#/ - && !/^\s*#INCLUDE:[^#^\n]+#/ - && !/^\s*#NEW_INSTALL_LIST#/ - && !/^\s*#ENV:[^#^\n]+#/); #-- skip comments - push(@tmp_array,$_); - } - if ( @tmp_array > 0) { - $pkglist=join(' ',@tmp_array); - #handle the #INLCUDE# tag recursively - my $idir = dirname($pkglistfile); - my $doneincludes=0; - while (not $doneincludes) { - $doneincludes=1; - if ($pkglist =~ /#INCLUDE:[^#^\n]+#/) { - $doneincludes=0; - $pkglist =~ s/#INCLUDE:([^#^\n]+)#/debian_includefile($1,$idir)/eg; - } - } - } - $inc =~ s/#INCLUDE_DEFAULT_PKGLIST_PRESEED#/$pkglist/g; - close PKGLISTFILE; + $allpkglist.=" $pkglist "; + close PKGLISTFILE; + } + } + + $inc =~ s/#INCLUDE_DEFAULT_PKGLIST_PRESEED#/$allpkglist/g; + + } else { + # handle no $pkglistfile + $inc =~ s/#INCLUDE_DEFAULT_PKGLIST_PRESEED#//g; } - } else { - # handle no $pkglistfile - $inc =~ s/#INCLUDE_DEFAULT_PKGLIST_PRESEED#//g; - } } #if user specify the partion file, replace the default partition strategy