From f6419d5de123077a5961de9b481fefba6b7b551f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 22 Jul 2020 00:06:56 +0200 Subject: [PATCH] [locale] New setting *adjustLiveTimezone* - allow finer-grained control over whether-or-not to adjust the timezone in the live system. - handle some special cases at the point of loading-configuration. - document the setting in locale.conf - correct some documentation bugs - adjust the YAML schema for locale.conf so it's legal YAML syntax **and** validates the current file. --- src/modules/locale/Config.cpp | 23 ++++++++++++++---- src/modules/locale/Config.h | 7 ++++++ src/modules/locale/locale.conf | 17 ++++++++++--- src/modules/locale/locale.schema.yaml | 35 ++++++++++++++++++++++++--- 4 files changed, 69 insertions(+), 13 deletions(-) diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp index 5fa8b3c8b..4a2923081 100644 --- a/src/modules/locale/Config.cpp +++ b/src/modules/locale/Config.cpp @@ -177,15 +177,11 @@ Config::Config( QObject* parent ) gs->insert( "locationRegion", location->region() ); gs->insert( "locationZone", location->zone() ); - // If we're in chroot mode (normal install mode), then we immediately set the - // timezone on the live system. When debugging timezones, don't bother. -#ifndef DEBUG_TIMEZONES - if ( locationChanged && Calamares::Settings::instance()->doChroot() ) + if ( locationChanged && m_adjustLiveTimezone ) { QProcess::execute( "timedatectl", // depends on systemd { "set-timezone", location->region() + '/' + location->zone() } ); } -#endif } ); } @@ -325,6 +321,23 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) localeGenPath = QStringLiteral( "/etc/locale.gen" ); } m_localeGenLines = loadLocales( localeGenPath ); + + m_adjustLiveTimezone + = CalamaresUtils::getBool( configurationMap, "adjustLiveTimezone", Calamares::Settings::instance()->doChroot() ); +#ifdef DEBUG_TIMEZONES + if ( m_adjustLiveTimezone ) + { + cDebug() << "Turning off live-timezone adjustments because debugging is on."; + m_adjustLiveTimezone = false; + } +#endif +#ifdef __FreeBSD__ + if ( m_adjustLiveTimezone ) + { + cDebug() << "Turning off live-timezone adjustments on FreeBSD."; + m_adjustLiveTimezone = false; + } +#endif } Calamares::JobList diff --git a/src/modules/locale/Config.h b/src/modules/locale/Config.h index c4a512100..c8710f4a9 100644 --- a/src/modules/locale/Config.h +++ b/src/modules/locale/Config.h @@ -126,6 +126,13 @@ private: * pick Ukranian settings, for instance). */ LocaleConfiguration m_selectedLocaleConfiguration; + + /** @brief Should we adjust the "live" timezone when the location changes? + * + * In the Widgets UI, clicking around on the world map adjusts the + * timezone, and the live system can be made to follow that. + */ + bool m_adjustLiveTimezone; }; diff --git a/src/modules/locale/locale.conf b/src/modules/locale/locale.conf index dc68a050f..572326f0b 100644 --- a/src/modules/locale/locale.conf +++ b/src/modules/locale/locale.conf @@ -1,5 +1,5 @@ --- -# This settings are used to set your default system time zone. +# These settings are used to set your default system time zone. # Time zones are usually located under /usr/share/zoneinfo and # provided by the 'tzdata' package of your Distribution. # @@ -14,17 +14,26 @@ region: "America" zone: "New_York" +# Should changing the system location (e.g. clicking around on the timezone +# map) immediately reflect the changed timezone in the live system? +# By default, installers (with a target system) do, and setup (e.g. OEM +# configuration) does not, but you can switch it on here (or off, if +# you think it's annoying in the installer). +# +# Note that not all systems support live adjustment. +# +# adjustLiveTimezone: true # System locales are detected in the following order: # # - /usr/share/i18n/SUPPORTED # - localeGenPath (defaults to /etc/locale.gen if not set) -# - 'locale -a' output +# - `locale -a` output # -# Enable only when your Distribution is using an +# Enable only when your Distribution is using a # custom path for locale.gen # -#localeGenPath: "PATH_TO/locale.gen" +#localeGenPath: "/etc/locale.gen" # GeoIP based Language settings: Leave commented out to disable GeoIP. # diff --git a/src/modules/locale/locale.schema.yaml b/src/modules/locale/locale.schema.yaml index 41c3ad487..6eadb5c85 100644 --- a/src/modules/locale/locale.schema.yaml +++ b/src/modules/locale/locale.schema.yaml @@ -4,7 +4,34 @@ $id: https://calamares.io/schemas/locale additionalProperties: false type: object properties: - "region": { type: str } - "zone": { type: str } - "localeGenPath": { type: string, required: true } - "geoipUrl": { type: str } + region: { type: string, + enum: [ + Africa, + America, + Antarctica, + Arctic, + Asia, + Atlantic, + Australia, + Europe, + Indian, + Pacific + ] + } + zone: { type: string } + + adjustLiveTimezone: { type: boolean, default: true } + + localeGenPath: { type: string } + + # TODO: refactor, this is reused in welcome + geoip: + additionalProperties: false + type: object + properties: + style: { type: string, enum: [ none, fixed, xml, json ] } + url: { type: string } + selector: { type: string } + required: [ style, url, selector ] + +required: [ region, zone ]