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 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
28 # mkbootmedia - create bootable Solaris ISO image
32 MKISOFS
=/usr
/bin
/mkisofs
33 ELTORITO
=boot
/grub
/stage2_eltorito
# relative to $MEDIA_ROOT
34 SPARCBOOT
=boot
/hsfs.bootblock
44 TEXTDOMAIN
=SUNW_OST_OSCMD
50 gettext "Usage:\n${PROG##*/} [-v] [-l <label>] <media-root> <iso>\n"
51 gettext "Options:\n -l <label>\n Label/volume name of the ISO image.\n"
52 gettext " -v\n Verbose. Multiple -v options increase verbosity.\n"
63 while getopts ':l:v' opt
68 v
) (( VERBOSITY
+= 1 ))
70 :) gettext "Option -$OPTARG missing argument.\n"
74 *) gettext "Option -$OPTARG invalid.\n"
91 if [ ! -z `echo $ISOIMAGE | $GREP "^/tmp"` ]; then
92 gettext "ISO images will not be created on /tmp.\nPlease choose a different output location.\n"
96 # Verify $MEDIA_ROOT is a Solaris install media (Solaris 10 Update 1 or later)
97 if [[ ! -d $
(echo "$MEDIA_ROOT"/Solaris
*/Tools
/Boot
) ]]; then
98 gettext "$MEDIA_ROOT is not Solaris install media.\n"
102 # If no label specified use the Solaris_* version under $MEDIA_ROOT
103 if [[ -z "$LABEL" ]]; then
104 LABEL
=$
(echo "$MEDIA_ROOT"/Solaris
*)
108 # If $ISOIMAGE exists, verify it's writable.
109 if [[ -e "$ISOIMAGE" && ! -w "$ISOIMAGE" ]]; then
110 gettext "$ISOIMAGE exists but is not writable.\n"
114 # If we're on an x86/x64 system, we need to have the El Torito file
115 # modified with some boot information (-boot-info-table option).
116 # If the image isn't writable, we can't continue
117 # UltraSPARC systems (sun4u, sun4v etc) don't use El Torito
118 if [[ "$MACH" = "i386" && ! -w "$MEDIA_ROOT/$ELTORITO" ]]; then
119 gettext "$MEDIA_ROOT/$ELTORITO is not writable.\n"
123 # Check that we've got mkisofs installed
124 if [[ ! -f "$MKISOFS" ||
! -x "$MKISOFS" ]]; then
125 gettext "Cannot find $f\n"
130 # Determine mkisofs' verbose flag depending on $VERBOSITY.
132 0) VERBOSE_FLAG
=-quiet
134 1) VERBOSE_FLAG
= # mkisofs' default verboseness
140 VERBOSE_FLAG
="-v $VERBOSE_FLAG"
146 # Since mkisofs below will modify the file $ELTORITO in-place, save a copy
147 # of it first. Use trap to restore it when this script exits (including
148 # when user hits control-C).
150 if [[ "$MACH" = "i386" ]]
152 BOOTBLOCK
=$MEDIA_ROOT/$ELTORITO
153 ELTORITO_SAVE
=/tmp
/${ELTORITO##*/}.$$
154 $CP "$MEDIA_ROOT/$ELTORITO" "$ELTORITO_SAVE" ||
exit 1
155 trap '"$CP" "$ELTORITO_SAVE" "$MEDIA_ROOT/$ELTORITO" 2>/dev/null;
156 "$RM" -f "$ELTORITO_SAVE"' EXIT
158 # sun4u/sun4u1/sun4v et al
159 BOOTBLOCK
=$MEDIA_ROOT/$SPARCBOOT
160 SPARCBOOT_SAVE
=/tmp
/hsfs.bootblock.$$
161 $CP "$MEDIA_ROOT/$SPARCBOOT" "$SPARCBOOT_SAVE" ||
exit 1
162 trap '"$CP" "$MEDIA_ROOT/$SPARCBOOT" "$SPARCBOOT_SAVE" 2>/dev/null;
163 "$RM" -f $SPARCBOOT_SAVE"' EXIT
166 # Call mkisofs to do the actual work.
167 # Note: the "-log-file >(cat -u >&2)" and "2>/dev/null" below is a trick
168 # to filter out mkisofs's warning message about being non-conforming
170 # We do some funky architecture-specific stuff here so that we can
171 # actually create a bootable media image for UltraSPARC systems
173 sparc_ISOARGS
="-G $BOOTBLOCK -B ... -joliet-long -R -U"
174 i386_ISOARGS
="-b boot/grub/stage2_eltorito -boot-info-table "
175 i386_ISOARGS
="$i386_ISOARGS -boot-load-size 4 -c .catalog -d -N "
176 i386_ISOARGS
="$i386_ISOARGS -no-emul-boot -r -relaxed-filenames"
177 if [[ "$MACH" = "i386" ]]
179 ISOARGS
=$i386_ISOARGS
181 ISOARGS
=$sparc_ISOARGS
184 $MKISOFS -o "$ISOIMAGE" \
185 -allow-leading-dots \
191 -log-file >($CAT -u >&2) \
192 "$MEDIA_ROOT" 2>/dev
/null