From a63c7565928034e48995cf466f7de8c71da3871e Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 5 Aug 2017 16:55:07 +0000 Subject: [PATCH] MFC r320702,r320703: r320702: Formalize LEAPSECONDS and OLDTIMEZONES in share/zoneinfo/... as `MK_ZONEINFO_LEAPSECONDS_SUPPORT == yes` and `MK_ZONEINFO_OLD_TIMEZONES_SUPPORT == yes`. Keep `LEAPSECONDS` and `OLDTIMEZONES` for backwards compatibility, but print out a warning notifying users that they should use the new variables, in an effort to migrate them to the variables. This is being done mostly for automated build tools, etc, that might rely on these variables being set. The variables will be removed in the future on ^/head, e.g., after ^/stable/12 is cut. Relnotes: yes r320703: Add tests to help verify Links functionality for .../contrib/tzdata/backwards MFC with: r320702 git-svn-id: svn://svn.freebsd.org/base/stable/10@322100 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- etc/mtree/BSD.tests.dist | 2 + share/mk/bsd.own.mk | 10 +++- share/zoneinfo/Makefile | 20 ++++++- share/zoneinfo/tests/Makefile | 18 +++++++ share/zoneinfo/tests/backward_test.sh | 44 +++++++++++++++ share/zoneinfo/tests/zoneinfo_common.sh | 54 +++++++++++++++++++ .../options/WITH_ZONEINFO_LEAPSECONDS_SUPPORT | 2 + .../WITH_ZONEINFO_OLD_TIMEZONES_SUPPORT | 3 ++ 8 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 share/zoneinfo/tests/Makefile create mode 100755 share/zoneinfo/tests/backward_test.sh create mode 100755 share/zoneinfo/tests/zoneinfo_common.sh create mode 100644 tools/build/options/WITH_ZONEINFO_LEAPSECONDS_SUPPORT create mode 100644 tools/build/options/WITH_ZONEINFO_OLD_TIMEZONES_SUPPORT diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 683322f5d..3a4e605a7 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -374,6 +374,8 @@ .. .. .. + zoneinfo + .. .. sys acl diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 1d7152a31..f501f8d38 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -411,7 +411,10 @@ __DEFAULT_NO_OPTIONS = \ SHARED_TOOLCHAIN \ SVN \ TESTS \ - USB_GADGET_EXAMPLES + USB_GADGET_EXAMPLES \ + ZONEINFO_LEAPSECONDS_SUPPORT \ + ZONEINFO_OLD_TIMEZONES_SUPPORT \ + # # Default behaviour of some options depends on the architecture. Unfortunately @@ -586,6 +589,11 @@ MK_GCC:= no MK_GDB:= no .endif +.if ${MK_ZONEINFO} == "no" +MK_ZONEINFO_LEAPSECONDS_SUPPORT:= no +MK_ZONEINFO_OLD_TIMEZONES_SUPPORT:= no +.endif + .if ${MK_CLANG} == "no" MK_CLANG_EXTRAS:= no MK_CLANG_FULL:= no diff --git a/share/zoneinfo/Makefile b/share/zoneinfo/Makefile index a3c81b949..75b1cca87 100644 --- a/share/zoneinfo/Makefile +++ b/share/zoneinfo/Makefile @@ -28,12 +28,24 @@ # $ svn update # Commit message: "MFV of tzdata2008X" # +.include + CLEANFILES+= yearistype CLEANDIRS+= builddir CONTRIBDIR= ${.CURDIR}/../../contrib/tzdata/ .PATH: ${CONTRIBDIR} .if defined(LEAPSECONDS) +.warning "Using backwards compatibility variable for LEAPSECONDS; please use WITH_ZONEINFO_LEAPSECONDS_SUPPORT instead" +MK_ZONEINFO_LEAPSECONDS_SUPPORT= yes +.endif + +.if defined(OLDTIMEZONES) +.warning "Using backwards compatibility variable for OLDTIMEZONES; please use WITH_ZONEINFO_OLD_TIMEZONES_SUPPORT instead" +MK_ZONEINFO_OLD_TIMEZONES_SUPPORT= yes +.endif + +.if ${MK_ZONEINFO_LEAPSECONDS_SUPPORT} != "no" LEAPFILE= -L ${CONTRIBDIR}leapseconds .else LEAPFILE= @@ -43,7 +55,7 @@ TZFILES= africa antarctica asia australasia etcetera europe \ factory northamerica southamerica POSIXRULES= America/New_York -.if defined(OLDTIMEZONES) +.if ${MK_ZONEINFO_OLD_TIMEZONES_SUPPORT} != "no" TZFILES+= backward systemv .endif @@ -67,7 +79,7 @@ TZBUILDSUBDIRS= \ Pacific \ SystemV -.if defined(OLDTIMEZONES) +.if ${MK_ZONEINFO_OLD_TIMEZONES_SUPPORT} != "no" TZBUILDSUBDIRS+= US Mexico Chile Canada Brazil .endif @@ -111,4 +123,8 @@ afterinstall: echo "Run tzsetup(8) manually to update /etc/localtime."; \ fi +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include diff --git a/share/zoneinfo/tests/Makefile b/share/zoneinfo/tests/Makefile new file mode 100644 index 000000000..2e65d685d --- /dev/null +++ b/share/zoneinfo/tests/Makefile @@ -0,0 +1,18 @@ +# $FreeBSD$ + +.include + +.PATH: ${SRCTOP}/contrib/tzdata + +FILESGROUPS= FILES +FILESGROUPS+= TESTFILES + +.if ${MK_ZONEINFO_OLD_TIMEZONES_SUPPORT} != "no" +ATF_TESTS_SH+= backward_test +TESTFILES+= backward +.endif + +TESTFILES+= zoneinfo_common.sh +TESTFILESDIR= ${TESTSDIR} + +.include diff --git a/share/zoneinfo/tests/backward_test.sh b/share/zoneinfo/tests/backward_test.sh new file mode 100755 index 000000000..41d2df929 --- /dev/null +++ b/share/zoneinfo/tests/backward_test.sh @@ -0,0 +1,44 @@ +# +# Copyright (c) 2017 Ngie Cooper +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ + +atf_test_case links +links_head() +{ + atf_set "descr" "Verify Links directives in contrib/tzdata/backward" +} + +links_body() +{ + verify_Links $(atf_get_srcdir)/backward +} + +atf_init_test_cases() +{ + . "$(dirname "$0")/zoneinfo_common.sh" + + atf_add_test_case links +} diff --git a/share/zoneinfo/tests/zoneinfo_common.sh b/share/zoneinfo/tests/zoneinfo_common.sh new file mode 100755 index 000000000..0a00a39cf --- /dev/null +++ b/share/zoneinfo/tests/zoneinfo_common.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# +# Copyright (c) 2017 Ngie Cooper +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ + +ZONEINFO_DIR=/usr/share/zoneinfo + +verify_Links() +{ + local zoneinfo_file + + zoneinfo_file=$1 + + awk '$1 == "Link" && NF == 3 { print $2, $3; }' < $zoneinfo_file | \ + while read src dest; do + verify_Link $src $dest + done +} + +verify_Link() +{ + local src dest + + old_path=$ZONEINFO_DIR/$src + new_path=$ZONEINFO_DIR/$dest + + atf_check test -f $new_path + atf_check test -f $old_path + + atf_check cmp $old_path $new_path +} diff --git a/tools/build/options/WITH_ZONEINFO_LEAPSECONDS_SUPPORT b/tools/build/options/WITH_ZONEINFO_LEAPSECONDS_SUPPORT new file mode 100644 index 000000000..535f60365 --- /dev/null +++ b/tools/build/options/WITH_ZONEINFO_LEAPSECONDS_SUPPORT @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to build leapsecond information in to the timezone database. diff --git a/tools/build/options/WITH_ZONEINFO_OLD_TIMEZONES_SUPPORT b/tools/build/options/WITH_ZONEINFO_OLD_TIMEZONES_SUPPORT new file mode 100644 index 000000000..664b03288 --- /dev/null +++ b/tools/build/options/WITH_ZONEINFO_OLD_TIMEZONES_SUPPORT @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Set to build backward compatibility timezone aliases in to the timezone +database. -- 2.45.0