blob: c2b019922a494eab16adf20d8afc1220500a59e3 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001require timezone.inc
2
3DEPENDS = "tzcode-native"
4
5inherit allarch
6
Patrick Williams213cb262021-08-07 19:21:33 -05007RCONFLICTS:${PN} = "timezones timezone-africa timezone-america timezone-antarctica \
Brad Bishop19323692019-04-05 15:28:33 -04008 timezone-arctic timezone-asia timezone-atlantic \
9 timezone-australia timezone-europe timezone-indian \
10 timezone-iso3166.tab timezone-pacific timezone-zone.tab"
11
12S = "${WORKDIR}"
13
14DEFAULT_TIMEZONE ?= "Universal"
15INSTALL_TIMEZONE_FILE ?= "1"
16
17TZONES= "africa antarctica asia australasia europe northamerica southamerica \
Andrew Geisslerf0343792020-11-18 10:42:21 -060018 factory etcetera backward \
Brad Bishop19323692019-04-05 15:28:33 -040019 "
20# pacificnew
21
Andrew Geissler5f350902021-07-23 13:09:54 -040022# "slim" is the default since 2020b
23# "fat" is needed by e.g. MariaDB's mysql_tzinfo_to_sql
24ZIC_FMT ?= "slim"
25
Brad Bishop19323692019-04-05 15:28:33 -040026do_compile () {
27 for zone in ${TZONES}; do \
Andrew Geissler5f350902021-07-23 13:09:54 -040028 ${STAGING_BINDIR_NATIVE}/zic -b ${ZIC_FMT} -d ${WORKDIR}${datadir}/zoneinfo -L /dev/null \
Andrew Geisslerf0343792020-11-18 10:42:21 -060029 ${S}/${zone} ; \
Andrew Geissler5f350902021-07-23 13:09:54 -040030 ${STAGING_BINDIR_NATIVE}/zic -b ${ZIC_FMT} -d ${WORKDIR}${datadir}/zoneinfo/posix -L /dev/null \
Andrew Geisslerf0343792020-11-18 10:42:21 -060031 ${S}/${zone} ; \
Andrew Geissler5f350902021-07-23 13:09:54 -040032 ${STAGING_BINDIR_NATIVE}/zic -b ${ZIC_FMT} -d ${WORKDIR}${datadir}/zoneinfo/right -L ${S}/leapseconds \
Andrew Geisslerf0343792020-11-18 10:42:21 -060033 ${S}/${zone} ; \
Brad Bishop19323692019-04-05 15:28:33 -040034 done
35}
36
37do_install () {
38 install -d ${D}/$exec_prefix ${D}${datadir}/zoneinfo
39 cp -pPR ${S}/$exec_prefix ${D}/
40 # libc is removing zoneinfo files from package
41 cp -pP "${S}/zone.tab" ${D}${datadir}/zoneinfo
42 cp -pP "${S}/zone1970.tab" ${D}${datadir}/zoneinfo
43 cp -pP "${S}/iso3166.tab" ${D}${datadir}/zoneinfo
Andrew Geisslerc9f78652020-09-18 14:11:35 -050044 cp -pP "${S}/leapseconds" ${D}${datadir}/zoneinfo
45 cp -pP "${S}/leap-seconds.list" ${D}${datadir}/zoneinfo
Brad Bishop19323692019-04-05 15:28:33 -040046
47 # Install default timezone
48 if [ -e ${D}${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ]; then
49 install -d ${D}${sysconfdir}
50 if [ "${INSTALL_TIMEZONE_FILE}" = "1" ]; then
51 echo ${DEFAULT_TIMEZONE} > ${D}${sysconfdir}/timezone
52 fi
53 ln -s ${datadir}/zoneinfo/${DEFAULT_TIMEZONE} ${D}${sysconfdir}/localtime
54 else
55 bberror "DEFAULT_TIMEZONE is set to an invalid value."
56 exit 1
57 fi
58
59 chown -R root:root ${D}
60}
61
Patrick Williams213cb262021-08-07 19:21:33 -050062pkg_postinst:${PN} () {
Brad Bishop19323692019-04-05 15:28:33 -040063 etc_lt="$D${sysconfdir}/localtime"
64 src="$D${sysconfdir}/timezone"
65
66 if [ -e ${src} ] ; then
67 tz=$(sed -e 's:#.*::' -e 's:[[:space:]]*::g' -e '/^$/d' "${src}")
68 fi
Andrew Geissler82c905d2020-04-13 13:39:40 -050069
70 if [ ! -z "${tz}" -a ! -e "$D${datadir}/zoneinfo/${tz}" ] ; then
Brad Bishop19323692019-04-05 15:28:33 -040071 echo "You have an invalid TIMEZONE setting in ${src}"
72 echo "Your ${etc_lt} has been reset to Universal; enjoy!"
73 tz="Universal"
74 echo "Updating ${etc_lt} with $D${datadir}/zoneinfo/${tz}"
75 if [ -L ${etc_lt} ] ; then
76 rm -f "${etc_lt}"
77 fi
78 ln -s "${datadir}/zoneinfo/${tz}" "${etc_lt}"
79 fi
80}
81
82# Packages primarily organized by directory with a major city
83# in most time zones in the base package
84
85TZ_PACKAGES = " \
86 tzdata-core tzdata-misc tzdata-posix tzdata-right tzdata-africa \
87 tzdata-americas tzdata-antarctica tzdata-arctic tzdata-asia \
88 tzdata-atlantic tzdata-australia tzdata-europe tzdata-pacific"
89PACKAGES = "${TZ_PACKAGES} ${PN}"
90
Patrick Williams213cb262021-08-07 19:21:33 -050091FILES:tzdata-africa += "${datadir}/zoneinfo/Africa/*"
92RPROVIDES:tzdata-africa = "tzdata-africa"
Brad Bishop19323692019-04-05 15:28:33 -040093
Patrick Williams213cb262021-08-07 19:21:33 -050094FILES:tzdata-americas += "${datadir}/zoneinfo/America/* \
Brad Bishop19323692019-04-05 15:28:33 -040095 ${datadir}/zoneinfo/US/* \
96 ${datadir}/zoneinfo/Brazil/* \
97 ${datadir}/zoneinfo/Canada/* \
98 ${datadir}/zoneinfo/Mexico/* \
99 ${datadir}/zoneinfo/Chile/*"
Patrick Williams213cb262021-08-07 19:21:33 -0500100RPROVIDES:tzdata-americas = "tzdata-americas"
Brad Bishop19323692019-04-05 15:28:33 -0400101
Patrick Williams213cb262021-08-07 19:21:33 -0500102FILES:tzdata-antarctica += "${datadir}/zoneinfo/Antarctica/*"
103RPROVIDES:tzdata-antarctica = "tzdata-antarctica"
Brad Bishop19323692019-04-05 15:28:33 -0400104
Patrick Williams213cb262021-08-07 19:21:33 -0500105FILES:tzdata-arctic += "${datadir}/zoneinfo/Arctic/*"
106RPROVIDES:tzdata-arctic = "tzdata-arctic"
Brad Bishop19323692019-04-05 15:28:33 -0400107
Patrick Williams213cb262021-08-07 19:21:33 -0500108FILES:tzdata-asia += "${datadir}/zoneinfo/Asia/* \
Brad Bishop19323692019-04-05 15:28:33 -0400109 ${datadir}/zoneinfo/Indian/* \
110 ${datadir}/zoneinfo/Mideast/*"
Patrick Williams213cb262021-08-07 19:21:33 -0500111RPROVIDES:tzdata-asia = "tzdata-asia"
Brad Bishop19323692019-04-05 15:28:33 -0400112
Patrick Williams213cb262021-08-07 19:21:33 -0500113FILES:tzdata-atlantic += "${datadir}/zoneinfo/Atlantic/*"
114RPROVIDES:tzdata-atlantic = "tzdata-atlantic"
Brad Bishop19323692019-04-05 15:28:33 -0400115
Patrick Williams213cb262021-08-07 19:21:33 -0500116FILES:tzdata-australia += "${datadir}/zoneinfo/Australia/*"
117RPROVIDES:tzdata-australia = "tzdata-australia"
Brad Bishop19323692019-04-05 15:28:33 -0400118
Patrick Williams213cb262021-08-07 19:21:33 -0500119FILES:tzdata-europe += "${datadir}/zoneinfo/Europe/*"
120RPROVIDES:tzdata-europe = "tzdata-europe"
Brad Bishop19323692019-04-05 15:28:33 -0400121
Patrick Williams213cb262021-08-07 19:21:33 -0500122FILES:tzdata-pacific += "${datadir}/zoneinfo/Pacific/*"
123RPROVIDES:tzdata-pacific = "tzdata-pacific"
Brad Bishop19323692019-04-05 15:28:33 -0400124
Patrick Williams213cb262021-08-07 19:21:33 -0500125FILES:tzdata-posix += "${datadir}/zoneinfo/posix/*"
126RPROVIDES:tzdata-posix = "tzdata-posix"
Brad Bishop19323692019-04-05 15:28:33 -0400127
Patrick Williams213cb262021-08-07 19:21:33 -0500128FILES:tzdata-right += "${datadir}/zoneinfo/right/*"
129RPROVIDES:tzdata-right = "tzdata-right"
Brad Bishop19323692019-04-05 15:28:33 -0400130
Patrick Williams213cb262021-08-07 19:21:33 -0500131FILES:tzdata-misc += "${datadir}/zoneinfo/Cuba \
Brad Bishop19323692019-04-05 15:28:33 -0400132 ${datadir}/zoneinfo/Egypt \
133 ${datadir}/zoneinfo/Eire \
134 ${datadir}/zoneinfo/Factory \
135 ${datadir}/zoneinfo/GB-Eire \
136 ${datadir}/zoneinfo/Hongkong \
137 ${datadir}/zoneinfo/Iceland \
138 ${datadir}/zoneinfo/Iran \
139 ${datadir}/zoneinfo/Israel \
140 ${datadir}/zoneinfo/Jamaica \
141 ${datadir}/zoneinfo/Japan \
142 ${datadir}/zoneinfo/Kwajalein \
143 ${datadir}/zoneinfo/Libya \
144 ${datadir}/zoneinfo/Navajo \
145 ${datadir}/zoneinfo/Poland \
146 ${datadir}/zoneinfo/Portugal \
147 ${datadir}/zoneinfo/Singapore \
148 ${datadir}/zoneinfo/Turkey"
Patrick Williams213cb262021-08-07 19:21:33 -0500149RPROVIDES:tzdata-misc = "tzdata-misc"
Brad Bishop19323692019-04-05 15:28:33 -0400150
Patrick Williams213cb262021-08-07 19:21:33 -0500151FILES:tzdata-core += " \
Brad Bishopa34c0302019-09-23 22:34:48 -0400152 ${sysconfdir}/localtime \
153 ${sysconfdir}/timezone \
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500154 ${datadir}/zoneinfo/leapseconds \
155 ${datadir}/zoneinfo/leap-seconds.list \
Brad Bishop19323692019-04-05 15:28:33 -0400156 ${datadir}/zoneinfo/Pacific/Honolulu \
157 ${datadir}/zoneinfo/America/Anchorage \
158 ${datadir}/zoneinfo/America/Los_Angeles \
159 ${datadir}/zoneinfo/America/Denver \
160 ${datadir}/zoneinfo/America/Chicago \
161 ${datadir}/zoneinfo/America/New_York \
162 ${datadir}/zoneinfo/America/Caracas \
163 ${datadir}/zoneinfo/America/Sao_Paulo \
164 ${datadir}/zoneinfo/Europe/London \
165 ${datadir}/zoneinfo/Europe/Paris \
166 ${datadir}/zoneinfo/Africa/Cairo \
167 ${datadir}/zoneinfo/Europe/Moscow \
168 ${datadir}/zoneinfo/Asia/Dubai \
169 ${datadir}/zoneinfo/Asia/Karachi \
170 ${datadir}/zoneinfo/Asia/Dhaka \
171 ${datadir}/zoneinfo/Asia/Bangkok \
172 ${datadir}/zoneinfo/Asia/Hong_Kong \
173 ${datadir}/zoneinfo/Asia/Tokyo \
174 ${datadir}/zoneinfo/Australia/Darwin \
175 ${datadir}/zoneinfo/Australia/Adelaide \
176 ${datadir}/zoneinfo/Australia/Brisbane \
177 ${datadir}/zoneinfo/Australia/Sydney \
178 ${datadir}/zoneinfo/Pacific/Noumea \
179 ${datadir}/zoneinfo/CET \
180 ${datadir}/zoneinfo/CST6CDT \
181 ${datadir}/zoneinfo/EET \
182 ${datadir}/zoneinfo/EST \
183 ${datadir}/zoneinfo/EST5EDT \
184 ${datadir}/zoneinfo/GB \
185 ${datadir}/zoneinfo/GMT \
186 ${datadir}/zoneinfo/GMT+0 \
187 ${datadir}/zoneinfo/GMT-0 \
188 ${datadir}/zoneinfo/GMT0 \
189 ${datadir}/zoneinfo/Greenwich \
190 ${datadir}/zoneinfo/HST \
191 ${datadir}/zoneinfo/MET \
192 ${datadir}/zoneinfo/MST \
193 ${datadir}/zoneinfo/MST7MDT \
194 ${datadir}/zoneinfo/NZ \
195 ${datadir}/zoneinfo/NZ-CHAT \
196 ${datadir}/zoneinfo/PRC \
197 ${datadir}/zoneinfo/PST8PDT \
198 ${datadir}/zoneinfo/ROC \
199 ${datadir}/zoneinfo/ROK \
200 ${datadir}/zoneinfo/UCT \
201 ${datadir}/zoneinfo/UTC \
202 ${datadir}/zoneinfo/Universal \
203 ${datadir}/zoneinfo/W-SU \
204 ${datadir}/zoneinfo/WET \
205 ${datadir}/zoneinfo/Zulu \
206 ${datadir}/zoneinfo/zone.tab \
207 ${datadir}/zoneinfo/zone1970.tab \
208 ${datadir}/zoneinfo/iso3166.tab \
209 ${datadir}/zoneinfo/Etc/*"
210
Patrick Williams213cb262021-08-07 19:21:33 -0500211CONFFILES:tzdata-core = "${sysconfdir}/localtime ${sysconfdir}/timezone"
Brad Bishop19323692019-04-05 15:28:33 -0400212
Patrick Williams213cb262021-08-07 19:21:33 -0500213ALLOW_EMPTY:${PN} = "1"
214RDEPENDS:${PN} = "${TZ_PACKAGES}"