From 36d5bcbd3db6f0e7d8161b9ce498e75117e8318a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= Date: Sun, 11 Jun 2023 17:07:40 +0200 Subject: [PATCH] install: move setup_timezone to its own function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some refactoring for the next commit Signed-off-by: Pablo Correa Gómez Tested-by: Clayton Craft Reviewed-by: Oliver Smith Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230611150743.23310-2-ablocorrea@hotmail.com%3E --- pmb/install/_install.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/pmb/install/_install.py b/pmb/install/_install.py index 28f40459..eaf73864 100644 --- a/pmb/install/_install.py +++ b/pmb/install/_install.py @@ -354,6 +354,20 @@ def setup_keymap(args): logging.info("NOTE: No valid keymap specified for device") +def setup_timezone(args): + suffix = f"rootfs_{args.device}" + + arch = args.deviceinfo["arch"] + alpine_conf = pmb.helpers.package.get(args, "alpine-conf", arch) + version = alpine_conf["version"].split("-r")[0] + + setup_tz_cmd = ["setup-timezone"] + if not pmb.parse.version.check_string(version, ">=3.14.0"): + setup_tz_cmd += ["-z"] + setup_tz_cmd += [args.timezone] + pmb.chroot.root(args, setup_tz_cmd, suffix) + + def setup_hostname(args): """ Set the hostname and update localhost address in /etc/hosts @@ -1021,14 +1035,7 @@ def create_device_rootfs(args, step, steps): setup_keymap(args) # Set timezone - arch = args.deviceinfo["arch"] - package = pmb.helpers.package.get(args, "alpine-conf", arch) - version = package["version"].split("-r")[0] - - if not pmb.parse.version.check_string(version, ">=3.14.0"): - pmb.chroot.root(args, ["setup-timezone", "-z", args.timezone], suffix) - else: - pmb.chroot.root(args, ["setup-timezone", args.timezone], suffix) + setup_timezone(args) # Set locale if locale_is_set: