10Sstevel@tonic-gate#!/bin/ksh -p 20Sstevel@tonic-gate# 30Sstevel@tonic-gate# CDDL HEADER START 40Sstevel@tonic-gate# 50Sstevel@tonic-gate# The contents of this file are subject to the terms of the 62334Ssetje# Common Development and Distribution License (the "License"). 72334Ssetje# You may not use this file except in compliance with the License. 80Sstevel@tonic-gate# 90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate# See the License for the specific language governing permissions 120Sstevel@tonic-gate# and limitations under the License. 130Sstevel@tonic-gate# 140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate# 200Sstevel@tonic-gate# CDDL HEADER END 210Sstevel@tonic-gate# 220Sstevel@tonic-gate 23*6006Sdminer# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate# Use is subject to license terms. 250Sstevel@tonic-gate 262334Ssetje# ident "%Z%%M% %I% %E% SMI" 27174Sjg 280Sstevel@tonic-gateformat=ufs 290Sstevel@tonic-gateALT_ROOT= 305648SsetjeALTROOT_ARG= 313446Smrjcompress=yes 323446SmrjSPLIT=unknown 333446SmrjERROR=0 344213Srscottdirsize32=0 354213Srscottdirsize64=0 360Sstevel@tonic-gate 375648SsetjePLAT=`uname -m` 385648Ssetjeif [ $PLAT = i86pc ] ; then 395648Ssetje ARCH64=amd64 405648Ssetjeelse 415648Ssetje ARCH64=sparcv9 425648Ssetjefi 435648SsetjeBOOT_ARCHIVE=platform/$PLAT/boot_archive 445648SsetjeBOOT_ARCHIVE_64=platform/$PLAT/$ARCH64/boot_archive 450Sstevel@tonic-gate 465648Ssetje# 475648Ssetje# set path, but inherit /tmp/bfubin if owned by 485648Ssetje# same uid executing this process, which must be root. 495648Ssetje# 505648Ssetjeif [ "`echo $PATH | cut -f 1 -d :`" = /tmp/bfubin ] && \ 515648Ssetje [ -O /tmp/bfubin ] ; then 525734Ssetje export PATH=/tmp/bfubin 535734Ssetje export GZIP_CMD=/tmp/bfubin/gzip 545648Ssetjeelse 555648Ssetje export PATH=/usr/sbin:/usr/bin:/sbin 565734Ssetje export GZIP_CMD=/usr/bin/gzip 575648Ssetjefi 585648Ssetje 595648SsetjeEXTRACT_FILELIST="/boot/solaris/bin/extract_boot_filelist" 600Sstevel@tonic-gate 610Sstevel@tonic-gate# 620Sstevel@tonic-gate# Parse options 630Sstevel@tonic-gate# 643446Smrjwhile [ "$1" != "" ] 650Sstevel@tonic-gatedo 663446Smrj case $1 in 673446Smrj -R) shift 683446Smrj ALT_ROOT="$1" 690Sstevel@tonic-gate if [ "$ALT_ROOT" != "/" ]; then 705734Ssetje echo "Creating boot_archive for $ALT_ROOT" 715648Ssetje ALTROOT_ARG="-R $ALT_ROOT" 725648Ssetje EXTRACT_FILELIST="${ALT_ROOT}${EXTRACT_FILELIST}" 730Sstevel@tonic-gate fi 740Sstevel@tonic-gate ;; 753467Srscott -n|--nocompress) compress=no 763467Srscott ;; 773446Smrj *) echo Usage: ${0##*/}: [-R \<root\>] [--nocompress] 783467Srscott exit 793467Srscott ;; 800Sstevel@tonic-gate esac 813446Smrj shift 820Sstevel@tonic-gatedone 830Sstevel@tonic-gate 840Sstevel@tonic-gateif [ -x /usr/bin/mkisofs -o -x /tmp/bfubin/mkisofs ] ; then 850Sstevel@tonic-gate format=isofs 860Sstevel@tonic-gatefi 870Sstevel@tonic-gate 88621Svikram# 89621Svikram# mkisofs on s8 doesn't support functionality used by GRUB boot. 90621Svikram# Use ufs format for boot archive instead. 91621Svikram# 92621Svikramrelease=`uname -r` 93621Svikramif [ "$release" = "5.8" ]; then 943446Smrj format=ufs 95621Svikramfi 96621Svikram 970Sstevel@tonic-gateshift `expr $OPTIND - 1` 980Sstevel@tonic-gate 990Sstevel@tonic-gateif [ $# -eq 1 ]; then 1002334Ssetje ALT_ROOT="$1" 1015734Ssetje echo "Creating boot_archive for $ALT_ROOT" 1020Sstevel@tonic-gatefi 1030Sstevel@tonic-gate 1045648Ssetjeif [ $PLAT = i86pc ] ; then 1055648Ssetje rundir=`dirname $0` 1065648Ssetje if [ ! -x "$rundir"/symdef ]; then 1075648Ssetje # Shouldn't happen 1085648Ssetje echo "Warning: $rundir/symdef not present." 1095648Ssetje echo "Creating single archive at $ALT_ROOT/$BOOT_ARCHIVE" 1105648Ssetje SPLIT=no 1115648Ssetje compress=no 1125648Ssetje elif "$rundir"/symdef "$ALT_ROOT"/platform/i86pc/kernel/unix \ 1135648Ssetje dboot_image 2>/dev/null; then 1145648Ssetje SPLIT=yes 1155648Ssetje else 1165648Ssetje SPLIT=no 1175648Ssetje compress=no 1185648Ssetje fi 1195648Ssetjeelse # must be sparc 1205648Ssetje SPLIT=no # there's only 64-bit (sparcv9), so don't split 1215648Ssetje compress=no 1223446Smrjfi 1233446Smrj 1245734Ssetje[ -x $GZIP_CMD ] || compress=no 1253446Smrj 1262334Ssetjefunction cleanup 1272334Ssetje{ 1283446Smrj umount -f "$rdmnt32" 2>/dev/null 1293446Smrj umount -f "$rdmnt64" 2>/dev/null 1303446Smrj lofiadm -d "$rdfile32" 2>/dev/null 1313446Smrj lofiadm -d "$rdfile64" 2>/dev/null 1324213Srscott [ -n "$rddir" ] && rm -fr "$rddir" 2> /dev/null 1334213Srscott [ -n "$new_rddir" ] && rm -fr "$new_rddir" 2>/dev/null 1340Sstevel@tonic-gate} 1350Sstevel@tonic-gate 1362334Ssetjefunction getsize 1372334Ssetje{ 1384213Srscott # Estimate image size and add 10% overhead for ufs stuff. 1392511Sjongkis # Note, we can't use du here in case we're on a filesystem, e.g. zfs, 1402511Sjongkis # in which the disk usage is less than the sum of the file sizes. 1412511Sjongkis # The nawk code 1422511Sjongkis # 1434213Srscott # {t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5} 1442511Sjongkis # 1452511Sjongkis # below rounds up the size of a file/directory, in bytes, to the 1462511Sjongkis # next multiple of 1024. This mimics the behavior of ufs especially 1472511Sjongkis # with directories. This results in a total size that's slightly 1482511Sjongkis # bigger than if du was called on a ufs directory. 1495648Ssetje size32=$(cat "$list32" | xargs -I {} ls -lLd "{}" 2> /dev/null | 1505648Ssetje nawk '{t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5} 1514213Srscott END {print int(t * 1.10 / 1024)}') 1524213Srscott (( size32 += dirsize32 )) 1535648Ssetje size64=$(cat "$list64" | xargs -I {} ls -lLd "{}" 2> /dev/null | 1545648Ssetje nawk '{t += ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5} 1554213Srscott END {print int(t * 1.10 / 1024)}') 1564213Srscott (( size64 += dirsize64 )) 1574213Srscott (( total_size = size32 + size64 )) 1585648Ssetje 1595648Ssetje if [ $compress = yes ] ; then 1605648Ssetje total_size=`echo $total_size | nawk '{print int($1 / 2)}'` 1615648Ssetje fi 1620Sstevel@tonic-gate} 1630Sstevel@tonic-gate 1643446Smrj# 1654213Srscott# Copies all desired files to a target directory. One argument should be 1664213Srscott# passed: the file containing the list of files to copy. This function also 1674213Srscott# depends on several variables that must be set before calling: 1683555Srscott# 1693555Srscott# $ALT_ROOT - the target directory 1703555Srscott# $compress - whether or not the files in the archives should be compressed 1713555Srscott# $rdmnt - the target directory 1723555Srscott# 1734213Srscottfunction copy_files 1743555Srscott{ 1754213Srscott list="$1" 1763555Srscott 1773555Srscott # 1783555Srscott # If compress is set, the files are gzip'd and put in the correct 1793555Srscott # location in the loop. Nothing is printed, so the pipe and cpio 1803555Srscott # at the end is a nop. 1813555Srscott # 1823555Srscott # If compress is not set, the file names are printed, which causes 1833555Srscott # the cpio at the end to do the copy. 1843555Srscott # 1854213Srscott while read path 1863555Srscott do 1874213Srscott if [ $compress = yes ]; then 1884213Srscott dir="${path%/*}" 189*6006Sdminer [ -d "$rdmnt/$dir" ] || mkdir -p "$rdmnt/$dir" 1905734Ssetje $GZIP_CMD -c "$path" > "$rdmnt/$path" 1913555Srscott else 1924213Srscott print "$path" 1933555Srscott fi 1944213Srscott done <"$list" | cpio -pdum "$rdmnt" 2>/dev/null 1955648Ssetje 1965648Ssetje if [ `uname -p` = sparc ] ; then 1975648Ssetje # copy links 1985648Ssetje find $filelist -type l -print 2>/dev/null |\ 1995648Ssetje cpio -pdum "$rdmnt" 2>/dev/null 2005648Ssetje if [ $compress = yes ] ; then 2015648Ssetje # always copy unix uncompressed 2025648Ssetje find $filelist -name unix -type f -print 2>/dev/null |\ 2035648Ssetje cpio -pdum "$rdmnt" 2>/dev/null 2045648Ssetje fi 2055648Ssetje fi 2065648Ssetje 2073555Srscott} 2083555Srscott 2093555Srscott# 2103446Smrj# The first argument can be: 2113446Smrj# 2123446Smrj# "both" - create an archive with both 32-bit and 64-bit binaries 2133446Smrj# "32-bit" - create an archive with only 32-bit binaries 2143446Smrj# "64-bit" - create an archive with only 64-bit binaries 2153446Smrj# 2160Sstevel@tonic-gatefunction create_ufs 2170Sstevel@tonic-gate{ 2183446Smrj which=$1 2193446Smrj archive=$2 2203446Smrj lofidev=$3 2210Sstevel@tonic-gate 2223446Smrj # should we exclude amd64 binaries? 2233446Smrj if [ "$which" = "32-bit" ]; then 2243446Smrj rdfile="$rdfile32" 2253446Smrj rdmnt="$rdmnt32" 2264213Srscott list="$list32" 2273446Smrj elif [ "$which" = "64-bit" ]; then 2283446Smrj rdfile="$rdfile64" 2293446Smrj rdmnt="$rdmnt64" 2304213Srscott list="$list64" 2313446Smrj else 2323446Smrj rdfile="$rdfile32" 2333446Smrj rdmnt="$rdmnt32" 2344213Srscott list="$list32" 2353446Smrj fi 2363446Smrj 2372334Ssetje newfs $lofidev < /dev/null 2> /dev/null 2382334Ssetje mkdir "$rdmnt" 2390Sstevel@tonic-gate mount -F mntfs mnttab /etc/mnttab > /dev/null 2>&1 2402334Ssetje mount -o nologging $lofidev "$rdmnt" 2413446Smrj files= 2420Sstevel@tonic-gate 2430Sstevel@tonic-gate # do the actual copy 2444213Srscott copy_files "$list" 2452334Ssetje umount "$rdmnt" 2462334Ssetje rmdir "$rdmnt" 2472334Ssetje 2485648Ssetje if [ `uname -p` = sparc ] ; then 2495648Ssetje rlofidev=`echo "$lofidev" | sed -e "s/dev\/lofi/dev\/rlofi/"` 2505648Ssetje bb="$ALT_ROOT/usr/platform/`uname -i`/lib/fs/ufs/bootblk" 2515648Ssetje installboot "$bb" $rlofidev 2525648Ssetje fi 2535648Ssetje 2543446Smrj # 2552334Ssetje # Check if gzip exists in /usr/bin, so we only try to run gzip 2562334Ssetje # on systems that have gzip. Then run gzip out of the patch to 2572334Ssetje # pick it up from bfubin or something like that if needed. 2582334Ssetje # 2593446Smrj # If compress is set, the individual files in the archive are 2603446Smrj # compressed, and the final compression will accomplish very 2613446Smrj # little. To save time, we skip the gzip in this case. 2623446Smrj # 2635648Ssetje if [ `uname -p` = i386 ] && [ $compress = no ] && \ 2645734Ssetje [ -x $GZIP_CMD ] ; then 2653446Smrj gzip -c "$rdfile" > "${archive}-new" 2662334Ssetje else 2673446Smrj cat "$rdfile" > "${archive}-new" 2682334Ssetje fi 2690Sstevel@tonic-gate} 2700Sstevel@tonic-gate 2713446Smrj# 2723446Smrj# The first argument can be: 2733446Smrj# 2743446Smrj# "both" - create an archive with both 32-bit and 64-bit binaries 2753446Smrj# "32-bit" - create an archive with only 32-bit binaries 2763446Smrj# "64-bit" - create an archive with only 64-bit binaries 2773446Smrj# 2780Sstevel@tonic-gatefunction create_isofs 2790Sstevel@tonic-gate{ 2803446Smrj which=$1 2813446Smrj archive=$2 2823446Smrj 2830Sstevel@tonic-gate # should we exclude amd64 binaries? 2843446Smrj if [ "$which" = "32-bit" ]; then 2853446Smrj rdmnt="$rdmnt32" 2863446Smrj errlog="$errlog32" 2874213Srscott list="$list32" 2883446Smrj elif [ "$which" = "64-bit" ]; then 2893446Smrj rdmnt="$rdmnt64" 2903446Smrj errlog="$errlog64" 2914213Srscott list="$list64" 2923446Smrj else 2933446Smrj rdmnt="$rdmnt32" 2943446Smrj errlog="$errlog32" 2954213Srscott list="$list32" 2963446Smrj fi 2970Sstevel@tonic-gate 2980Sstevel@tonic-gate # create image directory seed with graft points 2992334Ssetje mkdir "$rdmnt" 3000Sstevel@tonic-gate files= 3013446Smrj isocmd="mkisofs -quiet -graft-points -dlrDJN -relaxed-filenames" 3023446Smrj 3035648Ssetje if [ `uname -p` = sparc ] ; then 3045648Ssetje bb="$ALT_ROOT/usr/platform/`uname -i`/lib/fs/hsfs/bootblk" 3055648Ssetje isocmd="$isocmd -G \"$bb\"" 3065648Ssetje fi 3075648Ssetje 3084213Srscott copy_files "$list" 3092334Ssetje isocmd="$isocmd \"$rdmnt\"" 3102334Ssetje rm -f "$errlog" 3112334Ssetje 3123446Smrj # 3132334Ssetje # Check if gzip exists in /usr/bin, so we only try to run gzip 3142334Ssetje # on systems that have gzip. Then run gzip out of the patch to 3152334Ssetje # pick it up from bfubin or something like that if needed. 3162334Ssetje # 3173446Smrj # If compress is set, the individual files in the archive are 3183446Smrj # compressed, and the final compression will accomplish very 3193446Smrj # little. To save time, we skip the gzip in this case. 3203446Smrj # 3215734Ssetje if [ `uname -p` = i386 ] &&[ $compress = no ] && [ -x $GZIP_CMD ] 3225648Ssetje then 3232334Ssetje ksh -c "$isocmd" 2> "$errlog" | \ 3243446Smrj gzip > "${archive}-new" 3252334Ssetje else 3263446Smrj ksh -c "$isocmd" 2> "$errlog" > "${archive}-new" 3272334Ssetje fi 3282334Ssetje 3295734Ssetje dd_ret=0 3305648Ssetje if [ `uname -p` = sparc ] ; then 3315648Ssetje bb="$ALT_ROOT/usr/platform/`uname -i`/lib/fs/hsfs/bootblk" 3325734Ssetje dd if="$bb" of="${archive}-new" bs=1b oseek=1 count=15 \ 3335734Ssetje conv=notrunc conv=sync >> "$errlog" 2>&1 3345734Ssetje dd_ret=$? 3355648Ssetje fi 3365648Ssetje 3375734Ssetje if [ -s "$errlog" ] || [ $dd_ret -ne 0 ] ; then 3382334Ssetje grep Error: "$errlog" >/dev/null 2>&1 3395734Ssetje if [ $? -eq 0 ] || [ $dd_ret -ne 0 ] ; then 3405734Ssetje cat "$errlog" 3413446Smrj rm -f "${archive}-new" 342174Sjg fi 343174Sjg fi 3442334Ssetje rm -f "$errlog" 3450Sstevel@tonic-gate} 3460Sstevel@tonic-gate 3473446Smrjfunction create_archive 3483446Smrj{ 3493446Smrj which=$1 3503446Smrj archive=$2 3513446Smrj lofidev=$3 3523446Smrj 3535648Ssetje echo "updating $archive" 3543446Smrj 3553446Smrj if [ "$format" = "ufs" ]; then 3563446Smrj create_ufs "$which" "$archive" "$lofidev" 3573446Smrj else 3583446Smrj create_isofs "$which" "$archive" 3593446Smrj fi 3603446Smrj 3613446Smrj # sanity check the archive before moving it into place 3623446Smrj # 3633555Srscott ARCHIVE_SIZE=`ls -l "${archive}-new" | nawk '{ print $5 }'` 3645648Ssetje if [ $compress = yes ] || [ `uname -p` = sparc ] ; then 3653446Smrj # 3663446Smrj # 'file' will report "English text" for uncompressed 3673446Smrj # boot_archives. Checking for that doesn't seem stable, 3683446Smrj # so we just check that the file exists. 3693446Smrj # 3703446Smrj ls "${archive}-new" >/dev/null 2>&1 3713446Smrj else 3723446Smrj # 3733446Smrj # the file type check also establishes that the 3743446Smrj # file exists at all 3753446Smrj # 3763614Ssetje LC_MESSAGES=C file "${archive}-new" | grep gzip > /dev/null 3773446Smrj fi 3783446Smrj 3795734Ssetje if [ $? = 1 ] && [ -x $GZIP_CMD ] || [ $ARCHIVE_SIZE -lt 5000 ] 3803446Smrj then 3813446Smrj # 3823446Smrj # Two of these functions may be run in parallel. We 3833446Smrj # need to allow the other to clean up, so we can't 3843446Smrj # exit immediately. Instead, we set a flag. 3853446Smrj # 3863446Smrj echo "update of $archive failed" 3873446Smrj ERROR=1 3883446Smrj else 3893446Smrj lockfs -f "/$ALT_ROOT" 2>/dev/null 3903446Smrj mv "${archive}-new" "$archive" 3913446Smrj lockfs -f "/$ALT_ROOT" 2>/dev/null 3923446Smrj fi 3933446Smrj 3943446Smrj} 3953446Smrj 3964213Srscottfunction fatal_error 3974213Srscott{ 3984213Srscott print -u2 $* 3994213Srscott exit 1 4004213Srscott} 4014213Srscott 4020Sstevel@tonic-gate# 4030Sstevel@tonic-gate# get filelist 4040Sstevel@tonic-gate# 4053555Srscottif [ ! -f "$ALT_ROOT/boot/solaris/filelist.ramdisk" ] && 4063555Srscott [ ! -f "$ALT_ROOT/etc/boot/solaris/filelist.ramdisk" ] 4072851Sjongkisthen 4082851Sjongkis print -u2 "Can't find filelist.ramdisk" 4092851Sjongkis exit 1 4100Sstevel@tonic-gatefi 4115648Ssetjefilelist=$($EXTRACT_FILELIST $ALTROOT_ARG /boot/solaris/filelist.ramdisk \ 4125648Ssetje /etc/boot/solaris/filelist.ramdisk 2>/dev/null | sort -u) 4130Sstevel@tonic-gate 4144213Srscott# 4154213Srscott# We use /tmp/ for scratch space now. This may be changed later if there 4164213Srscott# is insufficient space in /tmp/. 4174213Srscott# 4184213Srscottrddir="/tmp/create_ramdisk.$$.tmp" 4194213Srscottnew_rddir= 4204213Srscottrm -rf "$rddir" 4214213Srscottmkdir "$rddir" || fatal_error "Could not create temporary directory $rddir" 4224213Srscott 4234213Srscott# Clean up upon exit. 4244213Srscotttrap 'cleanup' EXIT 4254213Srscott 4264213Srscottlist32="$rddir/filelist.32" 4274213Srscottlist64="$rddir/filelist.64" 4284213Srscott 4295648Ssetjetouch $list32 $list64 4305648Ssetje 4314213Srscott# 4324213Srscott# This loop creates the 32-bit and 64-bit lists of files. The 32-bit list 4334213Srscott# is written to stdout, which is redirected at the end of the loop. The 4344213Srscott# 64-bit list is appended with each write. 4354213Srscott# 4364213Srscottcd "/$ALT_ROOT" 4374213Srscottfind $filelist -print 2>/dev/null | while read path 4384213Srscottdo 4394213Srscott if [ $SPLIT = no ]; then 4404213Srscott print "$path" 4414213Srscott elif [ -d "$path" ]; then 4424213Srscott if [ $format = ufs ]; then 4434213Srscott size=`ls -lLd "$path" | nawk ' 4444213Srscott {print ($5 % 1024) ? (int($5 / 1024) + 1) * 1024 : $5}'` 4454213Srscott if [ `basename "$path"` != "amd64" ]; then 4464213Srscott (( dirsize32 += size )) 4474213Srscott fi 4484213Srscott (( dirsize64 += size )) 4494213Srscott fi 4504213Srscott else 451*6006Sdminer case `LC_MESSAGES=C /usr/bin/file -m /dev/null "$path" 2>/dev/null` in 452*6006Sdminer *ELF\ 64-bit*) 4534213Srscott print "$path" >> "$list64" 454*6006Sdminer ;; 455*6006Sdminer *ELF\ 32-bit*) 4564213Srscott print "$path" 457*6006Sdminer ;; 458*6006Sdminer *) 4594213Srscott # put in both lists 4604213Srscott print "$path" 4614213Srscott print "$path" >> "$list64" 462*6006Sdminer esac 4634213Srscott fi 4644213Srscottdone >"$list32" 4652334Ssetje 4662334Ssetjeif [ $format = ufs ] ; then 4672334Ssetje # calculate image size 4682334Ssetje getsize 4692334Ssetje 4702334Ssetje # check to see if there is sufficient space in tmpfs 4712334Ssetje # 4722334Ssetje tmp_free=`df -b /tmp | tail -1 | awk '{ printf ($2) }'` 4732334Ssetje (( tmp_free = tmp_free / 2 )) 4742334Ssetje 4754213Srscott if [ $total_size -gt $tmp_free ] ; then 4762334Ssetje # assumes we have enough scratch space on $ALT_ROOT 4774213Srscott new_rddir="/$ALT_ROOT/create_ramdisk.$$.tmp" 4784213Srscott rm -rf "$new_rddir" 4794213Srscott mkdir "$new_rddir" || fatal_error \ 4804213Srscott "Could not create temporary directory $new_rddir" 4814213Srscott 4824213Srscott # Save the file lists 4834213Srscott mv "$list32" "$new_rddir"/ 4844213Srscott mv "$list64" "$new_rddir"/ 4854213Srscott list32="/$new_rddir/filelist.32" 4864213Srscott list64="/$new_rddir/filelist.64" 4874213Srscott 4884213Srscott # Remove the old $rddir and set the new value of rddir 4894213Srscott rm -rf "$rddir" 4904213Srscott rddir="$new_rddir" 4914213Srscott new_rddir= 4922334Ssetje fi 4932334Ssetjefi 4942334Ssetje 4953446Smrjrdfile32="$rddir/rd.file.32" 4963446Smrjrdfile64="$rddir/rd.file.64" 4973446Smrjrdmnt32="$rddir/rd.mount.32" 4983446Smrjrdmnt64="$rddir/rd.mount.64" 4993446Smrjerrlog32="$rddir/rd.errlog.32" 5003446Smrjerrlog64="$rddir/rd.errlog.64" 5013446Smrjlofidev32="" 5023446Smrjlofidev64="" 5032334Ssetje 5043446Smrjif [ $SPLIT = yes ]; then 5053446Smrj # 5063446Smrj # We can't run lofiadm commands in parallel, so we have to do 5073446Smrj # them here. 5083446Smrj # 5093446Smrj if [ "$format" = "ufs" ]; then 5104213Srscott mkfile ${size32}k "$rdfile32" 5113446Smrj lofidev32=`lofiadm -a "$rdfile32"` 5124213Srscott mkfile ${size64}k "$rdfile64" 5133446Smrj lofidev64=`lofiadm -a "$rdfile64"` 5143446Smrj fi 5153446Smrj create_archive "32-bit" "$ALT_ROOT/$BOOT_ARCHIVE" $lofidev32 & 5163446Smrj create_archive "64-bit" "$ALT_ROOT/$BOOT_ARCHIVE_64" $lofidev64 5173446Smrj wait 5183446Smrj if [ "$format" = "ufs" ]; then 5193446Smrj lofiadm -d "$rdfile32" 5203446Smrj lofiadm -d "$rdfile64" 5213446Smrj fi 5220Sstevel@tonic-gateelse 5233446Smrj if [ "$format" = "ufs" ]; then 5243446Smrj mkfile ${total_size}k "$rdfile32" 5253446Smrj lofidev32=`lofiadm -a "$rdfile32"` 5263446Smrj fi 5273446Smrj create_archive "both" "$ALT_ROOT/$BOOT_ARCHIVE" $lofidev32 5283446Smrj [ "$format" = "ufs" ] && lofiadm -d "$rdfile32" 5290Sstevel@tonic-gatefi 5303446Smrjif [ $ERROR = 1 ]; then 5313446Smrj cleanup 532174Sjg exit 1 533174Sjgfi 534174Sjg 5350Sstevel@tonic-gate# 5360Sstevel@tonic-gate# For the diskless case, hardlink archive to /boot to make it 5370Sstevel@tonic-gate# visible via tftp. /boot is lofs mounted under /tftpboot/<hostname>. 5383446Smrj# NOTE: this script must work on both client and server. 5390Sstevel@tonic-gate# 5402334Ssetjegrep "[ ]/[ ]*nfs[ ]" "$ALT_ROOT/etc/vfstab" > /dev/null 5410Sstevel@tonic-gateif [ $? = 0 ]; then 5423446Smrj rm -f "$ALT_ROOT/boot/boot_archive" "$ALT_ROOT/boot/amd64/boot_archive" 5432334Ssetje ln "$ALT_ROOT/$BOOT_ARCHIVE" "$ALT_ROOT/boot/boot_archive" 5443446Smrj ln "$ALT_ROOT/$BOOT_ARCHIVE_64" "$ALT_ROOT/boot/amd64/boot_archive" 5450Sstevel@tonic-gatefi 5464213Srscott[ -n "$rddir" ] && rm -rf "$rddir" 547