From eab027f959f5bdd3d59cb33b1d9d3db5a62515e2 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 27 Jul 2020 11:15:20 +0200 Subject: [PATCH 01/13] [type/__timezone] Replace code-remote with __file object --- type/__timezone/explorer/timezone_is | 25 ------------------- type/__timezone/gencode-remote | 36 ---------------------------- type/__timezone/manifest | 7 ++++++ 3 files changed, 7 insertions(+), 61 deletions(-) delete mode 100755 type/__timezone/explorer/timezone_is delete mode 100755 type/__timezone/gencode-remote diff --git a/type/__timezone/explorer/timezone_is b/type/__timezone/explorer/timezone_is deleted file mode 100755 index 6f72a9248..000000000 --- a/type/__timezone/explorer/timezone_is +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -e -# -# 2017 Ander Punnar (ander at kvlt.ee) -# -# This file is part of skonfig-base. -# -# skonfig-base is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# skonfig-base is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with skonfig-base. If not, see . -# -# Prints the contents of /etc/timezone. -# - -[ -f /etc/timezone ] && cat /etc/timezone - -exit 0 diff --git a/type/__timezone/gencode-remote b/type/__timezone/gencode-remote deleted file mode 100755 index a3101122d..000000000 --- a/type/__timezone/gencode-remote +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -e -# -# 2012 Steven Armstrong (steven-cdist at armstrong.cc) -# 2019 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of skonfig-base. -# -# skonfig-base is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# skonfig-base is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with skonfig-base. If not, see . -# - -timezone_is=$(cat "${__object:?}/explorer/timezone_is") -timezone_should=$(cat "${__object:?}/parameter/tz") -os=$(cat "${__global:?}/explorer/os") - -if [ "${timezone_is}" = "${timezone_should}" ] -then - exit 0 -fi - -case ${os} -in - (ubuntu|debian|devuan|coreos|alpine) - echo "echo \"${timezone_should}\" >/etc/timezone" - ;; -esac diff --git a/type/__timezone/manifest b/type/__timezone/manifest index 05bd90375..637b31b83 100755 --- a/type/__timezone/manifest +++ b/type/__timezone/manifest @@ -61,6 +61,13 @@ in ;; esac +case ${os} +in + (ubuntu|debian|devuan|coreos|alpine) + echo "${timezone_should}" | __file /etc/timezone --source - + ;; +esac + __link /etc/localtime \ --source "/usr/share/zoneinfo/${timezone}" \ --type symbolic From c7d81473d910b7b5b7c4d3699eaa033ae896a995 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 27 Jul 2020 11:19:40 +0200 Subject: [PATCH 02/13] [type/__timezone] Lint --- type/__timezone/man.rst | 6 ++-- type/__timezone/manifest | 73 +++++++++++++++++++--------------------- 2 files changed, 38 insertions(+), 41 deletions(-) diff --git a/type/__timezone/man.rst b/type/__timezone/man.rst index 801671d1a..8430d7df7 100644 --- a/type/__timezone/man.rst +++ b/type/__timezone/man.rst @@ -3,13 +3,13 @@ cdist-type__timezone(7) NAME ---- -cdist-type__timezone - Allows one to configure the desired localtime timezone. +cdist-type__timezone - Configure the system timezone. DESCRIPTION ----------- -This type creates a symlink (/etc/localtime) to the selected timezone -(which should be available in /usr/share/zoneinfo). +This type creates a symlink (``/etc/localtime``) to the selected +timezone (which should be available in ``/usr/share/zoneinfo``). REQUIRED PARAMETERS diff --git a/type/__timezone/manifest b/type/__timezone/manifest index 637b31b83..43b23a5a4 100755 --- a/type/__timezone/manifest +++ b/type/__timezone/manifest @@ -3,6 +3,7 @@ # 2011 Ramon Salvadó (rsalvado at gnuine.com) # 2012-2015 Steven Armstrong (steven-cdist at armstrong.cc) # 2012-2019 Nico Schottelius (nico-cdist at schottelius.org) +# 2020 Dennis Camera (dennis.camera at riiengineering.ch) # # This file is part of skonfig-base. # @@ -20,45 +21,40 @@ # along with skonfig-base. If not, see . # -timezone=$(cat "${__object:?}/parameter/tz") +TZ=$(cat "${__object:?}/parameter/tz") os=$(cat "${__global:?}/explorer/os") +localtime_file=/etc/localtime case ${os} in - (archlinux|debian|ubuntu|devuan|alpine) - __package tzdata - export require='__package/tzdata' - ;; - (suse) - __package timezone - export require='__package/timezone' - ;; - (freebsd|netbsd|openbsd) - # whitelist - : - ;; - (coreos) - # whitelist - : - ;; - (scientific|centos) - __package tzdata --state present - export require='__package/tzdata' - __file /etc/sysconfig/clock \ - --owner root --group root --mode 644 \ - --state exists - require='__file/etc/sysconfig/clock' \ - __key_value ZONE \ - --file /etc/sysconfig/clock \ - --delimiter '=' \ - --value "\"${timezone}\"" - ;; - (*) - : "${__type:?}" # make shellcheck happy - echo "Your operating system (${os}) is currently not supported by this type (${__type##*/})." >&2 - echo 'Please contribute an implementation for it if you can.' >&2 - exit 1 - ;; + (archlinux|alpine|debian|devuan|ubuntu|centos|redhat|scientific) + __package tzdata + export require=__package/tzdata + ;; + (suse) + __package timezone + export require=__package/timezone + ;; + (coreos|freebsd|netbsd|openbsd) + # whitelist + ;; + (centos|redhat|scientific) + __file /etc/sysconfig/clock \ + --state exists \ + --owner 0 --group 0 --mode 0644 + require=__file/etc/sysconfig/clock \ + __key_value /etc/sysconfig/clock:ZONE \ + --file /etc/sysconfig/clock \ + --delimiter '=' --exact_delimiter \ + --key 'ZONE' \ + --value "\"${TZ}\"" + ;; + (*) + : "${__type:?}" # make shellcheck happy + echo "Your operating system (${os}) is currently not supported by this type (${__type##*/})." >&2 + echo 'Please contribute an implementation for it if you can.' >&2 + exit 1 + ;; esac case ${os} @@ -68,6 +64,7 @@ in ;; esac -__link /etc/localtime \ - --source "/usr/share/zoneinfo/${timezone}" \ - --type symbolic +zoneinfo_file="/usr/share/zoneinfo/${TZ}" +__link "${localtime_file}" \ + --type symbolic \ + --source "${zoneinfo_file}" From 469d82dce6958b2a1f06b1e6943bcdcc6310b445 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 27 Jul 2020 18:18:46 +0200 Subject: [PATCH 03/13] [type/__timezone] Split OS blocks into package installation and configuration --- type/__timezone/manifest | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/type/__timezone/manifest b/type/__timezone/manifest index 43b23a5a4..ac1f94039 100755 --- a/type/__timezone/manifest +++ b/type/__timezone/manifest @@ -25,6 +25,7 @@ TZ=$(cat "${__object:?}/parameter/tz") os=$(cat "${__global:?}/explorer/os") localtime_file=/etc/localtime +# some OSes require a timezone package to be installed first case ${os} in (archlinux|alpine|debian|devuan|ubuntu|centos|redhat|scientific) @@ -35,8 +36,19 @@ in __package timezone export require=__package/timezone ;; - (coreos|freebsd|netbsd|openbsd) - # whitelist +esac + +# configure the timezone +case ${os} +in + (alpine) + ;; + (coreos|debian|devuan|ubuntu) + __file /etc/timezone \ + --owner 0 --group 0 --mode 0644 \ + --source - <<-EOF + ${TZ} + EOF ;; (centos|redhat|scientific) __file /etc/sysconfig/clock \ @@ -57,13 +69,6 @@ in ;; esac -case ${os} -in - (ubuntu|debian|devuan|coreos|alpine) - echo "${timezone_should}" | __file /etc/timezone --source - - ;; -esac - zoneinfo_file="/usr/share/zoneinfo/${TZ}" __link "${localtime_file}" \ --type symbolic \ From 260862dcc57d8bd0e265698f92a385269ca9b571 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 27 Jul 2020 18:33:12 +0200 Subject: [PATCH 04/13] [type/__timezone] Add zoneinfo_file explorer to check if timezone exists --- type/__timezone/explorer/zoneinfo_file | 49 ++++++++++++++++++++++++++ type/__timezone/manifest | 15 +++++++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100755 type/__timezone/explorer/zoneinfo_file diff --git a/type/__timezone/explorer/zoneinfo_file b/type/__timezone/explorer/zoneinfo_file new file mode 100755 index 000000000..bb2c110a2 --- /dev/null +++ b/type/__timezone/explorer/zoneinfo_file @@ -0,0 +1,49 @@ +#!/bin/sh -e +# +# 2020 Dennis Camera (dennis.camera at riiengineering.ch) +# +# This file is part of skonfig-base. +# +# skonfig-base is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# skonfig-base is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with skonfig-base. If not, see . +# + +TZ=$(cat "${__object:?}/parameter/tz") + +case $(uname -s) +in + (Darwin) + TZDIR=/var/db/timezone/zoneinfo + ;; + (SunOS) + TZDIR=/usr/share/lib/zoneinfo + ;; + (*) + # According to glibc's tzfile(5) there are two typical directories: + if test -d /usr/share/zoneinfo + then + # Linux, FreeBSD, OpenBSD, NetBSD. And others? + TZDIR=/usr/share/zoneinfo + elif test -d /usr/lib/zoneinfo + then + # Old libc4, libc5 apparently. + TZDIR=/usr/lib/zoneinfo + else + exit 0 + fi +esac + +if test -e "${TZDIR}/${TZ}" +then + echo "${TZDIR}/${TZ}" +fi diff --git a/type/__timezone/manifest b/type/__timezone/manifest index ac1f94039..6d1c77ca8 100755 --- a/type/__timezone/manifest +++ b/type/__timezone/manifest @@ -24,6 +24,15 @@ TZ=$(cat "${__object:?}/parameter/tz") os=$(cat "${__global:?}/explorer/os") localtime_file=/etc/localtime +zoneinfo_file=$(cat "${__object:?}/explorer/zoneinfo_file") + +invalid_timezone() { + # NOTE: When the tzdata package was just installed, this might produce an + # invalid timezone error because the explorer has been run before the + # installation. + printf 'Invalid timezone: %s\n' "${TZ}" >&2 + exit 1 +} # some OSes require a timezone package to be installed first case ${os} @@ -42,8 +51,11 @@ esac case ${os} in (alpine) + test -n "${zoneinfo_file}" || invalid_timezone ;; (coreos|debian|devuan|ubuntu) + test -n "${zoneinfo_file}" || invalid_timezone + __file /etc/timezone \ --owner 0 --group 0 --mode 0644 \ --source - <<-EOF @@ -51,6 +63,8 @@ in EOF ;; (centos|redhat|scientific) + test -n "${zoneinfo_file}" || invalid_timezone + __file /etc/sysconfig/clock \ --state exists \ --owner 0 --group 0 --mode 0644 @@ -69,7 +83,6 @@ in ;; esac -zoneinfo_file="/usr/share/zoneinfo/${TZ}" __link "${localtime_file}" \ --type symbolic \ --source "${zoneinfo_file}" From f1d1c8a2f281d2fda1a485e6a940abd8df3302d3 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 27 Jul 2020 19:02:34 +0200 Subject: [PATCH 05/13] [type/__timezone] Add support for VoidLinux --- type/__timezone/manifest | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/type/__timezone/manifest b/type/__timezone/manifest index 6d1c77ca8..7449ab75e 100755 --- a/type/__timezone/manifest +++ b/type/__timezone/manifest @@ -37,7 +37,7 @@ invalid_timezone() { # some OSes require a timezone package to be installed first case ${os} in - (archlinux|alpine|debian|devuan|ubuntu|centos|redhat|scientific) + (archlinux|alpine|debian|devuan|ubuntu|centos|redhat|scientific|voidlinux) __package tzdata export require=__package/tzdata ;; @@ -75,6 +75,15 @@ in --key 'ZONE' \ --value "\"${TZ}\"" ;; + (voidlinux) + test -n "${zoneinfo_file}" || invalid_timezone + + __key_value /etc/rc.conf:TIMEZONE \ + --file /etc/rc.conf \ + --key TIMEZONE \ + --delimiter '=' --exact_delimiter \ + --value "\"${TZ}\"" + ;; (*) : "${__type:?}" # make shellcheck happy echo "Your operating system (${os}) is currently not supported by this type (${__type##*/})." >&2 From 7c4200a8fdb576ddf330c3808da5f802efb756f3 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 27 Jul 2020 19:34:12 +0200 Subject: [PATCH 06/13] [type/__timezone] Add support for Slackware --- type/__timezone/manifest | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/type/__timezone/manifest b/type/__timezone/manifest index 7449ab75e..bd7960269 100755 --- a/type/__timezone/manifest +++ b/type/__timezone/manifest @@ -45,12 +45,16 @@ in __package timezone export require=__package/timezone ;; + (slackware) + __package glibc-zoneinfo + export require=__package/glibc-zoneinfo + ;; esac # configure the timezone case ${os} in - (alpine) + (alpine|slackware) test -n "${zoneinfo_file}" || invalid_timezone ;; (coreos|debian|devuan|ubuntu) From 62fe63f93f267b260157a5a81ac0cf1aef3b7eb6 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 27 Jul 2020 19:36:57 +0200 Subject: [PATCH 07/13] [type/__timezone] Add support for Gentoo --- type/__timezone/manifest | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/type/__timezone/manifest b/type/__timezone/manifest index bd7960269..e14b1c3b2 100755 --- a/type/__timezone/manifest +++ b/type/__timezone/manifest @@ -41,6 +41,10 @@ in __package tzdata export require=__package/tzdata ;; + (gentoo) + __package sys-libs/timezone-data + export require=__package/sys-libs/timezone-data + ;; (suse) __package timezone export require=__package/timezone @@ -79,6 +83,24 @@ in --key 'ZONE' \ --value "\"${TZ}\"" ;; + (gentoo) + test -n "${zoneinfo_file}" || invalid_timezone + + # XXX: systemd? + + __file /etc/timezone \ + --owner 0 --group 0 --mode 0644 \ + --source - <<-EOF + ${TZ} + EOF + + # XXX: Should /etc/TZ be updated?? + __file /etc/TZ \ + --owner 0 --group 0 --mode 0644 \ + --source - <<-EOF + ${TZ} + EOF + ;; (voidlinux) test -n "${zoneinfo_file}" || invalid_timezone From 9a193d6c81dc89cb37f551e9edd00b4b28e83501 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 27 Jul 2020 20:05:24 +0200 Subject: [PATCH 08/13] [type/__timezone] Add support for FreeBSD --- type/__timezone/manifest | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/type/__timezone/manifest b/type/__timezone/manifest index e14b1c3b2..338940a4f 100755 --- a/type/__timezone/manifest +++ b/type/__timezone/manifest @@ -101,6 +101,15 @@ in ${TZ} EOF ;; + (freebsd) + test -n "${zoneinfo_file}" || invalid_timezone + + __file /var/db/zoneinfo \ + --owner 0 --group 0 --mode 0644 \ + --source - <<-EOF + ${TZ} + EOF + ;; (voidlinux) test -n "${zoneinfo_file}" || invalid_timezone From 2bbfadb332b95884d11d7f01c636834229e531b8 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Tue, 28 Jul 2020 11:22:23 +0200 Subject: [PATCH 09/13] [type/__timezone] Add --tzdir parameter --- type/__timezone/explorer/zoneinfo_file | 58 ++++++++++++++++---------- type/__timezone/man.rst | 14 +++++++ type/__timezone/parameter/optional | 1 + 3 files changed, 50 insertions(+), 23 deletions(-) create mode 100644 type/__timezone/parameter/optional diff --git a/type/__timezone/explorer/zoneinfo_file b/type/__timezone/explorer/zoneinfo_file index bb2c110a2..e8990774f 100755 --- a/type/__timezone/explorer/zoneinfo_file +++ b/type/__timezone/explorer/zoneinfo_file @@ -17,33 +17,45 @@ # You should have received a copy of the GNU General Public License # along with skonfig-base. If not, see . # +# Determine and print the path of the --tz zoneinfo file. +# If the zone is invalid, the explorer produces empty output. +# TZ=$(cat "${__object:?}/parameter/tz") -case $(uname -s) -in - (Darwin) - TZDIR=/var/db/timezone/zoneinfo - ;; - (SunOS) - TZDIR=/usr/share/lib/zoneinfo - ;; - (*) - # According to glibc's tzfile(5) there are two typical directories: - if test -d /usr/share/zoneinfo - then - # Linux, FreeBSD, OpenBSD, NetBSD. And others? - TZDIR=/usr/share/zoneinfo - elif test -d /usr/lib/zoneinfo - then - # Old libc4, libc5 apparently. - TZDIR=/usr/lib/zoneinfo - else - exit 0 - fi -esac +if test -s "${__object:?}/parameter/tzdir" +then + TZDIR=$(cat "${__object:?}/parameter/tzdir") + + test -d "${TZDIR}" || { + printf 'Invalid --tzdir: no such directory: %s\n' "${TZDIR}" >&2 + exit 1 + } +else + case $(uname -s) + in + (Darwin) + TZDIR=/var/db/timezone/zoneinfo + ;; + (SunOS) + TZDIR=/usr/share/lib/zoneinfo + ;; + (*) + # According to glibc's tzfile(5) there are two typical directories: + if test -d /usr/share/zoneinfo + then + # Linux, FreeBSD, OpenBSD, NetBSD. And others? + TZDIR=/usr/share/zoneinfo + elif test -d /usr/lib/zoneinfo + then + # Old libc4, libc5 apparently. + TZDIR=/usr/lib/zoneinfo + fi + ;; + esac +fi -if test -e "${TZDIR}/${TZ}" +if test -n "${TZDIR-}" && test -e "${TZDIR}/${TZ}" then echo "${TZDIR}/${TZ}" fi diff --git a/type/__timezone/man.rst b/type/__timezone/man.rst index 8430d7df7..8d96ab999 100644 --- a/type/__timezone/man.rst +++ b/type/__timezone/man.rst @@ -18,6 +18,14 @@ tz The name of the timezone to set. +OPTIONAL PARAMETERS +------------------- +tzdir + The directory containing the timezone data files on the target. + + Default: detected based on OS, usually ``/usr/share/zoneinfo``. + + EXAMPLES -------- @@ -29,6 +37,12 @@ EXAMPLES # Set up US/Central as our timezone. __timezone --tz US/Central + # Some operating systems (e.g. Debian, RedHat, SuSE) have a separate + # directory for POSIX timezones (time values interpreted as seconds since + # the epoch, not counting leap seconds). + # It can be used by manually specifying the TZDIR. + __timezone --tz Europe/Vaduz --tzdir /usr/share/zoneinfo/posix + AUTHORS ------- diff --git a/type/__timezone/parameter/optional b/type/__timezone/parameter/optional new file mode 100644 index 000000000..d0719869f --- /dev/null +++ b/type/__timezone/parameter/optional @@ -0,0 +1 @@ +tzdir From a31144f6bf60f406d20f489d49b1d9afba1fa0cc Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 9 Nov 2020 17:03:43 +0100 Subject: [PATCH 10/13] [type/__timezone] Make relative links to localtime This is advantageous for e.g. chroot jails. --- type/__timezone/manifest | 47 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/type/__timezone/manifest b/type/__timezone/manifest index 338940a4f..480fc6c96 100755 --- a/type/__timezone/manifest +++ b/type/__timezone/manifest @@ -26,6 +26,50 @@ os=$(cat "${__global:?}/explorer/os") localtime_file=/etc/localtime zoneinfo_file=$(cat "${__object:?}/explorer/zoneinfo_file") +canonicalize_path() { + # NOTE: Only works for absolute paths + # shellcheck disable=SC2016 + printf '%s\n' "${1:?}" \ + | tr '/' '\n' \ + | sed -n -e ' + # ignore empty lines (produced by // in original path and leading /) + /^$/bq + # ignore /./ components + /^\.$/bq + # drop a component from the "stack" if a .. is met + /^\.\.$/{ + # delete last line from hold space + x + s/^\(.*\)\n.*$/\1/ + x + bq + } + # push component to "stack" (append to hold space) + H + :q + # print stack contents (hold space) at the end + ${x;p;}' \ + | sed -n -e 'H;${g;s/^\n//;s/\n/\//g;p;}' +} + +count_path_components() ( + components=$(canonicalize_path "$1") + IFS=/ + # shellcheck disable=SC2048,SC2086 + set -f -- ${components#/} + echo $# +) + +backdirs() { + test "${1:-0}" -gt 0 || { printf './\n'; return 0; } + until test "${1:-0}" -le 0 + do + printf '../' + set -- $(($1 - 1)) + done + printf '\n' +} + invalid_timezone() { # NOTE: When the tzdata package was just installed, this might produce an # invalid timezone error because the explorer has been run before the @@ -127,6 +171,7 @@ in ;; esac +rel_zoneinfo_file="$(backdirs "$(count_path_components "${localtime_file%/*}")")${zoneinfo_file#/}" __link "${localtime_file}" \ --type symbolic \ - --source "${zoneinfo_file}" + --source "${rel_zoneinfo_file}" From f9fcb80c7eef23bdfadb1a30fd5091f958feeb04 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Wed, 11 Nov 2020 10:36:09 +0100 Subject: [PATCH 11/13] [type/__timezone] Update sysconfig on SuSE --- type/__timezone/manifest | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/type/__timezone/manifest b/type/__timezone/manifest index 480fc6c96..f27a84bda 100755 --- a/type/__timezone/manifest +++ b/type/__timezone/manifest @@ -154,6 +154,22 @@ in ${TZ} EOF ;; + (suse) + os_version=$(cat "${__global:?}/explorer/os_version") + os_major=${os_version%%[!0-9]*} + + # TODO: Consider using `yast2 timezone ...` instead + if test $((os_major)) -lt 15 || test $((os_major)) -eq 42 + then + # It seems that starting with SuSE 15 /etc/sysconfig/clock is + # abandoned. The file still exists but only contains a + # DEFAULT_TIMEZONE entry. + __key_value /etc/sysconfig/clock:TIMEZONE \ + --file /etc/sysconfig/clock \ + --delimiter '=' --exact_delimiter \ + --key TIMEZONE --value "\"${TZ}\"" + fi + ;; (voidlinux) test -n "${zoneinfo_file}" || invalid_timezone From e4509c49212419b36a08056aa78bda598e86a5fa Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Sun, 25 May 2025 17:42:05 +0200 Subject: [PATCH 12/13] =?UTF-8?q?[type/=5F=5Ftimezone]=20Add=20support=20f?= =?UTF-8?q?or=20Ad=C3=A9lie=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- type/__timezone/man.rst | 2 +- type/__timezone/manifest | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/type/__timezone/man.rst b/type/__timezone/man.rst index 8d96ab999..7eaa2ea83 100644 --- a/type/__timezone/man.rst +++ b/type/__timezone/man.rst @@ -54,7 +54,7 @@ AUTHORS COPYING ------- -Copyright \(C) 2012-2020 the `AUTHORS`_. +Copyright \(C) 2012-2025 the `AUTHORS`_. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/type/__timezone/manifest b/type/__timezone/manifest index f27a84bda..7322cfd3e 100755 --- a/type/__timezone/manifest +++ b/type/__timezone/manifest @@ -3,7 +3,7 @@ # 2011 Ramon Salvadó (rsalvado at gnuine.com) # 2012-2015 Steven Armstrong (steven-cdist at armstrong.cc) # 2012-2019 Nico Schottelius (nico-cdist at schottelius.org) -# 2020 Dennis Camera (dennis.camera at riiengineering.ch) +# 2020,2025 Dennis Camera (dennis.camera at riiengineering.ch) # # This file is part of skonfig-base. # @@ -81,7 +81,7 @@ invalid_timezone() { # some OSes require a timezone package to be installed first case ${os} in - (archlinux|alpine|debian|devuan|ubuntu|centos|redhat|scientific|voidlinux) + (adelie|alpine|archlinux|debian|devuan|ubuntu|centos|redhat|scientific|voidlinux) __package tzdata export require=__package/tzdata ;; @@ -102,7 +102,7 @@ esac # configure the timezone case ${os} in - (alpine|slackware) + (adelie|alpine|slackware) test -n "${zoneinfo_file}" || invalid_timezone ;; (coreos|debian|devuan|ubuntu) From f2872335a2fa1817c3068a40cbbc9f1fe90f4f4c Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Sun, 25 May 2025 17:44:30 +0200 Subject: [PATCH 13/13] [type/__timezone] Update man.rst --- type/__timezone/man.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/type/__timezone/man.rst b/type/__timezone/man.rst index 7eaa2ea83..b4106ad37 100644 --- a/type/__timezone/man.rst +++ b/type/__timezone/man.rst @@ -9,7 +9,12 @@ cdist-type__timezone - Configure the system timezone. DESCRIPTION ----------- This type creates a symlink (``/etc/localtime``) to the selected -timezone (which should be available in ``/usr/share/zoneinfo``). +timezone (which should be available in ``--tzdir`` which is usually +``/usr/share/zoneinfo``). + +On some operating systems, other system-specific files are modified as well. + +If necessary, the zoneinfo database (``tzdata``) will be installed on the target. REQUIRED PARAMETERS @@ -17,6 +22,8 @@ REQUIRED PARAMETERS tz The name of the timezone to set. + It should map to a file present in ``--tzdir``. + OPTIONAL PARAMETERS -------------------