Ubuntu/genimage: support to use local mirror in pkgdir with http format

This commit is contained in:
daniceexi 2015-02-10 03:43:17 -05:00
parent 82be975146
commit e3ad7b1017

View File

@ -228,8 +228,14 @@ unless ($onlyinitrd) {
# Get the ubuntu repo path from osimage.pkgdir
my @srcdirs = split(',', $srcdir);
my $pkgdir_internet; #only support one http mirror which will be used to create bootstrap
foreach my $dir (@srcdirs) {
find(\&isaptdir, <$dir/>);
if ($dir =~ /^http.*/){
$pkgdir_internet = $dir;
} else {
$srcdir = $dir; #set $srcdir to be the one which is not http path
find(\&isaptdir, <$dir/>);
}
}
# Add the dir for kernel deb to be installed
if ($kernelver) {
@ -251,6 +257,11 @@ unless ($onlyinitrd) {
$repnum += 1;
}
$repnum-=1;
# Add the internet mirror
if ($pkgdir_internet) {
print $aptconfig "deb $pkgdir_internet\n\n";
}
close($aptconfig);
mkpath "$rootimg_dir/etc";
@ -282,9 +293,10 @@ unless ($onlyinitrd) {
# Check whether a local Ubuntu mirror is specified
# if linuximage.pkgdir has second mirror is set, we consider the second mirror as a full Ubuntu mirror
if ($#srcdirs > 0) {
$aptcmd2 = "--verbose --arch $uarch $dist $rootimg_dir file://$srcdirs[1]";
$srcdir = $srcdirs[0];
if ($pkgdir_internet) {
my $mirrorurl = $pkgdir_internet;
$mirrorurl =~ s/ .*$//g; # get the url part of mirror path
$aptcmd2 = "--verbose --arch $uarch $dist $rootimg_dir $mirrorurl";
} else {
if ($uarch eq 'ppc64el') {
$aptcmd2 = "--verbose --arch $uarch $dist $rootimg_dir http://ports.ubuntu.com/ubuntu-ports/";