1*63878f74SAndy Fiddaman#!/bin/ksh 2*63878f74SAndy Fiddaman# 3*63878f74SAndy Fiddaman# This file and its contents are supplied under the terms of the 4*63878f74SAndy Fiddaman# Common Development and Distribution License ("CDDL"), version 1.0. 5*63878f74SAndy Fiddaman# You may only use this file in accordance with the terms of version 6*63878f74SAndy Fiddaman# 1.0 of the CDDL. 7*63878f74SAndy Fiddaman# 8*63878f74SAndy Fiddaman# A full copy of the text of the CDDL should have accompanied this 9*63878f74SAndy Fiddaman# source. A copy of the CDDL is also available via the Internet at 10*63878f74SAndy Fiddaman# http://www.illumos.org/license/CDDL. 11*63878f74SAndy Fiddaman 12*63878f74SAndy Fiddaman# Copyright 2020 OmniOS Community Edition (OmniOSce) Association. 13*63878f74SAndy Fiddaman 14*63878f74SAndy Fiddamanf=zone_sun.tab 15*63878f74SAndy Fiddamanproto=$ROOT/usr/share/lib/zoneinfo 16*63878f74SAndy Fiddaman 17*63878f74SAndy Fiddamanif [[ ! -f "$f" ]]; then 18*63878f74SAndy Fiddaman echo "Run from inside usr/src/data/zoneinfo" 19*63878f74SAndy Fiddaman exit 1 20*63878f74SAndy Fiddamanfi 21*63878f74SAndy Fiddaman 22*63878f74SAndy Fiddamanif [[ ! -d "$proto" ]]; then 23*63878f74SAndy Fiddaman echo "No zoneinfo in $proto - run 'dmake install'" 24*63878f74SAndy Fiddaman exit 1 25*63878f74SAndy Fiddamanfi 26*63878f74SAndy Fiddaman 27*63878f74SAndy Fiddaman# First check that all of the referenced zone files exist in the proto 28*63878f74SAndy Fiddaman# area. 29*63878f74SAndy Fiddaman 30*63878f74SAndy Fiddamannawk -F'\t' ' 31*63878f74SAndy Fiddaman /^#/ { next } 32*63878f74SAndy Fiddaman { 33*63878f74SAndy Fiddaman print $3 34*63878f74SAndy Fiddaman if ($4 != "-") 35*63878f74SAndy Fiddaman print $4 36*63878f74SAndy Fiddaman } 37*63878f74SAndy Fiddaman' $f | while read zone; do 38*63878f74SAndy Fiddaman if [ ! -f $proto/$zone ]; then 39*63878f74SAndy Fiddaman echo "Missing: $zone" 40*63878f74SAndy Fiddaman fi 41*63878f74SAndy Fiddamandone 42*63878f74SAndy Fiddaman 43*63878f74SAndy Fiddaman# Check that lines have between 3 and 5 fields 44*63878f74SAndy Fiddaman 45*63878f74SAndy Fiddamannawk -F'\t' ' 46*63878f74SAndy Fiddaman /^#/ { next } 47*63878f74SAndy Fiddaman NF < 3 || NF > 5 { print NF, $0 } 48*63878f74SAndy Fiddaman' $f | while read line; do 49*63878f74SAndy Fiddaman echo "Fields: $line" 50*63878f74SAndy Fiddamandone 51*63878f74SAndy Fiddaman 52*63878f74SAndy Fiddaman# Check that field 5 does not point to a zone file. This could indicate a 53*63878f74SAndy Fiddaman# field in the wrong position. 54*63878f74SAndy Fiddaman 55*63878f74SAndy Fiddamannawk -F'\t' ' 56*63878f74SAndy Fiddaman /^#/ { next } 57*63878f74SAndy Fiddaman NF > 4 { print $5 } 58*63878f74SAndy Fiddaman' $f | while read zone; do 59*63878f74SAndy Fiddaman if [ -f "$proto/$zone" ]; then 60*63878f74SAndy Fiddaman echo "Check: $zone" 61*63878f74SAndy Fiddaman fi 62*63878f74SAndy Fiddamandone 63*63878f74SAndy Fiddaman 64*63878f74SAndy Fiddaman# Check that the file is properly sorted 65*63878f74SAndy Fiddaman 66*63878f74SAndy Fiddamanof=`mktemp` 67*63878f74SAndy Fiddamannf=`mktemp` 68*63878f74SAndy Fiddamannawk '/^#/ { next } { print $1 }' $f > $of 69*63878f74SAndy Fiddamansort < $of > $nf 70*63878f74SAndy Fiddamancmp -s $of $nf || echo "Bad sorting" 71*63878f74SAndy Fiddamanrm -f $of $nf 72*63878f74SAndy Fiddaman 73