2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 09:36:41 +00:00

Bug #4475 Support INCLUDE for ubuntu pkglist

This commit is contained in:
Casandra Qiu 2015-04-21 10:00:49 -04:00
parent e6053b1b42
commit 584012f6cb

View File

@ -131,17 +131,35 @@ sub subvars {
if ($pkglistfile) {
# handle empty and non-empty $pkglistfile's
my @tmp_array=();
if (open PKGLISTFILE, "<$pkglistfile") {
my $pkglist = '';
# append preseed directive lines
while (<PKGLISTFILE>) {
chomp $_;
if ((/^\s*#.*/ ) || ( $_ =~ /^-/ )){
next;
}
$pkglist .= " " . $_;
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;
}
@ -1514,5 +1532,35 @@ sub getNM_GW()
return (undef, undef);
}
sub debian_includefile
{
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
next
if ( /^\s*#/
&& !/^\s*#INCLUDE:[^#^\n]+#/
&& !/^\s*#NEW_INSTALL_LIST#/
&& !/^\s*#ENV:[^#^\n]+#/); #-- skip comments
push(@text, $_);
}
close(INCLUDE);
return join(' ', @text);
}
1;