blob: 09145e1ed0d81969ee8922a2d0128186b11dc6c5 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001require timezone.inc
2
3DEPENDS = "tzcode-native"
4
5inherit allarch
6
7RCONFLICTS_${PN} = "timezones timezone-africa timezone-america timezone-antarctica \
8 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
62pkg_postinst_${PN} () {
63 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
91FILES_tzdata-africa += "${datadir}/zoneinfo/Africa/*"
92RPROVIDES_tzdata-africa = "tzdata-africa"
93
94FILES_tzdata-americas += "${datadir}/zoneinfo/America/* \
95 ${datadir}/zoneinfo/US/* \
96 ${datadir}/zoneinfo/Brazil/* \
97 ${datadir}/zoneinfo/Canada/* \
98 ${datadir}/zoneinfo/Mexico/* \
99 ${datadir}/zoneinfo/Chile/*"
100RPROVIDES_tzdata-americas = "tzdata-americas"
101
102FILES_tzdata-antarctica += "${datadir}/zoneinfo/Antarctica/*"
103RPROVIDES_tzdata-antarctica = "tzdata-antarctica"
104
105FILES_tzdata-arctic += "${datadir}/zoneinfo/Arctic/*"
106RPROVIDES_tzdata-arctic = "tzdata-arctic"
107
108FILES_tzdata-asia += "${datadir}/zoneinfo/Asia/* \
109 ${datadir}/zoneinfo/Indian/* \
110 ${datadir}/zoneinfo/Mideast/*"
111RPROVIDES_tzdata-asia = "tzdata-asia"
112
113FILES_tzdata-atlantic += "${datadir}/zoneinfo/Atlantic/*"
114RPROVIDES_tzdata-atlantic = "tzdata-atlantic"
115
116FILES_tzdata-australia += "${datadir}/zoneinfo/Australia/*"
117RPROVIDES_tzdata-australia = "tzdata-australia"
118
119FILES_tzdata-europe += "${datadir}/zoneinfo/Europe/*"
120RPROVIDES_tzdata-europe = "tzdata-europe"
121
122FILES_tzdata-pacific += "${datadir}/zoneinfo/Pacific/*"
123RPROVIDES_tzdata-pacific = "tzdata-pacific"
124
125FILES_tzdata-posix += "${datadir}/zoneinfo/posix/*"
126RPROVIDES_tzdata-posix = "tzdata-posix"
127
128FILES_tzdata-right += "${datadir}/zoneinfo/right/*"
129RPROVIDES_tzdata-right = "tzdata-right"
130
131FILES_tzdata-misc += "${datadir}/zoneinfo/Cuba \
132 ${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"
149RPROVIDES_tzdata-misc = "tzdata-misc"
150
151FILES_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
Brad Bishopa34c0302019-09-23 22:34:48 -0400211CONFFILES_tzdata-core = "${sysconfdir}/localtime ${sysconfdir}/timezone"
Brad Bishop19323692019-04-05 15:28:33 -0400212
213ALLOW_EMPTY_${PN} = "1"
214RDEPENDS_${PN} = "${TZ_PACKAGES}"