Skip to content

Commit c6e9ac7

Browse files
authored
Merge pull request #48 from dcasota/upstream/seed-locale-conf-before-pkg-install
installer: move the locale.conf write to PRE_PKGS_INSTALL
2 parents f614b59 + 3f88041 commit c6e9ac7

2 files changed

Lines changed: 45 additions & 15 deletions

File tree

photon_installer/modules/m_locale.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77

88
import commons
99

10-
install_phase = commons.POST_INSTALL
10+
# PRE_PKGS_INSTALL, not POST_INSTALL: dracut's 20i18n module reads
11+
# /etc/locale.conf when it builds an initrd, and the initramfs rpm installs a
12+
# file trigger that runs mkinitrd at the END of the package transaction started
13+
# by _install_packages(). A file written after that transaction is written too
14+
# late. Without it dracut aborts i18n setup with
15+
# "i18n_vars not set! Please set up i18n_vars in configuration file."
16+
# and falls back to embedding every keymap.
17+
#
18+
# _initialize_system() runs immediately before this phase, so the file lands at
19+
# very nearly the same point in the sequence as it would have from there, but
20+
# in the module that owns locale rather than in the installer body.
21+
install_phase = commons.PRE_PKGS_INSTALL
1122
enabled = True
1223

1324

1425
def execute(installer):
1526
# Set locale
16-
with open(
17-
os.path.join(installer.photon_root, "etc/locale.conf"), "w"
18-
) as locale_conf:
27+
locale_conf_path = os.path.join(installer.photon_root, "etc/locale.conf")
28+
os.makedirs(os.path.dirname(locale_conf_path), exist_ok=True)
29+
with open(locale_conf_path, "w") as locale_conf:
1930
locale_conf.write("LANG=en_US.UTF-8\n")
20-
21-
"""
22-
locale-gen.sh needs /usr/share/locale/locale.alias which is shipped
23-
with glibc-lang rpm, in some photon installations glibc-lang rpm is
24-
not installed by default. Call localedef directly here to define
25-
locale environment.
26-
"""
27-
installer.cmd.run_in_chroot(
28-
installer.photon_root,
29-
"/usr/bin/localedef -c -i en_US -f UTF-8 en_US.UTF-8",
30-
)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# /*
2+
# * Copyright © 2020 VMware, Inc.
3+
# * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-only
4+
# */
5+
6+
import commons
7+
8+
# The other half of locale setup, and the half that cannot move earlier.
9+
#
10+
# m_locale writes /etc/locale.conf at PRE_PKGS_INSTALL because dracut needs it
11+
# before the package transaction ends. localedef cannot follow it there: it runs
12+
# inside the chroot, and at PRE_PKGS_INSTALL the target holds only an
13+
# initialised rpm database and the `filesystem` rpm - glibc, which provides
14+
# /usr/bin/localedef, is not installed until _install_packages(). So this stays
15+
# at POST_INSTALL.
16+
install_phase = commons.POST_INSTALL
17+
enabled = True
18+
19+
20+
def execute(installer):
21+
"""
22+
locale-gen.sh needs /usr/share/locale/locale.alias which is shipped
23+
with glibc-lang rpm, in some photon installations glibc-lang rpm is
24+
not installed by default. Call localedef directly here to define
25+
locale environment.
26+
"""
27+
installer.cmd.run_in_chroot(
28+
installer.photon_root,
29+
"/usr/bin/localedef -c -i en_US -f UTF-8 en_US.UTF-8",
30+
)

0 commit comments

Comments
 (0)