def _setup_hooks( self, location: Location, system_context: SystemContext, locales: typing.Sequence[str], ) -> None: if not system_context.has_substitution("CLRM_LOCALES"): location.set_description("run locale-gen") self._add_hook( location, system_context, "export", "run", "/usr/bin/locale-gen", inside=True, ) location.set_description("Remove locale related data.") self._add_hook( location, system_context, "export", "remove", "/usr/share/locale/*", "/etc/locale.gen", "/usr/bin/locale-gen", "/usr/bin/localedef", force=True, recursive=True, ) system_context.set_substitution("CLRM_LOCALES", ",".join(locales))
def __call__(self, location: Location, system_context: SystemContext, *args: typing.Any, **kwargs: typing.Any) -> None: """Execute command.""" if system_context.has_substitution('MACHINE_ID'): raise GenerateError('Machine-id was already set.', location=location) machine_id = args[0] system_context.set_substitution('MACHINE_ID', machine_id) machine_id += '\n' self._execute(location.next_line(), system_context, 'create', '/etc/machine-id', machine_id)
def _setup_hooks(self, location: Location, system_context: SystemContext, locales: typing.Sequence[str]) -> None: if not system_context.has_substitution('CLRM_LOCALES'): location.set_description('run locale-gen') self._add_hook(location, system_context, 'export', 'run', '/usr/bin/locale-gen', inside=True) location.set_description('Remove locale related data.') self._add_hook(location, system_context, 'export', 'remove', '/usr/share/locale/*', '/etc/locale.gen', '/usr/bin/locale-gen', '/usr/bin/localedef', force=True, recursive=True) system_context.set_substitution('CLRM_LOCALES', ','.join(locales))
def __call__(self, location: Location, system_context: SystemContext, *args: typing.Any, **kwargs: typing.Any) -> None: """Execute command.""" if system_context.has_substitution("MACHINE_ID"): raise GenerateError("Machine-id was already set.", location=location) machine_id = args[0] system_context.set_substitution("MACHINE_ID", machine_id) machine_id += "\n" self._execute( location.next_line(), system_context, "create", "/etc/machine-id", machine_id, )
def __call__(self, location: Location, system_context: SystemContext, *args: typing.Any, **kwargs: typing.Any) -> None: """Execute command.""" static_hostname = args[0] pretty_hostname = kwargs.get('pretty', static_hostname) if system_context.has_substitution('HOSTNAME'): raise GenerateError('Hostname was already set.', location=location) system_context.set_substitution('HOSTNAME', static_hostname) system_context.set_substitution('PRETTY_HOSTNAME', pretty_hostname) self._execute(location, system_context, 'create', '/etc/hostname', static_hostname) self._execute( location.next_line(), system_context, 'sed', '/^PRETTY_HOSTNAME=/ cPRETTY_HOSTNAME=\"{}\"'.format( pretty_hostname), '/etc/machine.info')