xref: /titanic_50/usr/src/tools/scripts/checkpaths.sh (revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0)
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 2007 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27#ident	"%Z%%M%	%I%	%E% SMI"
28
29# Quis custodiet ipsos custodies?
30
31if [ -z "$SRC" ]; then
32	SRC=$CODEMGR_WS/usr/src
33fi
34
35if [ -z "$CODEMGR_WS" -o ! -d "$CODEMGR_WS" -o ! -d "$SRC" ]; then
36	echo "$0: must be run from within a workspace."
37	exit 1
38fi
39
40cd $CODEMGR_WS || exit 1
41
42# Use -b to tell this script to ignore derived (built) objects.
43if [ "$1" = "-b" ]; then
44	b_flg=y
45fi
46
47# Not currently used; available for temporary workarounds.
48args="-k NEVER_CHECK"
49
50# We intentionally don't depend on $MACH here, and thus no $ROOT.  If
51# a proto area exists, then we use it.  This allows this script to be
52# run against gates (which should contain both SPARC and x86 proto
53# areas), build workspaces (which should contain just one proto area),
54# and unbuilt workspaces (which contain no proto areas).
55if [ "$b_flg" = y ]; then
56	rootlist=
57elif [ $# -gt 0 ]; then
58	rootlist=$*
59else
60	rootlist="$CODEMGR_WS/proto/root_sparc $CODEMGR_WS/proto/root_i386"
61fi
62
63# If the closed source is not present, then exclude IKE from validation.
64if [ "$CLOSED_IS_PRESENT" = no ]; then
65	excl="-e ^usr/include/ike/"
66fi
67
68for ROOT in $rootlist
69do
70	case "$ROOT" in
71	*sparc|*sparc-nd)
72		arch=sparc
73		;;
74	*i386|*i386-nd)
75		arch=i386
76		;;
77	*)
78		echo "$ROOT has unknown architecture." >&2
79		exit 1
80		;;
81	esac
82	if [ -d $ROOT ]; then
83		validate_paths '-s/\s*'$arch'$//' -e '^opt/onbld' $excl \
84		    -b $ROOT $args $SRC/pkgdefs/etc/exception_list_$arch
85	fi
86done
87
88# Two entries in the findunref exception_list deal with things created
89# by nightly.  Otherwise, this test could be run on an unmodifed (and
90# unbuilt) workspace.  We handle this by flagging the one that is
91# present only on a built workspace (./*.out) and the one that's
92# present only after a run of findunref (./*.ref) with ISUSED, and
93# disabling all checks of them.  The assumption is that the entries
94# marked with ISUSED are always known to be good, thus the Latin quote
95# at the top of the file.
96if [ -r $SRC/tools/findunref/exception_list ]; then
97	# If the closed source is not present, then don't validate it.
98	if [ "$CLOSED_IS_PRESENT" = no ]; then
99		excl="-e ^\./closed"
100	fi
101	validate_paths -k ISUSED -r -e '^\*' $excl -b $SRC/.. \
102		$SRC/tools/findunref/exception_list
103fi
104
105# These are straightforward.
106if [ -d $SRC/xmod ]; then
107	# If the closed source is not present, then don't validate it.
108	if [ "$CLOSED_IS_PRESENT" = no ]; then
109		excl_cry="-e ^usr/closed"
110		excl_xmod="-e ^../closed"
111	fi
112	validate_paths $excl_cry $SRC/xmod/cry_files
113	validate_paths $excl_xmod -b $SRC $SRC/xmod/xmod_files
114fi
115
116# Finally, make sure the that (req|inc).flg files are in good shape.
117# If SCCS files are not expected to be present, though, then don't
118# check them.
119if [ ! -d "$CODEMGR_WS/Codemgr_wsdata" ]; then
120	f_flg='-f'
121fi
122# If the closed source is not present, then don't validate it.
123if [ "$CLOSED_IS_PRESENT" = no ]; then
124	excl="-e ^usr/closed/"
125fi
126
127validate_flg $f_flg $excl
128
129exit 0
130