aboutsummaryrefslogtreecommitdiff
path: root/misc/zoneinfo/Makefile
diff options
context:
space:
mode:
authorThomas Munro <tmunro@FreeBSD.org>2019-08-19 03:09:03 +0000
committerThomas Munro <tmunro@FreeBSD.org>2019-08-19 03:09:03 +0000
commit5df160dbe4992751c03d81359418ae2774e98bc2 (patch)
tree563ac0b25c2e63b4d0e69f345ad8b27e4dc78ec5 /misc/zoneinfo/Makefile
parent2c83d4be638c0f9b98c92c4542aeb85146730de6 (diff)
downloadports-5df160dbe4992751c03d81359418ae2774e98bc2.tar.gz
ports-5df160dbe4992751c03d81359418ae2774e98bc2.zip
misc/zoneinfo: install zone1970.tab and other fixes
Install zone1970.tab in addition to zone.tab (like D20646 for base). The old logic to remove countries from zone.tab doesn't port to zone1970.tab since some lines might have to be patched more than once. Replace it with some awk. Remove LEAPFILE reference that wasn't being set anyway. Fix plist entry for Etc/UCT, which is (since 2019a) part of "backward" and not present otherwise. Make BACKWARD not be the default, since (a) it's not the base system's default and (b) that stuff is all deprecated. Update comment about check-plist to include a reminder to check both with and without BACKWARD (this would have caught the existing plist error). Remove no-longer-needed include of bsd.port.pre.mk. Fix location and name of iso3166 file in comments in zone1970.tab, also to match base system. Add back a test-pkgplist target, because it turns out check-plist is not strict enough to handle the case of moving entries into or out of the "backward" set; check-plist doesn't error if a file is present in STAGEDIR but is commented out in the plist, but we want that to be noticed. Submitted by: Andrew Gierth <andrew@tao11.riddles.org.uk> Reviewed by: philip, skreuzer, tmunro Approved by: skreuzer (maintainer), allanjude (src mentor) Differential Revision: https://reviews.freebsd.org/D20981
Notes
Notes: svn path=/head/; revision=509250
Diffstat (limited to 'misc/zoneinfo/Makefile')
-rw-r--r--misc/zoneinfo/Makefile100
1 files changed, 64 insertions, 36 deletions
diff --git a/misc/zoneinfo/Makefile b/misc/zoneinfo/Makefile
index 6d0ad72a007a..a3fd63751db8 100644
--- a/misc/zoneinfo/Makefile
+++ b/misc/zoneinfo/Makefile
@@ -3,6 +3,7 @@
PORTNAME= zoneinfo
DISTVERSION= 2019b
+PORTREVISION= 1
CATEGORIES= misc
MASTER_SITES= https://data.iana.org/time-zones/releases/ \
ftp://ftp.iana.org/tz/releases/
@@ -18,61 +19,88 @@ PREFIX= /usr
NO_ARCH= yes
OPTIONS_DEFINE= BACKWARD
-OPTIONS_DEFAULT= BACKWARD
+OPTIONS_DEFAULT=
OPTIONS_SUB= yes
-BACKWARD_DESC= Include backwards compatible zones
+BACKWARD_DESC= Include backwards compatible zones
+BACKWARD_VARS= tzfiles+=backward
TZFILES= africa antarctica asia australasia etcetera europe \
factory northamerica southamerica systemv
POSIXRULES= America/New_York
-.include <bsd.port.options.mk>
-
-.if ${PORT_OPTIONS:MBACKWARD}
-TZFILES+= backward
-.endif
-
-# Run with "DEVELOPER=1 make check-plist" before commiting!
+# Run both of:
+# "make DEVELOPER=1 WITHOUT=BACKWARD do-clean test-pkgplist"
+# and
+# "make DEVELOPER=1 WITH=BACKWARD do-clean test-pkgplist"
+# before commiting!
# Make sure it breaks when the distfile isn't there anymore.
.if !defined(PACKAGE_BUILDING)
MASTER_SITES+= http://people.freebsd.org/~edwin/
.endif
-.include <bsd.port.pre.mk>
-
-# The following country codes can be missing from /usr/share/misc/iso3166 and
-# shouldn't appear in the zoneinfo file.
-MISSING= ax bl bq cw gg im je me mf rs ss sx
-
-.ifndef NOMISSING
-.for M in ${MISSING}
-HAS_${M:tu}!= ${GREP} -c ^${M:tu} /usr/share/misc/iso3166 || ${TRUE}
-.if ${HAS_${M:tu}} == "0"
-EXTRA_PATCHES+= ${FILESDIR}/patchremove-${M}
-.endif
-.endfor
-.endif
+# tzsetup objects (fatally) if any entry in zone.tab or zone1970.tab
+# refers to a country code that doesn't exist in misc/iso3166. While
+# arguably that should be fixed, for compatibility we remove such
+# entries here to avoid the problem.
+#
+# This used to be done by adding patch files for each country to
+# remove, but that doesn't work for zone1970.tab.
+#
+# We generate a list of all 2-letter codes that are NOT in iso3166;
+# then, for any entry in zone.tab or zone1970.tab that contains a bad
+# code: first emit a commented-out version of the line, then a version
+# with the bad codes stripped out of the first field (unless this
+# leaves the first field empty).
+
+post-patch:
+ cd ${WRKSRC}; \
+ badc=$$(${AWK} '/^[^\#]/ { t[$$1]=1; }; \
+ END { for (i=0; i<676; ++i) { \
+ c = sprintf("%c%c", 65+int(i/26), 65+(i%26)); \
+ if (!(c in t)) print c; \
+ } \
+ }' \
+ /usr/share/misc/iso3166 | \
+ ${SED} -n -e '1h; 1!H; $${g;s/\n/|/g;p;}'); \
+ for fn in zone.tab zone1970.tab; do \
+ ${MV} $${fn} $${fn}.bak; \
+ ${AWK} -v FS="\t" -v OFS="\t" -v re="(^|,)($${badc})" \
+ '/^[^#]/ && $$1 ~ re { \
+ print "#" $$0; \
+ gsub(re,"",$$1); \
+ sub(/^,/,"",$$1); \
+ }; \
+ $$1 != "" { print; }' <$${fn}.bak >$${fn}; \
+ done
do-build:
umask 022; \
cd ${WRKSRC}; \
zic -d ${WRKSRC}/zoneinfo -p ${POSIXRULES} -m ${NOBINMODE} \
- ${LEAPFILE} -y ${.OBJDIR}/yearistype ${TZFILES}
+ -y ${.OBJDIR}/yearistype ${TZFILES}
do-install:
${MKDIR} ${STAGEDIR}${PREFIX}/share/zoneinfo
- ${CP} -R -p ${WRKSRC}/zoneinfo/ ${STAGEDIR}${PREFIX}/share/zoneinfo
+ (cd ${WRKSRC}/zoneinfo && ${COPYTREE_SHARE} . ${STAGEDIR}${PREFIX}/share/zoneinfo)
${INSTALL_DATA} ${WRKSRC}/zone.tab ${STAGEDIR}${PREFIX}/share/zoneinfo
-
-test-patches:
-.for M in ${MISSING}
- make clean
- NOMISSING=1 EXTRA_PATCHES=${FILESDIR}/patchremove-${M} make patch
-.endfor
-
-test-pkgplist:
- for f in $$(find work/stage/usr/share/zoneinfo/ | sed -e 's,work/stage/usr/share/zoneinfo/,,' ); do if [ $$(grep -c $$f pkg-plist) -eq 0 ]; then echo $$f; fi ; done
-
-.include <bsd.port.post.mk>
+ ${INSTALL_DATA} ${WRKSRC}/zone1970.tab ${STAGEDIR}${PREFIX}/share/zoneinfo
+
+# check-plist is too lenient for us; it doesn't care if there are
+# files in the stage dir that are commented out in plist due to port
+# options. But we need to check for an exact match, otherwise the
+# final package may be incorrect if entries move into or out of the
+# "backward" file.
+#
+# So this rule makes the additional check that there must be no file in
+# STAGEDIR not accounted for by .plist-files-no-comments.
+
+test-pkgplist: check-plist
+ @(cd ${STAGEDIR} && ${FIND} . -type f -print) | \
+ ${SED} -e 's:^[.]::' | sort | \
+ ${COMM} -23 -- - ${WRKDIR}/.plist-files-no-comments | \
+ while read -r f; do echo "MISSING FROM PLIST: $$f" >&2; echo fail; done | \
+ ! ${GREP} fail >/dev/null
+
+.include <bsd.port.mk>