Krikri::PluginHelpers::LocaleGenCommand
LocaleGenCommand - the pure string logic of
community.general.locale_gen, split out of the plugin so the
normalization table, the /usr/share/i18n/SUPPORTED entry matcher
and the /etc/locale.gen rewrite are unit-testable without a
Debian host (or a locales package). The plugin executes the
commands these build on (locale -a, locale-gen).
Constants
Real module's LOCALE_NORMALIZATION: locale -a reports
encodings in either case (en_US.utf8 vs en_US.UTF-8), so both
sides of every comparison pass through this table first.
A /usr/share/i18n/SUPPORTED entry line, e.g. "en_US.UTF-8 UTF-8"
or a commented "# de_LI.UTF-8 UTF-8". Mirrors the real module's
re_locale_entry, including that the locale group is
\S+[._\S]+ - the trailing charset is whatever follows the
LAST space the backtracking engine can still hand to it.
Class methods
changed determination: the real module tracks state_tracking -
whether ALL requested locales are present - against the
requested state, so present changes when any locale is
missing, but absent only changes (and only applies) when
every requested locale is present. Check mode never applies,
and StateModuleHelper recomputes state_tracking from the
untouched system, so check mode always reports changed=False.
assert_available: a requested locale must appear as an entry in
one of the SUPPORTED files, OR already be compiled (listed by
locale -a - covers e.g. C.UTF-8, which some systems don't
list in SUPPORTED). Comparison goes through fix_case on both
sides.
set_locale_glibc: comment out (enabled: false) or uncomment
(enabled: true) one entry per requested locale in
/etc/locale.gen, preserving each line's charset column. Real
module's regex is ^#?\s*<name> (?P<charset>.+); it applies
the sub to every line, and a line that doesn't match is
returned unchanged - which is also what makes this idempotent
(an already-enabled line matches and rewrites to itself).