8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / boot / scripts / extract_boot_filelist.ksh
blob52479b747124e5b39a45a9b23b4c1f271d7144ad
1 #!/bin/ksh -p
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
22 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
25 # ident "%Z%%M% %I% %E% SMI"
28 # set path, but inherit /tmp/bfubin if it is sane
30 if [ "`echo $PATH | cut -f 1 -d :`" = /tmp/bfubin ] && \
31 [ -O /tmp/bfubin ] ; then
32 export PATH=/tmp/bfubin:/usr/sbin:/usr/bin:/sbin
33 else
34 export PATH=/usr/sbin:/usr/bin:/sbin
37 usage() {
38 echo "This utility is a component of the bootadm(1M) implementation"
39 echo "and it is not recommended for stand-alone use."
40 echo "Please use bootadm(1M) instead."
41 echo ""
42 echo "Usage: ${0##*/}: [-R <root>] [-p <platform>] <filelist> ..."
43 echo "where <platform> is one of i86pc, sun4u or sun4v"
44 exit 2
47 build_platform() {
49 altroot=$1
52 cd $altroot/
53 if [ -z "$STRIP" ] ; then
54 ls -d platform/*/kernel
55 else
56 ls -d platform/*/kernel | grep -v $STRIP
61 # default platform is what we're running on
62 PLATFORM=`uname -m`
64 altroot=""
65 filelists=
66 platform_provided=no
68 OPTIND=1
69 while getopts R:p: FLAG
71 case $FLAG in
72 R) if [ "$OPTARG" != "/" ]; then
73 altroot="$OPTARG"
76 p) platform_provided=yes
77 PLATFORM="$OPTARG"
79 *) usage
81 esac
82 done
84 shift `expr $OPTIND - 1`
85 if [ $# -eq 0 ]; then
86 usage
89 filelists=$*
92 # If the target platform is provided, as is the case for diskless,
93 # or we're building an archive for this machine, we can build
94 # a smaller archive by not including unnecessary components.
96 filtering=no
97 if [ "$altroot" == "" ] || [ $platform_provided = yes ]; then
98 case $PLATFORM in
99 i86pc)
100 STRIP=
102 sun4u)
103 STRIP=platform/sun4v/
105 sun4v)
106 STRIP=platform/sun4u/
109 STRIP=
111 esac
114 for list in $filelists
116 if [ -f $altroot/$list ]; then
117 grep ^platform$ $altroot/$list > /dev/null
118 if [ $? = 0 ] ; then
119 build_platform $altroot
120 if [ -z "$STRIP" ] ; then
121 cat $altroot/$list | grep -v ^platform$
122 else
123 cat $altroot/$list | grep -v ^platform$ | \
124 grep -v $STRIP
126 else
127 if [ -z "$STRIP" ] ; then
128 cat $altroot/$list
129 else
130 cat $altroot/$list | grep -v $STRIP
135 done
137 exit 0