add mirror attribute

This commit is contained in:
Olivier Sallou 2013-07-10 15:43:39 +02:00
parent f9fafe71fb
commit 17876070a5
4 changed files with 13 additions and 4 deletions

View file

@ -30,7 +30,8 @@
}, },
"timezone": { "type": "string" }, "timezone": { "type": "string" },
"locale": { "type": "string" }, "locale": { "type": "string" },
"charmap": { "type": "string" } "charmap": { "type": "string" },
"mirror": { "type": "string" }
}, },
"required": ["release", "architecture", "timezone", "locale", "charmap"] "required": ["release", "architecture", "timezone", "locale", "charmap"]
}, },

View file

@ -41,7 +41,8 @@ def tasks(tasklist, manifest):
locale.SetTimezone(), locale.SetTimezone(),
apt.DisableDaemonAutostart(), apt.DisableDaemonAutostart(),
apt.AptSources(), apt.AptSources(),
apt.AptUpgrade(), #No network for the moment, skip
#apt.AptUpgrade(),
boot.ConfigureGrub(), boot.ConfigureGrub(),
filesystem.ModifyFstab(), filesystem.ModifyFstab(),
boot.BlackListModules(), boot.BlackListModules(),

View file

@ -10,11 +10,14 @@ class AptSources(Task):
phase = phases.system_modification phase = phases.system_modification
def run(self, info): def run(self, info):
mirror = 'http://http.debian.net/debian'
if info.manifest.system['mirror']:
mirror = info.manifest.system['mirror']
sources_path = os.path.join(info.root, 'etc/apt/sources.list') sources_path = os.path.join(info.root, 'etc/apt/sources.list')
with open(sources_path, 'w') as apt_sources: with open(sources_path, 'w') as apt_sources:
apt_sources.write(('deb {apt_mirror} {release} main\n' apt_sources.write(('deb {apt_mirror} {release} main\n'
'deb-src {apt_mirror} {release} main\n' 'deb-src {apt_mirror} {release} main\n'
.format(apt_mirror='http://http.debian.net/debian', .format(apt_mirror=mirror,
release=info.manifest.system['release']))) release=info.manifest.system['release'])))
apt_sources.write(('deb {apt_mirror} {release}/updates main\n' apt_sources.write(('deb {apt_mirror} {release}/updates main\n'
'deb-src {apt_mirror} {release}/updates main\n' 'deb-src {apt_mirror} {release}/updates main\n'

View file

@ -6,6 +6,10 @@ log = logging.getLogger(__name__)
def get_bootstrap_args(info): def get_bootstrap_args(info):
mirror = 'http://http.debian.net/debian'
if info.manifest.system['mirror']:
mirror = info.manifest.system['mirror']
executable = ['/usr/sbin/debootstrap'] executable = ['/usr/sbin/debootstrap']
options = ['--arch=' + info.manifest.system['architecture']] options = ['--arch=' + info.manifest.system['architecture']]
include, exclude = info.img_packages include, exclude = info.img_packages
@ -13,7 +17,7 @@ def get_bootstrap_args(info):
options.append('--include=' + ','.join(include)) options.append('--include=' + ','.join(include))
if len(exclude) > 0: if len(exclude) > 0:
options.append('--exclude=' + ','.join(exclude)) options.append('--exclude=' + ','.join(exclude))
arguments = [info.manifest.system['release'], info.root, 'http://http.debian.net/debian'] arguments = [info.manifest.system['release'], info.root, mirror]
return executable, options, arguments return executable, options, arguments