recipes: db/tzdb: Ensure copy of the time zone database
[dragora.git] / recipes / db / tzdb / recipe
blob0e907e5fbfa9c498d015beef41c3b204d5577b7f
1 # Build recipe for tzdb.
3 # Copyright (c) 2017-2020 Matias Fonzo, <selk@dragora.org>.
4 # Copyright (c) 2018 Mateus P. Rodrigues, <mprodrigues@dragora.org>.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 #    http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 program=tzdb
19 version=2020a
20 release=2
22 # Define a category for the output of the package name
23 pkgcategory=db
25 tarname=${program}-${version}.tar.lz
27 # Remote source(s)
28 fetch=http://www.iana.org/time-zones/repository/releases/$tarname
30 description="
31 Time zone database.
33 The Time Zone Database (often called tz or zoneinfo) contains code and
34 data that represent the history of local time for many representative
35 locations around the globe.  It is updated periodically to reflect
36 changes made by political bodies to time zone boundaries, UTC offsets,
37 and daylight-saving rules.  Its management procedure is documented in
38 BCP 175: Procedures for Maintaining the Time Zone Database.
41 homepage=http://www.iana.org/time-zones
42 license="Public domain | BSD"
44 # Source documentation
45 docs="CONTRIBUTING LICENSE NEWS README"
46 docsdir="${docdir}/${program}-${version}"
48 # Force parallel jobs to '1'
49 jobs=1
51 build()
53     set -e
55     unpack "${tardir}/$tarname"
57     cd "$srcdir"
59     # Set sane permissions
60     chmod -R u+w,go-w,a+rX-s .
62     make -j${jobs} CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS -static" \
63      TOPDIR=/ \
64      TZDIR=/etc/zoneinfo \
65      ETCDIR=/usr/sbin \
66      LIBDIR=/usr/lib${libSuffix} \
67      MANDIR=$mandir \
68      KSHELL="/bin/sh -" \
69      DESTDIR="$destdir" install
71     # 1. We do not offer 'tzselect'.
72     # 2. To set default localtime.
73     # 3. To be linked via post-install.
74     rm -f \
75      "${destdir}/usr/bin/tzselect" \
76      "${destdir}/etc/localtime" \
77      "${destdir}/etc/zoneinfo-posix"
79     # Create .nograft to copy via post-installation the time zone files
80     # instead of being linked to the package directory; this is to ensure
81     # that the database is always up to date after a package update.  :-)
83     find "${destdir}"/etc/zoneinfo* -type d -print | \
84      while read -r directory
85      do
86          ( cd -- "$directory" && touch .nograft )
87      done
89     # Compress and link man pages (if needed)
90     if test -d "${destdir}/$mandir"
91     then
92         (
93             cd "${destdir}/$mandir"
94             find . -type f -exec lzip -9 '{}' +
95             find . -type l | while read -r file
96             do
97                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
98                 rm -- "$file"
99             done
100         )
101     fi
103     # Copy documentation
104     mkdir -p "${destdir}${docsdir}"
105     cp -p $docs "${destdir}${docsdir}/"