stages/locale: Refactor locale stage to look like similar ones
The locale stage now cannot be used to set the keymap. Use the keymap stage instead. Also, the stage was refactored to look like keymap and timezone stages just to be consistent (systemd-firstboot is now used).
This commit is contained in:
parent
8fa41de07c
commit
7fabcfe333
3 changed files with 60 additions and 8 deletions
|
|
@ -1,19 +1,25 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
language = options["language"]
|
||||
vc_keymap = options.get("vc_keymap")
|
||||
|
||||
with open(f"{tree}/etc/locale.conf", "w") as f:
|
||||
f.write(f'LANG="{language}"\n')
|
||||
# We need to remove the /etc/locale.conf file first, because it is created while we install RPM packages.
|
||||
# systemd-firstboot expects that if /etc/locale.conf exists it is a user-defined value and does not change it, but
|
||||
# the assumption is wrong, because it contains a default value from RPM package.
|
||||
try:
|
||||
os.remove(f"{tree}/etc/locale.conf")
|
||||
print("/etc/locale.conf already exists. Replacing.")
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
subprocess.run(["systemd-firstboot", f"--root={tree}", f"--locale={language}"], check=True)
|
||||
|
||||
if vc_keymap:
|
||||
with open(f"{tree}/etc/vconsole.conf", "w") as f:
|
||||
f.write(f'KEYMAP="{vc_keymap}"\n')
|
||||
f.write(f'FONT="eurlatgr"\n')
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@ def test_firewall(extract_dir):
|
|||
assert 'port port="88" protocol="udp"' in content
|
||||
|
||||
|
||||
def test_locale(extract_dir):
|
||||
with open(f"{extract_dir}/etc/locale.conf") as f:
|
||||
content = f.read()
|
||||
assert 'LANG=nn_NO.utf8' in content
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Run integration tests')
|
||||
parser.add_argument('--list', dest='list', action='store_true', help='list test cases')
|
||||
|
|
@ -64,8 +70,16 @@ if __name__ == '__main__':
|
|||
test_cases=[test_firewall],
|
||||
type=IntegrationTestType.EXTRACT
|
||||
)
|
||||
locale = IntegrationTestCase(
|
||||
name="locale",
|
||||
pipeline="locale.json",
|
||||
build_pipeline=args.build_pipeline,
|
||||
output_image="locale.tar.xz",
|
||||
test_cases=[test_locale],
|
||||
type=IntegrationTestType.EXTRACT
|
||||
)
|
||||
|
||||
cases = [f30_boot, timezone, firewall]
|
||||
cases = [f30_boot, timezone, firewall, locale]
|
||||
|
||||
if args.list:
|
||||
print("Available test cases:")
|
||||
|
|
|
|||
32
test/pipelines/locale.json
Normal file
32
test/pipelines/locale.json
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "Example Image",
|
||||
"stages": [
|
||||
{
|
||||
"name": "org.osbuild.dnf",
|
||||
"options": {
|
||||
"releasever": "30",
|
||||
"repos": {
|
||||
"fedora": {
|
||||
"name": "Fedora",
|
||||
"metalink": "https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch",
|
||||
"gpgkey": "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch"
|
||||
}
|
||||
},
|
||||
"packages": ["@Core"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "org.osbuild.locale",
|
||||
"options": {
|
||||
"language": "nn_NO.utf8"
|
||||
}
|
||||
}
|
||||
],
|
||||
"assembler": {
|
||||
"name": "org.osbuild.tar",
|
||||
"options": {
|
||||
"filename": "locale.tar.xz",
|
||||
"compression": "xz"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue