blob: dd1960ffa70e79d3d8016d7464bcf02208dca8ba [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 -04007DEFAULT_TIMEZONE ?= "Universal"
8INSTALL_TIMEZONE_FILE ?= "1"
9
Andrew Geissler595f6302022-01-24 19:11:47 +000010TZONES = " \
11 africa antarctica asia australasia europe northamerica southamerica \
12 factory etcetera backward \
13"
Brad Bishop19323692019-04-05 15:28:33 -040014
Andrew Geissler5f350902021-07-23 13:09:54 -040015# "slim" is the default since 2020b
16# "fat" is needed by e.g. MariaDB's mysql_tzinfo_to_sql
17ZIC_FMT ?= "slim"
18
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050019do_configure[cleandirs] = "${B}"
20B = "${WORKDIR}/build"
21
Andrew Geissler595f6302022-01-24 19:11:47 +000022do_compile() {
23 for zone in ${TZONES}; do
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050024 ${STAGING_BINDIR_NATIVE}/zic -b ${ZIC_FMT} -d ${B}/zoneinfo -L /dev/null ${S}/${zone}
25 ${STAGING_BINDIR_NATIVE}/zic -b ${ZIC_FMT} -d ${B}/zoneinfo/posix -L /dev/null ${S}/${zone}
26 ${STAGING_BINDIR_NATIVE}/zic -b ${ZIC_FMT} -d ${B}/zoneinfo/right -L ${S}/leapseconds ${S}/${zone}
Andrew Geissler595f6302022-01-24 19:11:47 +000027 done
Brad Bishop19323692019-04-05 15:28:33 -040028}
29
Andrew Geissler595f6302022-01-24 19:11:47 +000030do_install() {
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050031 install -d ${D}${datadir}/zoneinfo
32 cp -pPR ${B}/zoneinfo/* ${D}${datadir}/zoneinfo
33
Andrew Geissler595f6302022-01-24 19:11:47 +000034 # libc is removing zoneinfo files from package
35 cp -pP "${S}/zone.tab" ${D}${datadir}/zoneinfo
36 cp -pP "${S}/zone1970.tab" ${D}${datadir}/zoneinfo
37 cp -pP "${S}/iso3166.tab" ${D}${datadir}/zoneinfo
38 cp -pP "${S}/leapseconds" ${D}${datadir}/zoneinfo
39 cp -pP "${S}/leap-seconds.list" ${D}${datadir}/zoneinfo
Brad Bishop19323692019-04-05 15:28:33 -040040
Andrew Geissler595f6302022-01-24 19:11:47 +000041 # Install default timezone
42 if [ -e ${D}${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ]; then
43 install -d ${D}${sysconfdir}
44 if [ "${INSTALL_TIMEZONE_FILE}" = "1" ]; then
45 echo ${DEFAULT_TIMEZONE} > ${D}${sysconfdir}/timezone
46 fi
47 ln -s ${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime
48 else
49 bberror "DEFAULT_TIMEZONE is set to an invalid value."
50 exit 1
51 fi
Brad Bishop19323692019-04-05 15:28:33 -040052
Andrew Geissler595f6302022-01-24 19:11:47 +000053 chown -R root:root ${D}
Brad Bishop19323692019-04-05 15:28:33 -040054}
55
Andrew Geissler595f6302022-01-24 19:11:47 +000056pkg_postinst:${PN}() {
Brad Bishop19323692019-04-05 15:28:33 -040057 etc_lt="$D${sysconfdir}/localtime"
58 src="$D${sysconfdir}/timezone"
59
Andrew Geissler595f6302022-01-24 19:11:47 +000060 if [ -e "$src" ]; then
61 tz=$(sed -e 's:#.*::' -e 's:[[:space:]]*::g' -e '/^$/d' "$src")
Brad Bishop19323692019-04-05 15:28:33 -040062 fi
Andrew Geissler82c905d2020-04-13 13:39:40 -050063
Andrew Geissler595f6302022-01-24 19:11:47 +000064 if [ ! -z "$tz" -a ! -e "$D${datadir}/zoneinfo/$tz" ]; then
65 echo "You have an invalid TIMEZONE setting in $src"
66 echo "Your $etc_lt has been reset to Universal; enjoy!"
Brad Bishop19323692019-04-05 15:28:33 -040067 tz="Universal"
Andrew Geissler595f6302022-01-24 19:11:47 +000068 echo "Updating $etc_lt with $D${datadir}/zoneinfo/$tz"
69 if [ -L "$etc_lt" ]; then
70 rm -f "$etc_lt"
Brad Bishop19323692019-04-05 15:28:33 -040071 fi
Andrew Geissler595f6302022-01-24 19:11:47 +000072 ln -s "${datadir}/zoneinfo/$tz" "$etc_lt"
Brad Bishop19323692019-04-05 15:28:33 -040073 fi
74}
75
Andrew Geissler595f6302022-01-24 19:11:47 +000076# Packages are primarily organized by directory with a major city in most time
77# zones in the base package
Brad Bishop19323692019-04-05 15:28:33 -040078TZ_PACKAGES = " \
79 tzdata-core tzdata-misc tzdata-posix tzdata-right tzdata-africa \
80 tzdata-americas tzdata-antarctica tzdata-arctic tzdata-asia \
Andrew Geissler595f6302022-01-24 19:11:47 +000081 tzdata-atlantic tzdata-australia tzdata-europe tzdata-pacific \
82"
Brad Bishop19323692019-04-05 15:28:33 -040083PACKAGES = "${TZ_PACKAGES} ${PN}"
84
Andrew Geissler595f6302022-01-24 19:11:47 +000085FILES:tzdata-africa += "${datadir}/zoneinfo/Africa"
Brad Bishop19323692019-04-05 15:28:33 -040086
Andrew Geissler595f6302022-01-24 19:11:47 +000087FILES:tzdata-americas += " \
88 ${datadir}/zoneinfo/America \
89 ${datadir}/zoneinfo/US \
90 ${datadir}/zoneinfo/Brazil \
91 ${datadir}/zoneinfo/Canada \
92 ${datadir}/zoneinfo/Mexico \
93 ${datadir}/zoneinfo/Chile \
94"
Brad Bishop19323692019-04-05 15:28:33 -040095
Andrew Geissler595f6302022-01-24 19:11:47 +000096FILES:tzdata-antarctica += "${datadir}/zoneinfo/Antarctica"
Brad Bishop19323692019-04-05 15:28:33 -040097
Andrew Geissler595f6302022-01-24 19:11:47 +000098FILES:tzdata-arctic += "${datadir}/zoneinfo/Arctic"
Brad Bishop19323692019-04-05 15:28:33 -040099
Andrew Geissler595f6302022-01-24 19:11:47 +0000100FILES:tzdata-asia += " \
101 ${datadir}/zoneinfo/Asia \
102 ${datadir}/zoneinfo/Indian \
103 ${datadir}/zoneinfo/Mideast \
104"
Brad Bishop19323692019-04-05 15:28:33 -0400105
Andrew Geissler595f6302022-01-24 19:11:47 +0000106FILES:tzdata-atlantic += "${datadir}/zoneinfo/Atlantic"
Brad Bishop19323692019-04-05 15:28:33 -0400107
Andrew Geissler595f6302022-01-24 19:11:47 +0000108FILES:tzdata-australia += "${datadir}/zoneinfo/Australia"
Brad Bishop19323692019-04-05 15:28:33 -0400109
Andrew Geissler595f6302022-01-24 19:11:47 +0000110FILES:tzdata-europe += "${datadir}/zoneinfo/Europe"
Brad Bishop19323692019-04-05 15:28:33 -0400111
Andrew Geissler595f6302022-01-24 19:11:47 +0000112FILES:tzdata-pacific += "${datadir}/zoneinfo/Pacific"
Brad Bishop19323692019-04-05 15:28:33 -0400113
Andrew Geissler595f6302022-01-24 19:11:47 +0000114FILES:tzdata-posix += "${datadir}/zoneinfo/posix"
Brad Bishop19323692019-04-05 15:28:33 -0400115
Andrew Geissler595f6302022-01-24 19:11:47 +0000116FILES:tzdata-right += "${datadir}/zoneinfo/right"
Brad Bishop19323692019-04-05 15:28:33 -0400117
Andrew Geissler595f6302022-01-24 19:11:47 +0000118FILES:tzdata-misc += " \
119 ${datadir}/zoneinfo/Cuba \
120 ${datadir}/zoneinfo/Egypt \
121 ${datadir}/zoneinfo/Eire \
122 ${datadir}/zoneinfo/Factory \
123 ${datadir}/zoneinfo/GB-Eire \
124 ${datadir}/zoneinfo/Hongkong \
125 ${datadir}/zoneinfo/Iceland \
126 ${datadir}/zoneinfo/Iran \
127 ${datadir}/zoneinfo/Israel \
128 ${datadir}/zoneinfo/Jamaica \
129 ${datadir}/zoneinfo/Japan \
130 ${datadir}/zoneinfo/Kwajalein \
131 ${datadir}/zoneinfo/Libya \
132 ${datadir}/zoneinfo/Navajo \
133 ${datadir}/zoneinfo/Poland \
134 ${datadir}/zoneinfo/Portugal \
135 ${datadir}/zoneinfo/Singapore \
136 ${datadir}/zoneinfo/Turkey \
137"
Brad Bishop19323692019-04-05 15:28:33 -0400138
Patrick Williams213cb262021-08-07 19:21:33 -0500139FILES:tzdata-core += " \
Andrew Geissler595f6302022-01-24 19:11:47 +0000140 ${sysconfdir}/localtime \
141 ${sysconfdir}/timezone \
142 ${datadir}/zoneinfo/leapseconds \
143 ${datadir}/zoneinfo/leap-seconds.list \
144 ${datadir}/zoneinfo/Pacific/Honolulu \
145 ${datadir}/zoneinfo/America/Anchorage \
146 ${datadir}/zoneinfo/America/Los_Angeles \
147 ${datadir}/zoneinfo/America/Denver \
148 ${datadir}/zoneinfo/America/Chicago \
149 ${datadir}/zoneinfo/America/New_York \
150 ${datadir}/zoneinfo/America/Caracas \
151 ${datadir}/zoneinfo/America/Sao_Paulo \
152 ${datadir}/zoneinfo/Europe/London \
153 ${datadir}/zoneinfo/Europe/Paris \
154 ${datadir}/zoneinfo/Africa/Cairo \
155 ${datadir}/zoneinfo/Europe/Moscow \
156 ${datadir}/zoneinfo/Asia/Dubai \
157 ${datadir}/zoneinfo/Asia/Karachi \
158 ${datadir}/zoneinfo/Asia/Dhaka \
159 ${datadir}/zoneinfo/Asia/Bangkok \
160 ${datadir}/zoneinfo/Asia/Hong_Kong \
161 ${datadir}/zoneinfo/Asia/Tokyo \
162 ${datadir}/zoneinfo/Australia/Darwin \
163 ${datadir}/zoneinfo/Australia/Adelaide \
164 ${datadir}/zoneinfo/Australia/Brisbane \
165 ${datadir}/zoneinfo/Australia/Sydney \
166 ${datadir}/zoneinfo/Pacific/Noumea \
167 ${datadir}/zoneinfo/CET \
168 ${datadir}/zoneinfo/CST6CDT \
169 ${datadir}/zoneinfo/EET \
170 ${datadir}/zoneinfo/EST \
171 ${datadir}/zoneinfo/EST5EDT \
172 ${datadir}/zoneinfo/GB \
173 ${datadir}/zoneinfo/GMT \
174 ${datadir}/zoneinfo/GMT+0 \
175 ${datadir}/zoneinfo/GMT-0 \
176 ${datadir}/zoneinfo/GMT0 \
177 ${datadir}/zoneinfo/Greenwich \
178 ${datadir}/zoneinfo/HST \
179 ${datadir}/zoneinfo/MET \
180 ${datadir}/zoneinfo/MST \
181 ${datadir}/zoneinfo/MST7MDT \
182 ${datadir}/zoneinfo/NZ \
183 ${datadir}/zoneinfo/NZ-CHAT \
184 ${datadir}/zoneinfo/PRC \
185 ${datadir}/zoneinfo/PST8PDT \
186 ${datadir}/zoneinfo/ROC \
187 ${datadir}/zoneinfo/ROK \
188 ${datadir}/zoneinfo/UCT \
189 ${datadir}/zoneinfo/UTC \
190 ${datadir}/zoneinfo/Universal \
191 ${datadir}/zoneinfo/W-SU \
192 ${datadir}/zoneinfo/WET \
193 ${datadir}/zoneinfo/Zulu \
194 ${datadir}/zoneinfo/zone.tab \
195 ${datadir}/zoneinfo/zone1970.tab \
196 ${datadir}/zoneinfo/iso3166.tab \
197 ${datadir}/zoneinfo/Etc \
198"
Brad Bishop19323692019-04-05 15:28:33 -0400199
Patrick Williams213cb262021-08-07 19:21:33 -0500200CONFFILES:tzdata-core = "${sysconfdir}/localtime ${sysconfdir}/timezone"
Brad Bishop19323692019-04-05 15:28:33 -0400201
Patrick Williams213cb262021-08-07 19:21:33 -0500202ALLOW_EMPTY:${PN} = "1"
Andrew Geissler595f6302022-01-24 19:11:47 +0000203
Patrick Williams213cb262021-08-07 19:21:33 -0500204RDEPENDS:${PN} = "${TZ_PACKAGES}"