10Sstevel@tonic-gate#!/bin/ksh -p
20Sstevel@tonic-gate#
30Sstevel@tonic-gate# CDDL HEADER START
40Sstevel@tonic-gate#
50Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*900Skupfer# Common Development and Distribution License (the "License").
7*900Skupfer# You may not use this file except in compliance with the License.
80Sstevel@tonic-gate#
90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate# See the License for the specific language governing permissions
120Sstevel@tonic-gate# and limitations under the License.
130Sstevel@tonic-gate#
140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate#
200Sstevel@tonic-gate# CDDL HEADER END
210Sstevel@tonic-gate#
220Sstevel@tonic-gate#
230Sstevel@tonic-gate# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate# Use is subject to license terms.
250Sstevel@tonic-gate#
260Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate
280Sstevel@tonic-gate# Quis custodiet ipsos custodies?
290Sstevel@tonic-gate
300Sstevel@tonic-gateif [ -z "$SRC" ]; then
310Sstevel@tonic-gate	SRC=$CODEMGR_WS/usr/src
320Sstevel@tonic-gatefi
330Sstevel@tonic-gate
340Sstevel@tonic-gateif [ -z "$CODEMGR_WS" -o ! -d "$CODEMGR_WS" -o ! -d "$SRC" ]; then
350Sstevel@tonic-gate	echo "$0: must be run from within a workspace."
360Sstevel@tonic-gate	exit 1
370Sstevel@tonic-gatefi
380Sstevel@tonic-gate
390Sstevel@tonic-gatecd $CODEMGR_WS || exit 1
400Sstevel@tonic-gate
410Sstevel@tonic-gate# Use -b to tell this script to ignore derived (built) objects.
420Sstevel@tonic-gateif [ "$1" = "-b" ]; then
430Sstevel@tonic-gate	b_flg=y
440Sstevel@tonic-gatefi
450Sstevel@tonic-gate
460Sstevel@tonic-gate# Not currently used; available for temporary workarounds.
470Sstevel@tonic-gateargs="-k NEVER_CHECK"
480Sstevel@tonic-gate
490Sstevel@tonic-gate# We intentionally don't depend on $MACH here, and thus no $ROOT.  If
500Sstevel@tonic-gate# a proto area exists, then we use it.  This allows this script to be
510Sstevel@tonic-gate# run against gates (which should contain both SPARC and x86 proto
520Sstevel@tonic-gate# areas), build workspaces (which should contain just one proto area),
530Sstevel@tonic-gate# and unbuilt workspaces (which contain no proto areas).
540Sstevel@tonic-gateif [ "$b_flg" = y ]; then
550Sstevel@tonic-gate	rootlist=
560Sstevel@tonic-gateelif [ $# -gt 0 ]; then
570Sstevel@tonic-gate	rootlist=$*
580Sstevel@tonic-gateelse
590Sstevel@tonic-gate	rootlist="$CODEMGR_WS/proto/root_sparc $CODEMGR_WS/proto/root_i386"
600Sstevel@tonic-gatefi
610Sstevel@tonic-gate
620Sstevel@tonic-gatefor ROOT in $rootlist
630Sstevel@tonic-gatedo
640Sstevel@tonic-gate	case "$ROOT" in
650Sstevel@tonic-gate	*sparc)	arch=sparc;;
660Sstevel@tonic-gate	*i386)	arch=i386;;
670Sstevel@tonic-gate	*)
680Sstevel@tonic-gate		echo "$ROOT has unknown architecture." >&2
690Sstevel@tonic-gate		exit 1
700Sstevel@tonic-gate		;;
710Sstevel@tonic-gate	esac
720Sstevel@tonic-gate	if [ -d $ROOT ]; then
730Sstevel@tonic-gate		validate_paths '-s/\s*'$arch'$//' -e '^opt/onbld' -b $ROOT \
740Sstevel@tonic-gate			$args $SRC/pkgdefs/etc/exception_list_$arch
750Sstevel@tonic-gate	fi
760Sstevel@tonic-gatedone
770Sstevel@tonic-gate
780Sstevel@tonic-gate# Two entries in the findunref exception_list deal with things created
790Sstevel@tonic-gate# by nightly.  Otherwise, this test could be run on an unmodifed (and
800Sstevel@tonic-gate# unbuilt) workspace.  We handle this by flagging the one that is
810Sstevel@tonic-gate# present only on a built workspace (./*.out) and the one that's
820Sstevel@tonic-gate# present only after a run of findunref (./*.ref) with ISUSED, and
830Sstevel@tonic-gate# disabling all checks of them.  The assumption is that the entries
840Sstevel@tonic-gate# marked with ISUSED are always known to be good, thus the Latin quote
850Sstevel@tonic-gate# at the top of the file.
860Sstevel@tonic-gateif [ -r $SRC/tools/findunref/exception_list ]; then
87*900Skupfer	validate_paths -k ISUSED -r -e '^\*' -b $SRC/.. \
880Sstevel@tonic-gate		$SRC/tools/findunref/exception_list
890Sstevel@tonic-gatefi
900Sstevel@tonic-gate
910Sstevel@tonic-gate# These are straightforward.
920Sstevel@tonic-gateif [ -d $SRC/xmod ]; then
930Sstevel@tonic-gate	validate_paths $SRC/xmod/cry_files
940Sstevel@tonic-gate	validate_paths -b $SRC $SRC/xmod/xmod_files
950Sstevel@tonic-gatefi
960Sstevel@tonic-gate
970Sstevel@tonic-gate# Finally, make sure the that (req|inc).flg files are in good shape.
980Sstevel@tonic-gatevalidate_flg
990Sstevel@tonic-gate
1000Sstevel@tonic-gateexit 0
101