xref: /illumos-gate/usr/src/cmd/boot/scripts/extract_boot_filelist.ksh (revision bea83d026ee1bd1b2a2419e1d0232f107a5d7d9b)
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# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# ident	"%Z%%M%	%I%	%E% SMI"
26
27#
28# set path, but inherit /tmp/bfubin if it is sane
29#
30if [ "`echo $PATH | cut -f 1 -d :`" = /tmp/bfubin ] && \
31    [ -O /tmp/bfubin ] ; then
32	export PATH=/tmp/bfubin:/usr/sbin:/usr/bin:/sbin
33else
34	export PATH=/usr/sbin:/usr/bin:/sbin
35fi
36
37usage() {
38	echo "Usage: ${0##*/}: [-R \<root\>] <filelist> ..."
39	exit 2
40}
41
42altroot=""
43filelists=
44while getopts R FLAG
45do
46        case $FLAG in
47        R)	shift
48		if [ "$1" != "/" ]; then
49			altroot="$1"
50		fi
51		;;
52        *)      usage
53		;;
54        esac
55	shift
56done
57
58if [ $# -eq 0 ]; then
59	usage
60fi
61
62filelists=$*
63
64filtering=no
65if [ "$altroot" == "" ]; then
66	case `uname -m` in
67	i86pc)
68		filtering=no
69		;;
70	sun4u)
71		filtering=yes
72		exclude_pattern="sun4v"
73		;;
74	sun4v)
75		filtering=yes
76		exclude_pattern="sun4u"
77		;;
78	esac
79fi
80
81for list in $filelists
82do
83	if [ -f $altroot/$list ]; then
84		if [ $filtering = yes ]; then
85			cat $altroot/$list | grep -v $exclude_pattern
86		else
87			cat $altroot/$list
88		fi
89	fi
90done
91
92exit 0
93