diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 4771b2206..404f531cb 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -766,11 +766,19 @@ sub mirrorspec{ my $pkgdir; my @mirrors; my @pkgdirlist=split(/,/,$pkgdirval); + my $masternode = xCAT::TableUtils->get_site_Master(); + foreach (@pkgdirlist){ if($_ =~ /^http|ssh/){ push @mirrors,$_; }else{ - $pkgdir=$_; + # If multiple pkgdirs are provided, The first path in the value of osimage.pkgdir + if (!$pkgdir) { + $pkgdir=$_; + }else { + my $osuurl = "http://" . $masternode . $_ . " ./"; + push @mirrors,$osuurl; + } } } diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage index 4e4478a55..f2c87c44d 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage @@ -230,13 +230,21 @@ unless ($onlyinitrd) { my @srcdirs = split(',', $srcdir); my @pkgdir_internet; #Put all the http mirror in ths array, but only the first http mirror which will be used to create bootstrap + my @pkgdir_local; #Put all directories except first in this array + my $masternode = xCAT::TableUtils->get_site_Master(); $srcdir = undef; foreach my $dir (@srcdirs) { if ($dir =~ /^http.*/){ push @pkgdir_internet, $dir; } else { - $srcdir = $dir; #set $srcdir to be the one which is not http path - find(\&isaptdir, <$dir/>); + # If multiple pkgdirs are provided, The first path in the value of osimage.pkgdir + if (!$srcdir) { + $srcdir = $dir; + find(\&isaptdir, <$dir/>); + } else { #set other directory to http url + my $osuurl = "http://$masternode$dir ./"; + push @pkgdir_local, $osuurl; + } } } # Add the dir for kernel deb to be installed @@ -266,6 +274,11 @@ unless ($onlyinitrd) { print $aptconfig "deb $_\n\n"; } } + if (@pkgdir_local) { + foreach (@pkgdir_local) { + print $aptconfig "deb $_\n\n"; + } + } close($aptconfig); mkpath "$rootimg_dir/etc"; @@ -329,13 +342,15 @@ unless ($onlyinitrd) { open($aptconfig,">","$rootimg_dir/etc/apt/sources.list"); if ($srcdir) { - my $master = xCAT::TableUtils->get_site_Master(); - print $aptconfig "deb http://$master$srcdir $dist main\n"; + print $aptconfig "deb http://$masternode$srcdir $dist main\n"; } foreach (@pkgdir_internet) { print $aptconfig "deb $_\n"; } + foreach (@pkgdir_local) { + print $aptconfig "deb $_\n"; + } close($aptconfig);