xref: /titanic_50/usr/src/tools/scripts/bringovercheck.sh (revision 3420b242dcd546952ee939a5a378bba3d3080165)
1733ed737Ssommerfe#! /bin/ksh -p
2733ed737Ssommerfe#
3733ed737Ssommerfe# CDDL HEADER START
4733ed737Ssommerfe#
5733ed737Ssommerfe# The contents of this file are subject to the terms of the
6733ed737Ssommerfe# Common Development and Distribution License (the "License").
7733ed737Ssommerfe# You may not use this file except in compliance with the License.
8733ed737Ssommerfe#
9733ed737Ssommerfe# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10733ed737Ssommerfe# or http://www.opensolaris.org/os/licensing.
11733ed737Ssommerfe# See the License for the specific language governing permissions
12733ed737Ssommerfe# and limitations under the License.
13733ed737Ssommerfe#
14733ed737Ssommerfe# When distributing Covered Code, include this CDDL HEADER in each
15733ed737Ssommerfe# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16733ed737Ssommerfe# If applicable, add the following below this CDDL HEADER, with the
17733ed737Ssommerfe# fields enclosed by brackets "[]" replaced with your own identifying
18733ed737Ssommerfe# information: Portions Copyright [yyyy] [name of copyright owner]
19733ed737Ssommerfe#
20733ed737Ssommerfe# CDDL HEADER END
21733ed737Ssommerfe#
22733ed737Ssommerfe
23733ed737Ssommerfe#
24733ed737Ssommerfe# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25733ed737Ssommerfe# Use is subject to license terms.
26733ed737Ssommerfe#
27733ed737Ssommerfe# ident	"%Z%%M%	%I%	%E% SMI"
28733ed737Ssommerfe#
29733ed737Ssommerfe
30733ed737Ssommerfe#
31733ed737Ssommerfe# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
32733ed737Ssommerfe# under certain circumstances, which can really screw things up; unset it.
33733ed737Ssommerfe#
34733ed737Ssommerfeunset CDPATH
35733ed737Ssommerfe
36733ed737SsommerfePATH=/usr/bin:/usr/ccs/bin
37733ed737Ssommerfe
38*3420b242Ssommerfe# yield an exit status and no other output
39*3420b242Ssommerfe# /dev/null redirection guards against noise in the event that neither $1
40*3420b242Ssommerfe# nor $2 exist
41*3420b242Ssommerfeisnewer() {
42*3420b242Ssommerfe	[ "$1" -nt "$2" ] && return 0
43*3420b242Ssommerfe	[ "$1" -ot "$2" ] && return 1
44*3420b242Ssommerfe	left=$(/bin/ls -E "$1" 2>/dev/null | awk '{print $7}')
45*3420b242Ssommerfe	left=${left##*.}
46*3420b242Ssommerfe	right=$(/bin/ls -E "$2" 2>/dev/null | awk '{print $7}')
47*3420b242Ssommerfe	right=${right##*.}
48*3420b242Ssommerfe	[ -z "$left" -o -z "$right" -o "$left" -gt "$right" ] && return 0
49*3420b242Ssommerfe	return 1
50*3420b242Ssommerfe}
51*3420b242Ssommerfe
52733ed737Ssommerfeif [ $# -ne 1 ]; then
53733ed737Ssommerfe	echo "Usage: $0 workspace" 1>&2
54733ed737Ssommerfe	exit 1
55733ed737Ssommerfefi
56733ed737Ssommerfe
57733ed737SsommerfeCODEMGR_WS="$1"
58733ed737Ssommerfe
59733ed737Ssommerfeif [ ! -d "${CODEMGR_WS}" ]; then
60733ed737Ssommerfe    	echo "${CODEMGR_WS}: not a directory" 1>&2
61733ed737Ssommerfe	echo "Usage: $0 workspace" 1>&2
62733ed737Ssommerfe	exit 1
63733ed737Ssommerfefi
64733ed737Ssommerfe
65733ed737Ssommerfeif [ ! -f "${CODEMGR_WS}"/Codemgr_wsdata/nametable ]; then
66733ed737Ssommerfe    	echo "${CODEMGR_WS}: not a workspace (no Codemgr_wsdata/nametable)" 1>&2
67733ed737Ssommerfe	echo "Usage: $0 workspace" 1>&2
68733ed737Ssommerfe	exit 1
69733ed737Ssommerfefi
70733ed737Ssommerfe
71733ed737Ssommerfecd ${CODEMGR_WS} &&
72*3420b242Ssommerfetail +2 Codemgr_wsdata/nametable |
73733ed737Ssommerfewhile read file etc; do
74733ed737Ssommerfe    	file="./$file"
75733ed737Ssommerfe	sfile="${file%/*}/SCCS/s.${file##*/}"
76*3420b242Ssommerfe	if isnewer "$sfile" "$file"; then
77733ed737Ssommerfe	    	ls -E "$sfile"
78733ed737Ssommerfe		ls -E "$file"
79733ed737Ssommerfe		echo "reget $file:"
80733ed737Ssommerfe		# -G needed so file doesn't land in working dir.
81733ed737Ssommerfe		sccs get -G "$file" "$file"
82733ed737Ssommerfe	fi
83*3420b242Ssommerfedone
84