mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00

Up until now I didn't see the point of using spaces for indentation. However, the previous commit (a18bec3) was quite eye opening. Given that python is an indentation aware language, the amount of mistakes that went unnoticed because tabs and spaces were used at the same time (tabs for indentation and spaces for alignment) were unacceptable. E101,W191 have been re-enable in the tox flake8 checker and the documentation has been modified accordingly. The following files have been left as-is: * bootstrapvz/common/assets/extlinux/extlinux.conf * bootstrapvz/common/assets/init.d/expand-root * bootstrapvz/common/assets/init.d/generate-ssh-hostkeys * bootstrapvz/common/assets/init.d/squeeze/generate-ssh-hostkeys * bootstrapvz/plugins/docker_daemon/assets/init.d/docker * bootstrapvz/providers/ec2/assets/bin/growpart * bootstrapvz/providers/ec2/assets/grub.d/40_custom * bootstrapvz/providers/ec2/assets/init.d/ec2-get-credentials * bootstrapvz/providers/ec2/assets/init.d/ec2-run-user-data * docs/_static/taskoverview.coffee * docs/_static/taskoverview.less * tests/unit/subprocess.sh
74 lines
2.5 KiB
Python
74 lines
2.5 KiB
Python
from bootstrapvz.base import Task
|
|
from .. import phases
|
|
import os.path
|
|
|
|
|
|
class LocaleBootstrapPackage(Task):
|
|
description = 'Adding locale package to bootstrap installation'
|
|
phase = phases.preparation
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
# We could bootstrap without locales, but things just suck without them
|
|
# eg. error messages when running apt
|
|
info.include_packages.add('locales')
|
|
|
|
|
|
class GenerateLocale(Task):
|
|
description = 'Generating system locale'
|
|
phase = phases.package_installation
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
from ..tools import sed_i
|
|
from ..tools import log_check_call
|
|
|
|
lang = '{locale}.{charmap}'.format(locale=info.manifest.system['locale'],
|
|
charmap=info.manifest.system['charmap'])
|
|
locale_str = '{locale}.{charmap} {charmap}'.format(locale=info.manifest.system['locale'],
|
|
charmap=info.manifest.system['charmap'])
|
|
|
|
search = '# ' + locale_str
|
|
locale_gen = os.path.join(info.root, 'etc/locale.gen')
|
|
sed_i(locale_gen, search, locale_str)
|
|
|
|
log_check_call(['chroot', info.root, 'locale-gen'])
|
|
log_check_call(['chroot', info.root,
|
|
'update-locale', 'LANG=' + lang])
|
|
|
|
|
|
class SetTimezone(Task):
|
|
description = 'Setting the selected timezone'
|
|
phase = phases.system_modification
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
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)
|
|
|
|
|
|
class SetLocalTimeLink(Task):
|
|
description = 'Setting the selected local timezone (link)'
|
|
phase = phases.system_modification
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
timezone = info.manifest.system['timezone']
|
|
localtime_path = os.path.join(info.root, 'etc/localtime')
|
|
os.unlink(localtime_path)
|
|
os.symlink(os.path.join('/usr/share/zoneinfo', timezone), localtime_path)
|
|
|
|
|
|
class SetLocalTimeCopy(Task):
|
|
description = 'Setting the selected local timezone (copy)'
|
|
phase = phases.system_modification
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
from shutil import copy
|
|
timezone = info.manifest.system['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)
|