main/postmarketos-base: migrate wrong timezone configurations (MR 4308)

So that old installations that run setup-timezone without "-i" do not
need to execute manual steps to get sensible timezone configurations.

See https://gitlab.com/postmarketOS/pmaports/-/issues/2168 for more context

Fixes #2168
[ci:skip-build]: already built successfully in CI
This commit is contained in:
Pablo Correa Gómez 2023-08-05 23:33:35 +02:00 committed by Oliver Smith
parent 0383bcaa1e
commit 04abb5b1a7
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 22 additions and 1 deletions

View file

@ -1,6 +1,6 @@
pkgname=postmarketos-base
pkgver=27
pkgrel=0
pkgrel=1
pkgdesc="Meta package for minimal postmarketOS base"
url="https://postmarketos.org"
arch="noarch"

View file

@ -3,3 +3,24 @@
# Otherwise it will enable services, as listed in that file. And we don't want
# this to happen during upgrade, especially not automatically enabling the sshd
# service! (build.postmarketos.org#85)
# Fixup old pmOS installations that run setup-timezone without "-i" option
# and those later installations that run with it, but have missing
# https://gitlab.alpinelinux.org/alpine/alpine-conf/-/merge_requests/157
# See https://gitlab.com/postmarketOS/pmaports/-/issues/2168 for context
# This is probably safe to remove after a couple of releases of the alpine-conf
# fix having been merged
[ -L /etc/localtime ] || exit 0
localtime="$(readlink /etc/localtime)"
restart="yes"
case "$localtime" in
//usr/share/zoneinfo/*) localtime=${localtime#/*} ;;
//etc/zoneinfo*) localtime="/usr/share/zoneinfo/${localtime#//etc/zoneinfo/*}" ;;
/etc/zoneinfo/*) localtime="/usr/share/zoneinfo/${localtime#/etc/zoneinfo/*}" ;;
*) restart="no" ;;
esac
ln -sf "$localtime" /etc/localtime
rm -rf /etc/zoneinfo
[ "$restart" = "yes" ] && service -qq openrc-settingsd restart
exit 0