summaryrefslogtreecommitdiff
path: root/usr/src/tools/scripts/checkpaths.sh
blob: 836ed71653f6576f11a0dbd709b413f14fb003a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

# Quis custodiet ipsos custodies?

if [ -z "$SRC" ]; then
	SRC=$CODEMGR_WS/usr/src
fi

if [ -z "$CODEMGR_WS" -o ! -d "$CODEMGR_WS" -o ! -d "$SRC" ]; then
	echo "$0: must be run from within a workspace."
	exit 1
fi

cd $CODEMGR_WS || exit 1

# Use -b to tell this script to ignore derived (built) objects.
if [ "$1" = "-b" ]; then
	b_flg=y
fi

# Not currently used; available for temporary workarounds.
args="-k NEVER_CHECK"

# We intentionally don't depend on $MACH here, and thus no $ROOT.  If
# a proto area exists, then we use it.  This allows this script to be
# run against gates (which should contain both SPARC and x86 proto
# areas), build workspaces (which should contain just one proto area),
# and unbuilt workspaces (which contain no proto areas).
if [ "$b_flg" = y ]; then
	rootlist=
elif [ $# -gt 0 ]; then
	rootlist=$*
else
	rootlist="$CODEMGR_WS/proto/root_sparc $CODEMGR_WS/proto/root_i386"
fi

# If the closed source is not present, then exclude IKE from validation.
if [ "$CLOSED_IS_PRESENT" = no ]; then
	excl="-e ^usr/include/ike/"
fi

for ROOT in $rootlist
do
	case "$ROOT" in
	*sparc|*sparc-nd)
		arch=sparc
		;;
	*i386|*i386-nd)
		arch=i386
		;;
	*)
		echo "$ROOT has unknown architecture." >&2
		exit 1
		;;
	esac
	if [ -d $ROOT ]; then
		#
		# This is the old-style packaging exception list, from
		# the svr4-specific usr/src/pkgdefs
		#
		[ -f $SRC/pkgdefs/etc/exception_list_$arch ] && \
			validate_paths '-s/\s*'$arch'$//' $excl -b $ROOT \
			    $args $SRC/pkgdefs/etc/exception_list_$arch
		#
		# These are the new-style packaging exception lists,
		# from the repository-wide exception_lists/ directory.
		#
		e="$CODEMGR_WS/exception_lists/packaging"
		for f in $e; do
			if [ -f $f ]; then
				nawk 'NF == 1 || /[ 	]\+'$arch'$/ { print; }' \
				    < $f | validate_paths -b $ROOT -n $f
			fi
		done
	fi
done

# Two entries in the findunref exception_list deal with things created
# by nightly.  Otherwise, this test could be run on an unmodifed (and
# unbuilt) workspace.  We handle this by flagging the one that is
# present only on a built workspace (./*.out) and the one that's
# present only after a run of findunref (./*.ref) with ISUSED, and
# disabling all checks of them.  The assumption is that the entries
# marked with ISUSED are always known to be good, thus the Latin quote
# at the top of the file.
#
# The exception_list is generated from whichever input files are appropriate
# for this workspace, so checking it obviates the need to check the inputs.

if [ -r $SRC/tools/findunref/exception_list ]; then
	validate_paths -k ISUSED -r -e '^\*' $SRC/tools/findunref/exception_list
fi

if [ -f $SRC/tools/opensolaris/license-list ]; then
	excl=
	if [ "$CLOSED_IS_PRESENT" = no ]; then
		excl="-e ^usr/closed"
	fi
	sed -e 's/$/.descrip/' < $SRC/tools/opensolaris/license-list | \
		validate_paths -n SRC/tools/opensolaris/license-list $excl
fi

# Finally, make sure the that (req|inc).flg files are in good shape.
# If SCCS files are not expected to be present, though, then don't
# check them.
if [ ! -d "$CODEMGR_WS/Codemgr_wsdata" ]; then
	f_flg='-f'
fi
# If the closed source is not present, then don't validate it.
if [ "$CLOSED_IS_PRESENT" = no ]; then
	excl="-e ^usr/closed/"
fi

validate_flg $f_flg $excl

exit 0