xref: /illumos-gate/usr/src/tools/scripts/checkpaths.sh (revision 6f0673af8764c356a5bd511fc7ca8af579fe2000)
17c478bd9Sstevel@tonic-gate#!/bin/ksh -p
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6fb23a357Skupfer# Common Development and Distribution License (the "License").
7fb23a357Skupfer# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
229730304dSmeem# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate# Use is subject to license terms.
247c478bd9Sstevel@tonic-gate#
25*1f5207b7SJohn Levon# Copyright (c) 2019, Joyent, Inc.
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate# Quis custodiet ipsos custodies?
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gateif [ -z "$SRC" ]; then
307c478bd9Sstevel@tonic-gate	SRC=$CODEMGR_WS/usr/src
317c478bd9Sstevel@tonic-gatefi
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gateif [ -z "$CODEMGR_WS" -o ! -d "$CODEMGR_WS" -o ! -d "$SRC" ]; then
347c478bd9Sstevel@tonic-gate	echo "$0: must be run from within a workspace."
357c478bd9Sstevel@tonic-gate	exit 1
367c478bd9Sstevel@tonic-gatefi
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gatecd $CODEMGR_WS || exit 1
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate# Use -b to tell this script to ignore derived (built) objects.
417c478bd9Sstevel@tonic-gateif [ "$1" = "-b" ]; then
427c478bd9Sstevel@tonic-gate	b_flg=y
437c478bd9Sstevel@tonic-gatefi
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gate# Not currently used; available for temporary workarounds.
467c478bd9Sstevel@tonic-gateargs="-k NEVER_CHECK"
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate# We intentionally don't depend on $MACH here, and thus no $ROOT.  If
497c478bd9Sstevel@tonic-gate# a proto area exists, then we use it.  This allows this script to be
507c478bd9Sstevel@tonic-gate# run against gates (which should contain both SPARC and x86 proto
517c478bd9Sstevel@tonic-gate# areas), build workspaces (which should contain just one proto area),
527c478bd9Sstevel@tonic-gate# and unbuilt workspaces (which contain no proto areas).
537c478bd9Sstevel@tonic-gateif [ "$b_flg" = y ]; then
547c478bd9Sstevel@tonic-gate	rootlist=
557c478bd9Sstevel@tonic-gateelif [ $# -gt 0 ]; then
567c478bd9Sstevel@tonic-gate	rootlist=$*
577c478bd9Sstevel@tonic-gateelse
587c478bd9Sstevel@tonic-gate	rootlist="$CODEMGR_WS/proto/root_sparc $CODEMGR_WS/proto/root_i386"
597c478bd9Sstevel@tonic-gatefi
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gatefor ROOT in $rootlist
627c478bd9Sstevel@tonic-gatedo
637c478bd9Sstevel@tonic-gate	case "$ROOT" in
644e5b757fSkupfer	*sparc|*sparc-nd)
654e5b757fSkupfer		arch=sparc
664e5b757fSkupfer		;;
674e5b757fSkupfer	*i386|*i386-nd)
684e5b757fSkupfer		arch=i386
694e5b757fSkupfer		;;
707c478bd9Sstevel@tonic-gate	*)
717c478bd9Sstevel@tonic-gate		echo "$ROOT has unknown architecture." >&2
727c478bd9Sstevel@tonic-gate		exit 1
737c478bd9Sstevel@tonic-gate		;;
747c478bd9Sstevel@tonic-gate	esac
757c478bd9Sstevel@tonic-gatedone
767c478bd9Sstevel@tonic-gate
777c478bd9Sstevel@tonic-gate# Two entries in the findunref exception_list deal with things created
787c478bd9Sstevel@tonic-gate# by nightly.  Otherwise, this test could be run on an unmodifed (and
797c478bd9Sstevel@tonic-gate# unbuilt) workspace.  We handle this by flagging the one that is
807c478bd9Sstevel@tonic-gate# present only on a built workspace (./*.out) and the one that's
817c478bd9Sstevel@tonic-gate# present only after a run of findunref (./*.ref) with ISUSED, and
827c478bd9Sstevel@tonic-gate# disabling all checks of them.  The assumption is that the entries
837c478bd9Sstevel@tonic-gate# marked with ISUSED are always known to be good, thus the Latin quote
847c478bd9Sstevel@tonic-gate# at the top of the file.
85cdf0c1d5Smjnelson#
86cdf0c1d5Smjnelson# The exception_list is generated from whichever input files are appropriate
87cdf0c1d5Smjnelson# for this workspace, so checking it obviates the need to check the inputs.
889730304dSmeem
897c478bd9Sstevel@tonic-gateif [ -r $SRC/tools/findunref/exception_list ]; then
909730304dSmeem	validate_paths -k ISUSED -r -e '^\*' $SRC/tools/findunref/exception_list
917c478bd9Sstevel@tonic-gatefi
927c478bd9Sstevel@tonic-gate
93a422476dSRichard Lowevalidate_flg -f
947c478bd9Sstevel@tonic-gate
957c478bd9Sstevel@tonic-gateexit 0
96