blob: 7f4322d8671e165eedca8bdc64a53a6d40305020 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001require timezone.inc
2
3DEPENDS = "tzcode-native"
4
5inherit allarch
6
Brad Bishop19323692019-04-05 15:28:33 -04007S = "${WORKDIR}"
8
9DEFAULT_TIMEZONE ?= "Universal"
10INSTALL_TIMEZONE_FILE ?= "1"
11
Andrew Geissler595f6302022-01-24 19:11:47 +000012TZONES = " \
13 africa antarctica asia australasia europe northamerica southamerica \
14 factory etcetera backward \
15"
Brad Bishop19323692019-04-05 15:28:33 -040016
Andrew Geissler5f350902021-07-23 13:09:54 -040017# "slim" is the default since 2020b
18# "fat" is needed by e.g. MariaDB's mysql_tzinfo_to_sql
19ZIC_FMT ?= "slim"
20
Andrew Geissler595f6302022-01-24 19:11:47 +000021do_compile() {
22 for zone in ${TZONES}; do
23 ${STAGING_BINDIR_NATIVE}/zic -b ${ZIC_FMT} -d ${WORKDIR}${datadir}/zoneinfo -L /dev/null ${S}/${zone}
24 ${STAGING_BINDIR_NATIVE}/zic -b ${ZIC_FMT} -d ${WORKDIR}${datadir}/zoneinfo/posix -L /dev/null ${S}/${zone}
25 ${STAGING_BINDIR_NATIVE}/zic -b ${ZIC_FMT} -d ${WORKDIR}${datadir}/zoneinfo/right -L ${S}/leapseconds ${S}/${zone}
26 done
Brad Bishop19323692019-04-05 15:28:33 -040027}
28
Andrew Geissler595f6302022-01-24 19:11:47 +000029do_install() {
30 install -d ${D}$exec_prefix ${D}${datadir}/zoneinfo
31 cp -pPR ${WORKDIR}$exec_prefix ${D}${base_prefix}
32 # libc is removing zoneinfo files from package
33 cp -pP "${S}/zone.tab" ${D}${datadir}/zoneinfo
34 cp -pP "${S}/zone1970.tab" ${D}${datadir}/zoneinfo
35 cp -pP "${S}/iso3166.tab" ${D}${datadir}/zoneinfo
36 cp -pP "${S}/leapseconds" ${D}${datadir}/zoneinfo
37 cp -pP "${S}/leap-seconds.list" ${D}${datadir}/zoneinfo
Brad Bishop19323692019-04-05 15:28:33 -040038
Andrew Geissler595f6302022-01-24 19:11:47 +000039 # Install default timezone
40 if [ -e ${D}${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ]; then
41 install -d ${D}${sysconfdir}
42 if [ "${INSTALL_TIMEZONE_FILE}" = "1" ]; then
43 echo ${DEFAULT_TIMEZONE} > ${D}${sysconfdir}/timezone
44 fi
45 ln -s ${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime
46 else
47 bberror "DEFAULT_TIMEZONE is set to an invalid value."
48 exit 1
49 fi
Brad Bishop19323692019-04-05 15:28:33 -040050
Andrew Geissler595f6302022-01-24 19:11:47 +000051 chown -R root:root ${D}
Brad Bishop19323692019-04-05 15:28:33 -040052}
53
Andrew Geissler595f6302022-01-24 19:11:47 +000054pkg_postinst:${PN}() {
Brad Bishop19323692019-04-05 15:28:33 -040055 etc_lt="$D${sysconfdir}/localtime"
56 src="$D${sysconfdir}/timezone"
57
Andrew Geissler595f6302022-01-24 19:11:47 +000058 if [ -e "$src" ]; then
59 tz=$(sed -e 's:#.*::' -e 's:[[:space:]]*::g' -e '/^$/d' "$src")
Brad Bishop19323692019-04-05 15:28:33 -040060 fi
Andrew Geissler82c905d2020-04-13 13:39:40 -050061
Andrew Geissler595f6302022-01-24 19:11:47 +000062 if [ ! -z "$tz" -a ! -e "$D${datadir}/zoneinfo/$tz" ]; then
63 echo "You have an invalid TIMEZONE setting in $src"
64 echo "Your $etc_lt has been reset to Universal; enjoy!"
Brad Bishop19323692019-04-05 15:28:33 -040065 tz="Universal"
Andrew Geissler595f6302022-01-24 19:11:47 +000066 echo "Updating $etc_lt with $D${datadir}/zoneinfo/$tz"
67 if [ -L "$etc_lt" ]; then
68 rm -f "$etc_lt"
Brad Bishop19323692019-04-05 15:28:33 -040069 fi
Andrew Geissler595f6302022-01-24 19:11:47 +000070 ln -s "${datadir}/zoneinfo/$tz" "$etc_lt"
Brad Bishop19323692019-04-05 15:28:33 -040071 fi
72}
73
Andrew Geissler595f6302022-01-24 19:11:47 +000074# Packages are primarily organized by directory with a major city in most time
75# zones in the base package
Brad Bishop19323692019-04-05 15:28:33 -040076TZ_PACKAGES = " \
77 tzdata-core tzdata-misc tzdata-posix tzdata-right tzdata-africa \
78 tzdata-americas tzdata-antarctica tzdata-arctic tzdata-asia \
Andrew Geissler595f6302022-01-24 19:11:47 +000079 tzdata-atlantic tzdata-australia tzdata-europe tzdata-pacific \
80"
Brad Bishop19323692019-04-05 15:28:33 -040081PACKAGES = "${TZ_PACKAGES} ${PN}"
82
Andrew Geissler595f6302022-01-24 19:11:47 +000083FILES:tzdata-africa += "${datadir}/zoneinfo/Africa"
Brad Bishop19323692019-04-05 15:28:33 -040084
Andrew Geissler595f6302022-01-24 19:11:47 +000085FILES:tzdata-americas += " \
86 ${datadir}/zoneinfo/America \
87 ${datadir}/zoneinfo/US \
88 ${datadir}/zoneinfo/Brazil \
89 ${datadir}/zoneinfo/Canada \
90 ${datadir}/zoneinfo/Mexico \
91 ${datadir}/zoneinfo/Chile \
92"
Brad Bishop19323692019-04-05 15:28:33 -040093
Andrew Geissler595f6302022-01-24 19:11:47 +000094FILES:tzdata-antarctica += "${datadir}/zoneinfo/Antarctica"
Brad Bishop19323692019-04-05 15:28:33 -040095
Andrew Geissler595f6302022-01-24 19:11:47 +000096FILES:tzdata-arctic += "${datadir}/zoneinfo/Arctic"
Brad Bishop19323692019-04-05 15:28:33 -040097
Andrew Geissler595f6302022-01-24 19:11:47 +000098FILES:tzdata-asia += " \
99 ${datadir}/zoneinfo/Asia \
100 ${datadir}/zoneinfo/Indian \
101 ${datadir}/zoneinfo/Mideast \
102"
Brad Bishop19323692019-04-05 15:28:33 -0400103
Andrew Geissler595f6302022-01-24 19:11:47 +0000104FILES:tzdata-atlantic += "${datadir}/zoneinfo/Atlantic"
Brad Bishop19323692019-04-05 15:28:33 -0400105
Andrew Geissler595f6302022-01-24 19:11:47 +0000106FILES:tzdata-australia += "${datadir}/zoneinfo/Australia"
Brad Bishop19323692019-04-05 15:28:33 -0400107
Andrew Geissler595f6302022-01-24 19:11:47 +0000108FILES:tzdata-europe += "${datadir}/zoneinfo/Europe"
Brad Bishop19323692019-04-05 15:28:33 -0400109
Andrew Geissler595f6302022-01-24 19:11:47 +0000110FILES:tzdata-pacific += "${datadir}/zoneinfo/Pacific"
Brad Bishop19323692019-04-05 15:28:33 -0400111
Andrew Geissler595f6302022-01-24 19:11:47 +0000112FILES:tzdata-posix += "${datadir}/zoneinfo/posix"
Brad Bishop19323692019-04-05 15:28:33 -0400113
Andrew Geissler595f6302022-01-24 19:11:47 +0000114FILES:tzdata-right += "${datadir}/zoneinfo/right"
Brad Bishop19323692019-04-05 15:28:33 -0400115
Andrew Geissler595f6302022-01-24 19:11:47 +0000116FILES:tzdata-misc += " \
117 ${datadir}/zoneinfo/Cuba \
118 ${datadir}/zoneinfo/Egypt \
119 ${datadir}/zoneinfo/Eire \
120 ${datadir}/zoneinfo/Factory \
121 ${datadir}/zoneinfo/GB-Eire \
122 ${datadir}/zoneinfo/Hongkong \
123 ${datadir}/zoneinfo/Iceland \
124 ${datadir}/zoneinfo/Iran \
125 ${datadir}/zoneinfo/Israel \
126 ${datadir}/zoneinfo/Jamaica \
127 ${datadir}/zoneinfo/Japan \
128 ${datadir}/zoneinfo/Kwajalein \
129 ${datadir}/zoneinfo/Libya \
130 ${datadir}/zoneinfo/Navajo \
131 ${datadir}/zoneinfo/Poland \
132 ${datadir}/zoneinfo/Portugal \
133 ${datadir}/zoneinfo/Singapore \
134 ${datadir}/zoneinfo/Turkey \
135"
Brad Bishop19323692019-04-05 15:28:33 -0400136
Patrick Williams213cb262021-08-07 19:21:33 -0500137FILES:tzdata-core += " \
Andrew Geissler595f6302022-01-24 19:11:47 +0000138 ${sysconfdir}/localtime \
139 ${sysconfdir}/timezone \
140 ${datadir}/zoneinfo/leapseconds \
141 ${datadir}/zoneinfo/leap-seconds.list \
142 ${datadir}/zoneinfo/Pacific/Honolulu \
143 ${datadir}/zoneinfo/America/Anchorage \
144 ${datadir}/zoneinfo/America/Los_Angeles \
145 ${datadir}/zoneinfo/America/Denver \
146 ${datadir}/zoneinfo/America/Chicago \
147 ${datadir}/zoneinfo/America/New_York \
148 ${datadir}/zoneinfo/America/Caracas \
149 ${datadir}/zoneinfo/America/Sao_Paulo \
150 ${datadir}/zoneinfo/Europe/London \
151 ${datadir}/zoneinfo/Europe/Paris \
152 ${datadir}/zoneinfo/Africa/Cairo \
153 ${datadir}/zoneinfo/Europe/Moscow \
154 ${datadir}/zoneinfo/Asia/Dubai \
155 ${datadir}/zoneinfo/Asia/Karachi \
156 ${datadir}/zoneinfo/Asia/Dhaka \
157 ${datadir}/zoneinfo/Asia/Bangkok \
158 ${datadir}/zoneinfo/Asia/Hong_Kong \
159 ${datadir}/zoneinfo/Asia/Tokyo \
160 ${datadir}/zoneinfo/Australia/Darwin \
161 ${datadir}/zoneinfo/Australia/Adelaide \
162 ${datadir}/zoneinfo/Australia/Brisbane \
163 ${datadir}/zoneinfo/Australia/Sydney \
164 ${datadir}/zoneinfo/Pacific/Noumea \
165 ${datadir}/zoneinfo/CET \
166 ${datadir}/zoneinfo/CST6CDT \
167 ${datadir}/zoneinfo/EET \
168 ${datadir}/zoneinfo/EST \
169 ${datadir}/zoneinfo/EST5EDT \
170 ${datadir}/zoneinfo/GB \
171 ${datadir}/zoneinfo/GMT \
172 ${datadir}/zoneinfo/GMT+0 \
173 ${datadir}/zoneinfo/GMT-0 \
174 ${datadir}/zoneinfo/GMT0 \
175 ${datadir}/zoneinfo/Greenwich \
176 ${datadir}/zoneinfo/HST \
177 ${datadir}/zoneinfo/MET \
178 ${datadir}/zoneinfo/MST \
179 ${datadir}/zoneinfo/MST7MDT \
180 ${datadir}/zoneinfo/NZ \
181 ${datadir}/zoneinfo/NZ-CHAT \
182 ${datadir}/zoneinfo/PRC \
183 ${datadir}/zoneinfo/PST8PDT \
184 ${datadir}/zoneinfo/ROC \
185 ${datadir}/zoneinfo/ROK \
186 ${datadir}/zoneinfo/UCT \
187 ${datadir}/zoneinfo/UTC \
188 ${datadir}/zoneinfo/Universal \
189 ${datadir}/zoneinfo/W-SU \
190 ${datadir}/zoneinfo/WET \
191 ${datadir}/zoneinfo/Zulu \
192 ${datadir}/zoneinfo/zone.tab \
193 ${datadir}/zoneinfo/zone1970.tab \
194 ${datadir}/zoneinfo/iso3166.tab \
195 ${datadir}/zoneinfo/Etc \
196"
Brad Bishop19323692019-04-05 15:28:33 -0400197
Patrick Williams213cb262021-08-07 19:21:33 -0500198CONFFILES:tzdata-core = "${sysconfdir}/localtime ${sysconfdir}/timezone"
Brad Bishop19323692019-04-05 15:28:33 -0400199
Patrick Williams213cb262021-08-07 19:21:33 -0500200ALLOW_EMPTY:${PN} = "1"
Andrew Geissler595f6302022-01-24 19:11:47 +0000201
Patrick Williams213cb262021-08-07 19:21:33 -0500202RDEPENDS:${PN} = "${TZ_PACKAGES}"