mkbfu.sh revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
# Make archives suitable for bfu
#
# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
# under certain circumstances, which can really screw things up; unset it.
#
unset CDPATH
echo $* >&2
exit 1
}
# Place a limit on the number of background jobs we can produce at one
# time. The mechanism used is crude; we wait for all jobs to complete
# before continuing. It'd be nice if ksh actually had such a native
# facility.
wait
bgctr=0
if [ -s $errf ]; then
echo "Failed to create\c" >&2
else
echo "Creating\c"
fi
done
fi
}
bgctr=0
# Produce a named archive. Archives always have two names -- the
# first part is an identifier for the archive, the second part is
# 'root' or 'usr' or 'lib' or 'sbin' or 'kernel'.
outf="${arc}.out"
cpioerr="${arc}.cpioerr"
awk '/^[0-9]* blocks$/ { blocks=1; print $0; next }
END {
if (!blocks) {
# Terminate the "echo \c" line above.
print
}
}
ext=
usage="Usage: $0 [-f filter] [-z] proto-dir archive-dir"
prove_you_mean_it="\n\
\n\
Unless invoked directly by makebfu, this script will produce archives with\n\
incorrect permissions which will brickify a system if installed. You most\n\
likely wanted to run makebfu instead; if not, set\n\n\
\t\tI_REALLY_WANT_TO_RUN_MKBFU=YES\n\n\
in your environment and try again.\n\n\n"
while getopts :f:z opt
do
z) compressor="gzip -c"
ext=".gz";;
esac
done
# The extra subshell allows us to wait for cpio to exit completely (rather
# that merely closing stdout) before attempting to examine the stderr output
# file. Otherwise, we'll race with cpio's completion.
cpio='( ( cpio -ocB 2>$cpioerr ); true )'
if [ "$filter" ]; then
fi
if [ "$compressor" ]; then
cpio="$cpio | $compressor"
fi
PROTO=$1
CPIODIR=$2
cd $PROTO
# Create "new style" archives if Zones are present, with lib, sbin and kernel
# in their own archives; otherwise create "old style" archives with everything
# in generic.root
echo "./usr"
echo "./platform"
echo "./lib"
echo "./sbin"
echo "./kernel"
else
echo "./usr"
echo "./platform"
fi
do
done
if [ -d boot ]; then
fi
# If there are any background jobs left, then gather them now.
bgmax=0
fi