1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27# ident	"%Z%%M%	%I%	%E% SMI"
28#
29
30# Quis custodiet ipsos custodies?
31
32if [ -z "$SRC" ]; then
33	SRC=$CODEMGR_WS/usr/src
34fi
35
36if [ -z "$CODEMGR_WS" -o ! -d "$CODEMGR_WS" -o ! -d "$SRC" ]; then
37	echo "$0: must be run from within a workspace."
38	exit 1
39fi
40
41cd $CODEMGR_WS || exit 1
42
43# Use -b to tell this script to ignore derived (built) objects.
44if [ "$1" = "-b" ]; then
45	b_flg=y
46fi
47
48# Not currently used; available for temporary workarounds.
49args="-k NEVER_CHECK"
50
51# We intentionally don't depend on $MACH here, and thus no $ROOT.  If
52# a proto area exists, then we use it.  This allows this script to be
53# run against gates (which should contain both SPARC and x86 proto
54# areas), build workspaces (which should contain just one proto area),
55# and unbuilt workspaces (which contain no proto areas).
56if [ "$b_flg" = y ]; then
57	rootlist=
58elif [ $# -gt 0 ]; then
59	rootlist=$*
60else
61	rootlist="$CODEMGR_WS/proto/root_sparc $CODEMGR_WS/proto/root_i386"
62fi
63
64# If the closed source is not present, then exclude IKE from validation.
65if [ "$CLOSED_IS_PRESENT" = no ]; then
66	excl="-e ^usr/include/ike/"
67fi
68
69for ROOT in $rootlist
70do
71	case "$ROOT" in
72	*sparc|*sparc-nd)
73		arch=sparc
74		;;
75	*i386|*i386-nd)
76		arch=i386
77		;;
78	*)
79		echo "$ROOT has unknown architecture." >&2
80		exit 1
81		;;
82	esac
83	if [ -d $ROOT ]; then
84		validate_paths '-s/\s*'$arch'$//' -e '^opt/onbld' $excl \
85		    -b $ROOT $args $SRC/pkgdefs/etc/exception_list_$arch
86	fi
87done
88
89# Two entries in the findunref exception_list deal with things created
90# by nightly.  Otherwise, this test could be run on an unmodifed (and
91# unbuilt) workspace.  We handle this by flagging the one that is
92# present only on a built workspace (./*.out) and the one that's
93# present only after a run of findunref (./*.ref) with ISUSED, and
94# disabling all checks of them.  The assumption is that the entries
95# marked with ISUSED are always known to be good, thus the Latin quote
96# at the top of the file.
97#
98# The exception_list is generated from whichever input files are appropriate
99# for this workspace, so checking it obviates the need to check the inputs.
100elist=""
101if [ -r $SRC/tools/findunref/exception_list ]; then
102	validate_paths -k ISUSED -r -e '^\*' -b $SRC/.. \
103		$SRC/tools/findunref/exception_list
104fi
105
106# These are straightforward.
107if [ -d $SRC/xmod ]; then
108	# If the closed source is not present, then don't validate it.
109	if [ "$CLOSED_IS_PRESENT" = no ]; then
110		excl_cry="-e ^usr/closed"
111		excl_xmod="-e ^../closed"
112	fi
113	validate_paths $excl_cry $SRC/xmod/cry_files
114	validate_paths $excl_xmod -b $SRC $SRC/xmod/xmod_files
115fi
116
117if [ -f $SRC/tools/opensolaris/license-list ]; then
118	excl=
119	if [ "$CLOSED_IS_PRESENT" = no ]; then
120		excl="-e ^usr/closed"
121	fi
122	sed -e 's/$/.descrip/' < $SRC/tools/opensolaris/license-list | \
123		validate_paths $excl
124fi
125
126# Finally, make sure the that (req|inc).flg files are in good shape.
127# If SCCS files are not expected to be present, though, then don't
128# check them.
129if [ ! -d "$CODEMGR_WS/Codemgr_wsdata" ]; then
130	f_flg='-f'
131fi
132# If the closed source is not present, then don't validate it.
133if [ "$CLOSED_IS_PRESENT" = no ]; then
134	excl="-e ^usr/closed/"
135fi
136
137validate_flg $f_flg $excl
138
139exit 0
140