From 8dc66421c0a9699f9424e279bffd0252740fcf41 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 23 May 2021 14:53:45 +0200 Subject: [PATCH] bundles/basic: don't rewrite /etc/locale.gen every time --- bundles/basic/items.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bundles/basic/items.py b/bundles/basic/items.py index e37b684..c414fe5 100644 --- a/bundles/basic/items.py +++ b/bundles/basic/items.py @@ -13,14 +13,20 @@ files = { '/etc/htoprc.global': { 'source': 'htoprc', }, - '/etc/locale.gen': { - 'content_type': 'mako', + '/etc/motd': {}, +} + +locale_needs = set() +for locale in sorted(node.metadata['locale']['installed']): + actions[f'ensure_locale_{locale}_is_enabled'] = { + 'command': f"sed -i '/{locale}/s/^# *//g' /etc/locale.gen", + 'unless': f"grep -e '^{locale}' /etc/locale.gen", 'triggers': { 'action:locale-gen', }, - }, - '/etc/motd': {}, -} + 'needs': locale_needs, + } + locale_needs = {f'action:ensure_locale_{locale}_is_enabled'} actions = { 'locale-gen': {