xref: /onnv-gate/usr/src/tools/scripts/checkpaths.sh (revision 11838:32bb5d254240)
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
6900Skupfer# Common Development and Distribution License (the "License").
7900Skupfer# 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#
224162Skupfer
230Sstevel@tonic-gate#
2410313SPeter.Memishian@Sun.COM# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
250Sstevel@tonic-gate# Use is subject to license terms.
260Sstevel@tonic-gate#
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
622138Scarlsonj# If the closed source is not present, then exclude IKE from validation.
632138Scarlsonjif [ "$CLOSED_IS_PRESENT" = no ]; then
642138Scarlsonj	excl="-e ^usr/include/ike/"
652138Scarlsonjfi
662138Scarlsonj
670Sstevel@tonic-gatefor ROOT in $rootlist
680Sstevel@tonic-gatedo
690Sstevel@tonic-gate	case "$ROOT" in
704162Skupfer	*sparc|*sparc-nd)
714162Skupfer		arch=sparc
724162Skupfer		;;
734162Skupfer	*i386|*i386-nd)
744162Skupfer		arch=i386
754162Skupfer		;;
760Sstevel@tonic-gate	*)
770Sstevel@tonic-gate		echo "$ROOT has unknown architecture." >&2
780Sstevel@tonic-gate		exit 1
790Sstevel@tonic-gate		;;
800Sstevel@tonic-gate	esac
810Sstevel@tonic-gate	if [ -d $ROOT ]; then
82*11838SLiane.Praza@Sun.COM		#
83*11838SLiane.Praza@Sun.COM		# This is the old-style packaging exception list, from
84*11838SLiane.Praza@Sun.COM		# the svr4-specific usr/src/pkgdefs
85*11838SLiane.Praza@Sun.COM		#
86*11838SLiane.Praza@Sun.COM		[ -f $SRC/pkgdefs/etc/exception_list_$arch ] && \
87*11838SLiane.Praza@Sun.COM			validate_paths '-s/\s*'$arch'$//' $excl -b $ROOT \
88*11838SLiane.Praza@Sun.COM			    $args $SRC/pkgdefs/etc/exception_list_$arch
89*11838SLiane.Praza@Sun.COM		#
90*11838SLiane.Praza@Sun.COM		# These are the new-style packaging exception lists,
91*11838SLiane.Praza@Sun.COM		# from the repository-wide exception_lists/ directory.
92*11838SLiane.Praza@Sun.COM		#
93*11838SLiane.Praza@Sun.COM		e="$CODEMGR_WS/exception_lists/packaging"
94*11838SLiane.Praza@Sun.COM		if [ "$CLOSED_IS_PRESENT" = "yes" ]; then
95*11838SLiane.Praza@Sun.COM			e="$e $CODEMGR_WS/exception_lists/packaging.closed"
96*11838SLiane.Praza@Sun.COM		else
97*11838SLiane.Praza@Sun.COM			e="$e $CODEMGR_WS/exception_lists/packaging.open"
98*11838SLiane.Praza@Sun.COM		fi
99*11838SLiane.Praza@Sun.COM		for f in $e; do
100*11838SLiane.Praza@Sun.COM			if [ -f $f ]; then
101*11838SLiane.Praza@Sun.COM				nawk 'NF == 1 || /[ 	]\+'$arch'$/ { print; }' \
102*11838SLiane.Praza@Sun.COM				    < $f | validate_paths -b $ROOT -n $f
103*11838SLiane.Praza@Sun.COM			fi
104*11838SLiane.Praza@Sun.COM		done
1050Sstevel@tonic-gate	fi
1060Sstevel@tonic-gatedone
1070Sstevel@tonic-gate
1080Sstevel@tonic-gate# Two entries in the findunref exception_list deal with things created
1090Sstevel@tonic-gate# by nightly.  Otherwise, this test could be run on an unmodifed (and
1100Sstevel@tonic-gate# unbuilt) workspace.  We handle this by flagging the one that is
1110Sstevel@tonic-gate# present only on a built workspace (./*.out) and the one that's
1120Sstevel@tonic-gate# present only after a run of findunref (./*.ref) with ISUSED, and
1130Sstevel@tonic-gate# disabling all checks of them.  The assumption is that the entries
1140Sstevel@tonic-gate# marked with ISUSED are always known to be good, thus the Latin quote
1150Sstevel@tonic-gate# at the top of the file.
1167078Smjnelson#
1177078Smjnelson# The exception_list is generated from whichever input files are appropriate
1187078Smjnelson# for this workspace, so checking it obviates the need to check the inputs.
11910313SPeter.Memishian@Sun.COM
1200Sstevel@tonic-gateif [ -r $SRC/tools/findunref/exception_list ]; then
12110313SPeter.Memishian@Sun.COM	validate_paths -k ISUSED -r -e '^\*' $SRC/tools/findunref/exception_list
1220Sstevel@tonic-gatefi
1230Sstevel@tonic-gate
1240Sstevel@tonic-gate# These are straightforward.
1250Sstevel@tonic-gateif [ -d $SRC/xmod ]; then
1262138Scarlsonj	# If the closed source is not present, then don't validate it.
1272138Scarlsonj	if [ "$CLOSED_IS_PRESENT" = no ]; then
1282138Scarlsonj		excl_cry="-e ^usr/closed"
1292138Scarlsonj		excl_xmod="-e ^../closed"
1302138Scarlsonj	fi
1312138Scarlsonj	validate_paths $excl_cry $SRC/xmod/cry_files
1322138Scarlsonj	validate_paths $excl_xmod -b $SRC $SRC/xmod/xmod_files
1330Sstevel@tonic-gatefi
1340Sstevel@tonic-gate
1356417Smjnelsonif [ -f $SRC/tools/opensolaris/license-list ]; then
1366417Smjnelson	excl=
1376417Smjnelson	if [ "$CLOSED_IS_PRESENT" = no ]; then
1386417Smjnelson		excl="-e ^usr/closed"
1396417Smjnelson	fi
1406417Smjnelson	sed -e 's/$/.descrip/' < $SRC/tools/opensolaris/license-list | \
141*11838SLiane.Praza@Sun.COM		validate_paths -n SRC/tools/opensolaris/license-list $excl
1426417Smjnelsonfi
1436417Smjnelson
1440Sstevel@tonic-gate# Finally, make sure the that (req|inc).flg files are in good shape.
1452138Scarlsonj# If SCCS files are not expected to be present, though, then don't
1462138Scarlsonj# check them.
1472138Scarlsonjif [ ! -d "$CODEMGR_WS/Codemgr_wsdata" ]; then
1482138Scarlsonj	f_flg='-f'
1492138Scarlsonjfi
1502138Scarlsonj# If the closed source is not present, then don't validate it.
1512138Scarlsonjif [ "$CLOSED_IS_PRESENT" = no ]; then
1522138Scarlsonj	excl="-e ^usr/closed/"
1532138Scarlsonjfi
1542138Scarlsonj
1552138Scarlsonjvalidate_flg $f_flg $excl
1560Sstevel@tonic-gate
1570Sstevel@tonic-gateexit 0
158