2014-03-23 23:12:07 +01:00
|
|
|
from bootstrapvz.base import Task
|
|
|
|
from .. import phases
|
2013-07-01 21:42:40 +02:00
|
|
|
import os.path
|
|
|
|
|
|
|
|
|
2013-12-29 16:09:47 +01:00
|
|
|
class LocaleBootstrapPackage(Task):
|
|
|
|
description = 'Adding locale package to bootstrap installation'
|
|
|
|
phase = phases.preparation
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-12-29 16:09:47 +01:00
|
|
|
# We could bootstrap without locales, but things just suck without them
|
|
|
|
# eg. error messages when running apt
|
|
|
|
info.include_packages.add('locales')
|
|
|
|
|
|
|
|
|
2013-07-01 21:42:40 +02:00
|
|
|
class GenerateLocale(Task):
|
|
|
|
description = 'Generating the selected locale'
|
2013-12-29 16:09:47 +01:00
|
|
|
phase = phases.package_installation
|
2013-07-01 21:42:40 +02:00
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2014-03-23 23:12:07 +01:00
|
|
|
from ..tools import sed_i
|
|
|
|
from ..tools import log_check_call
|
2013-07-01 21:42:40 +02:00
|
|
|
locale_gen = os.path.join(info.root, 'etc/locale.gen')
|
|
|
|
locale_str = '{locale}.{charmap} {charmap}'.format(locale=info.manifest.system['locale'],
|
|
|
|
charmap=info.manifest.system['charmap'])
|
|
|
|
search = '# ' + locale_str
|
|
|
|
sed_i(locale_gen, search, locale_str)
|
2013-07-01 22:06:42 +02:00
|
|
|
|
2014-02-23 22:16:10 +01:00
|
|
|
log_check_call(['chroot', info.root, 'locale-gen'])
|
2013-08-13 20:38:52 +02:00
|
|
|
|
|
|
|
lang = '{locale}.{charmap}'.format(locale=info.manifest.system['locale'],
|
|
|
|
charmap=info.manifest.system['charmap'])
|
2014-02-23 22:16:10 +01:00
|
|
|
log_check_call(['chroot', info.root,
|
|
|
|
'update-locale', 'LANG=' + lang])
|
2013-07-01 21:42:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SetTimezone(Task):
|
|
|
|
description = 'Setting the selected timezone'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-07-01 21:42:40 +02:00
|
|
|
from shutil import copy
|
|
|
|
tz_path = os.path.join(info.root, 'etc/timezone')
|
|
|
|
timezone = info.manifest.system['timezone']
|
|
|
|
with open(tz_path, 'w') as tz_file:
|
|
|
|
tz_file.write(timezone)
|
|
|
|
zoneinfo_path = os.path.join(info.root, '/usr/share/zoneinfo', timezone)
|
|
|
|
localtime_path = os.path.join(info.root, 'etc/localtime')
|
|
|
|
copy(zoneinfo_path, localtime_path)
|