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]
23 # Copyright 2016 Toomas Soome <tsoome@me.com>
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2014 by Delphix. All rights reserved.
37 echo "This utility is a component of the bootadm(1M) implementation"
38 echo "and it is not recommended for stand-alone use."
39 echo "Please use bootadm(1M) instead."
41 echo "Usage: ${0##*/}: [-R \<root\>] [-p \<platform\>]"
42 echo "where \<platform\> is one of: i86pc"
46 # default platform is what we're running on
49 export PATH
=/usr
/sbin
:/usr
/bin
:/sbin
50 export GZIP_CMD
=/usr
/bin
/gzip
52 EXTRACT_FILELIST
="/boot/solaris/bin/extract_boot_filelist"
62 if [ "$ALT_ROOT" != "/" ]; then
63 echo "Creating boot_archive for $ALT_ROOT"
64 EXTRACT_ARGS
="${EXTRACT_ARGS} -R ${ALT_ROOT}"
65 EXTRACT_FILELIST
="${ALT_ROOT}${EXTRACT_FILELIST}"
70 EXTRACT_ARGS
="${EXTRACT_ARGS} -p ${PLATFORM}"
78 shift `expr $OPTIND - 1`
82 echo "Creating boot_archive for $ALT_ROOT"
93 BOOT_ARCHIVE
=platform
/$PLATFORM/boot_archive
97 [ -n "$rddir" ] && rm -fr "$rddir" 2> /dev
/null
104 cpio -o -H odc
< "$list" > "$cpiofile"
106 [ -x /usr
/bin
/digest
] && /usr
/bin
/digest
-a sha1
"$cpiofile" > "$archive.hash-new"
109 # Check if gzip exists in /usr/bin, so we only try to run gzip
110 # on systems that have gzip.
112 if [ -x $GZIP_CMD ] ; then
113 gzip -c "$cpiofile" > "${archive}-new"
115 mv "$cpiofile" "${archive}-new"
118 if [ $?
-ne 0 ] ; then
119 rm -f "${archive}-new" "$achive.hash-new"
123 function create_archive
127 echo "updating $archive"
129 create_cpio
"$archive"
131 if [ ! -e "${archive}-new" ] ; then
133 # Two of these functions may be run in parallel. We
134 # need to allow the other to clean up, so we can't
135 # exit immediately. Instead, we set a flag.
137 echo "update of $archive failed"
140 # remove the hash first, it's better to have a boot archive
141 # without a hash, than one with a hash for its predecessor
142 rm -f "$archive.hash"
143 mv "${archive}-new" "$archive"
144 mv "$archive.hash-new" "$archive.hash" 2> /dev
/null
157 if [ ! -f "$ALT_ROOT/boot/solaris/filelist.ramdisk" ] &&
158 [ ! -f "$ALT_ROOT/etc/boot/solaris/filelist.ramdisk" ]
160 print
-u2 "Can't find filelist.ramdisk"
163 filelist
=$
($EXTRACT_FILELIST $EXTRACT_ARGS \
164 /boot
/solaris
/filelist.ramdisk \
165 /etc
/boot
/solaris
/filelist.ramdisk \
166 2>/dev
/null |
sort -u)
169 # We assume there is enough space on $ALT_ROOT. We create the temporary
170 # file in /platform because then it is just a local filesystem move (instead
171 # of a cross-mountpoint move). So, if we successufully create the boot
172 # archive temp file, we will likely succeed in moving it into place.
174 rddir
="/$ALT_ROOT/platform/create_ramdisk.$$.tmp"
176 mkdir
"$rddir" || fatal_error
"Could not create temporary directory $rddir"
178 # Clean up upon exit.
181 list
="$rddir/filelist"
186 # This loop creates the lists of files. The list is written to stdout,
187 # which is redirected at the end of the loop.
190 find $filelist -print 2>/dev
/null
> "$list"
192 cpiofile
="$rddir/cpio.file"
194 create_archive
"$ALT_ROOT/$BOOT_ARCHIVE"
196 if [ $ERROR = 1 ]; then
201 [ -n "$rddir" ] && rm -rf "$rddir"