head	1.4;
access;
symbols;
locks; strict;
comment	@# @;


1.4
date	92.12.07.11.20.46;	author md;	state Exp;
branches;
next	1.3;

1.3
date	92.11.27.13.49.52;	author md;	state Exp;
branches;
next	1.2;

1.2
date	92.11.12.14.32.49;	author md;	state Exp;
branches;
next	1.1;

1.1
date	88.12.09.22.53.51;	author md;	state Exp;
branches;
next	;


desc
@original version.
@


1.4
log
@oops, checked in wrong program, this is the right one.
@
text
@#!/usr/bin/sed -f
#
# 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1987,1988
# LICENSED MATERIALS - PROPERTY OF IBM
# REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
#
# This sed script converts a MINIMAL kernel config file into
# a MINIROOT kernel config file

# set comments up right
/^#.*[$]Header/s:#: #:
/^#.*[$]Source/s:#: #:
/^#/s:.*::
/^ #/s: #:#:
1i\
\# This is a MINIROOT kernel config file.\
\# It was created from a MINIMAL kernel config file by mkMINIROOT.\
\# $Header: /sys/dist/RCS/mkMINIROOT,v 1.2 1992/11/12 14:32:49 md Exp md $\
\# $ACIS:mkMINIROOT 12.1$\
\# $Source: /sys/dist/RCS/mkMINIROOT,v $

# delete blank lines
/^[ 	]*$/d

# change ident to MINIROOT, maxusers to 1
s:^\(ident[ 	]*\)MINIMAL:\1MINIROOT:
s:^\(maxusers[ 	]*\)[0-9]*:\12:

# insert ROROOT and MINIDISKSIZE options, specify swap on hd0
s:^\(config[ 	]*vmunix[ 	]*\)swap .*:options	"ROROOT=0x0300"\
options NOFPA\
options "NOMC881"\
options NOTCP_DEBUG\
options	"MINIROOTSIZE=2400"\
\1root on fd0 swap on hd0:

# delete unnecessary options, devices, pseudo-devices
/^options[ 	]*VICE[ 	]*/d
/^options[ 	]*DEBUG[ 	]*/d
/^options[ 	]*RDB[ 	]*/d
/^options[ 	]*XWM[ 	]*/d
/^options[ 	]*SECURE[ 	]*/d
/^options[ 	]*MINIMAL[ 	]*/d
/^options[ 	]*GENERIC[ 	]*/d
/^options[ 	]*RVD[ 	]*/d
/^options[ 	]*AFS[ 	]*/d
/^options[ 	]*NFS[ 	]*/d
/^options[ 	]*VFS[ 	]*/d
/^options[ 	]*DFS[ 	]*/d
/^options[ 	]*UCBFIX[ 	]*/d

/^options[ 	]*NS[ 	]*/d
/^options[ 	]*QUOTA[ 	]*/d
/^options[ 	]*ISO[ 	]*/d
/^options[ 	]*TPIP[ 	]*/d
/^options[ 	]*EON[ 	]*/d

/^device[ 	]*asy[014][ 	]*/d
/^device[ 	]*lp0[ 	]*/d
/^device[ 	]*psp0[	 ]*/d
/^device[ 	]*ps0[	 ]*/d
/^device[ 	]*mc0[	 ]*/d

/^pseudo-device[ 	]*ms$/d
/^pseudo-device[ 	]*tb$/d
/^pseudo-device[ 	]*pts$/d
/^pseudo-device[ 	]*pty$/d
/^pseudo-device[ 	]*ap$/d
/^pseudo-device[ 	]*xemul[ 	]*/d
/^pseudo-device[ 	]*vd[ 	]*/d
/^pseudo-device[ 	]*rfs[ 	]*/d
/^pseudo-device[ 	]*sl$/d
/^pseudo-device[ 	]*xtenemul$/d
@


1.3
log
@many changes, mainly to build disk image in /tmp first so we can check
that we don't exceed the size of of the floppy.
@
text
@d1 1
a1 4
#!/bin/sh
# $Header: /sys/dist/RCS/miniroot,v 1.2 1992/03/26 16:47:38 md Exp md $
# $ACIS:miniroot 12.2$
# $Source: /sys/dist/RCS/miniroot,v $
d3 1
a3 1
# 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1986,1987,1988
d7 2
a8 309
#	miniroot - script to build an installation miniroot
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/ibm:.
export PATH
CMD=`basename ${0}`
USAGE="
usage: ${CMD} [options]

available options:
	-f<special>	disk partition to use	[/dev/fd0]
	-m<mdir>	mountpoint to use	[/mnt]
	-k<file>	kernel binary to use	[/sys/MINIROOT/vmunix]
	-d<rdir>	"root" directory tree	[/]
	-local		use local datafiles (eg, /etc/hosts)
"
#
# uses Makefile to make the "local" (miniroot specific) utilities.
# Unless local is specified, tries to use /usr/src versions of datafiles
#
DEVICE=/dev/fd0
RDEVICE=/dev/rfd0
FS=/mnt
VMUNIX=/sys/MINIROOT/vmunix
SRC=/usr/src
ROOT=/
TBUILD=/tmp/mroot.image

for i
do
	case "${i}" in
	-f?*)	DEVICE=`expr "${i}" : '-.\(.*\)'`;;
	-m?*)	FS=`expr "${i}" : '-.\(.*\)'`;;
	-k?*)	VMUNIX=`expr "${i}" : '-.\(.*\)'`;;
	-d?*)	ROOT=`expr "${i}" : '-.\(.*\)'`;;
	-local)	SRC=;;
	*)	echo "${CMD}:${i}:unknown option ${USAGE}" >&2
		exit 1;;
	esac
done

# /etc/services, /etc/protocols, and /etc/disktab are data files that
# may not have had the newest versions installed yet
DATAFILES=
for i in /etc/disktab /etc/protocols /etc/services
do
	if [ ! -f ${ROOT}${SRC}/${i} ]
	then DATAFILES="${DATAFILES} ${ROOT}${i}"
	else DATAFILES="${DATAFILES} ${ROOT}${SRC}/${i}"
	fi
done

echo "${CMD}: checking if all required files exist....." >&2
# /etc/group, /etc/passwd, and /etc/hosts datafiles are stripped.
if [ ! -f ${ROOT}${SRC}/etc/group ]
then
	GROUP=/etc/group
	echo "${CMD}: warning!:using local /etc/group" >&2
else
	GROUP=${ROOT}${SRC}/etc/group
fi

if [ ! -f ${ROOT}${SRC}/etc/passwd ]
then
	PASSWD=/etc/passwd
	echo "${CMD}: warning!:using local /etc/passwd" >&2
else
	PASSWD=${ROOT}${SRC}/etc/passwd
fi

if [ ! -f ${ROOT}${SRC}/etc/hosts ]
then
	HOSTS=/etc/hosts
	echo "${CMD}: warning!:using local /etc/hosts" >&2
else
	HOSTS=${ROOT}${SRC}/etc/hosts
fi

if [ ! -f ${ROOT}${SRC}/dev/MAKEDEV ]
then MAKEDEV=/dev/MAKEDEV
else MAKEDEV=${ROOT}${SRC}/dev/MAKEDEV
fi

BOOT=${ROOT}/usr/mdec/bootfd
BOOTBLOCK=${ROOT}/usr/mdec/fd1.2mboot

# root directory
DIST=/sys/dist

# original /bin files
BIN="${ROOT}/bin/sh ${ROOT}/bin/dd ${ROOT}/bin/expr ${ROOT}/bin/test"

# local /bin files
LOCALBIN="${DIST}/bin/sync.sh ${DIST}/bin/cat.sh ${DIST}/bin/mkdir.sh \
	${DIST}/bin/chmod.sh ${DIST}/bin/echo.sh \
	${DIST}/bin/ln.sh ${DIST}/bin/ls.sh ${DIST}/bin/df.sh \
	${DIST}/bin/rmdir.sh ${DIST}/bin/date.sh ${DIST}/bin/kill.sh"

# orginal /etc files
# ETC="${ROOT}/sbin/fsck ${ROOT}/sbin/restore ${ROOT}/sbin/routed"

# /sbin files
SBIN="${ROOT}/sbin/restore ${ROOT}/sbin/newfs ${ROOT}/sbin/mount"

# local /sbin files
LOCALSBIN="${DIST}/sbin/dtype ${DIST}/sbin/init"

# local /etc files
LOCALETC="${DIST}/etc/onechar ${DIST}/etc/fstab \
	${DIST}/etc/sizeck.sh ${DIST}/etc/whichdev.sh \
	${DIST}/etc/ask.sh ${DIST}/etc/yesno.sh \
	${DIST}/etc/rc.sh ${DIST}/etc/halt.sh ${DIST}/etc/reboot.sh \
	${DIST}/etc/umount.sh ${DIST}/etc/mask.sh \
	${DIST}/etc/mkconfig.sh ${DIST}/etc/syscall ${DIST}/etc/type.sh"

# local /lib files
LOCALLIB="${DIST}/lib/install.driver.sh ${DIST}/lib/install.mainmenu.sh \
	${DIST}/lib/install.options.sh ${DIST}/lib/install.welcome.sh"

# local /usr/bin files
LOCALUSRBIN="${DIST}/usr/bin/sleep.sh ${DIST}/usr/bin/basename.sh"

# local /usr/ucb files
LOCALUCB="${DIST}/usr/ucb/page.sh"

# original /usr/mdec files
MDEC="${ROOT}/usr/mdec/boothd ${ROOT}/usr/mdec/hd* ${ROOT}/usr/mdec/installboot"

# original /usr/ibm files
IBM="${ROOT}/usr/ibm/ftc"

MISSING=
for i in ${VMUNIX} ${DEVICE} ${BOOT} ${BOOTBLOCK} ${DATAFILES} ${GROUP} ${PASSWD} \
        ${HOSTS} ${MAKEDEV} ${BIN} ${LOCALBIN} ${ETC} ${LOCALETC} ${LOCALLIB} \
        ${LOCALUSRBIN} ${LOCALUCB} ${MDEC} ${IBM}
do
	test -f ${i} || MISSING="${MISSING} ${i}"
done

if [ "${MISSING}" ]
then
	echo "${CMD}: cannot find" ${MISSING} >&2
	exit 1
fi

if [ `whoami` != root ]
then
	echo "${CMD}: can only be run by root" >&2
	exit 1
fi

case "${DEVICE}" in
/dev/fd[01])
	# format diskette (fdformat will ask before formatting)
	RDEVICE=`echo ${DEVICE} | sed s'@@fd@@rfd@@'`
	fdformat -h ${RDEVICE};;
esac

# make a bootable file system
while : rebuild filesystem?
do
    echo -n "${CMD}: rebuild filesystem on" ${DEVICE} "?">&2
    read answer
    case $answer in
    	"n")	break;;

    	"y")	${ROOT}/usr/mdec/installboot ${BOOTBLOCK} ${BOOT} ${DEVICE}
		${ROOT}/sbin/newfs ${DEVICE} 
		${ROOT}/sbin/tunefs -m 0 -o space ${DEVICE} 
		break;;

    	*)	echo "Please answer 'y' or 'n'" >&2
		continue;;
    esac
done

echo "${CMD}: checking for a valid filesystem on" ${DEVICE} >&2
if ${ROOT}/sbin/fsck -n ${RDEVICE}
then : all is well
else
	echo "${CMD}: fsck ${RDEVICE} failed" >&2
	exit 1
fi

trap 'EXIT=${?}; cd /; umount ${DEVICE} > /dev/null 2>&1; exit ${EXIT}' 0 1 2 15

# create the temporary build directory
if [ -d ${TBUILD} ]; then
while : remove build tree?
do
    echo -n "${CMD}: the" ${TBUILD} "build directory exist.  Remove it?">&2
    read answer
    case $answer in
    	"n")	break;;

    	"y")	rm -rf ${TBUILD} || exit ${?}
		break;;

    	*)	echo "Please answer 'y' or 'n'" >&2
		continue;;
    esac
done
fi

if mkdir ${TBUILD}
then : all is well
else
	echo "${CMD}: can't create ${TBUILD}" >&2
	exit 1
fi

echo "${CMD}: making build tree in ${TBUILD}......" >&2

# set up the directories; make the device special files
cd ${TBUILD}
chmod 775 .
chgrp staff .
mkdir bin etc sbin dev lib mnt mnt/site tmp usr usr/bin usr/ucb usr/mdec usr/ibm
cd dev
sh -${-} ${MAKEDEV} std st0 fd0 hd0 hd1 hd2 sc0 sc1
cd ..

# install kernel binary, use ${TBUILD} to make install happy
install -c -s ${VMUNIX} ${TBUILD}/vmunix || exit ${?}
ln vmunix boot || exit ${?}

# set up the bin, sbin, etc, usr/bin, usr/ucb, and usr/mdec directories
for i in ${BIN}
do
	install -c ${i} bin/`basename ${i}` || exit ${?}
done
for i in ${LOCALBIN}
do
	install -c ${i} bin/`basename ${i} .sh` || exit ${?}
done

for i in ${SBIN}
do
	j=`basename ${i}`
	install -c ${i} sbin/$j || exit ${?}
done
for i in ${LOCALSBIN}
do
	j=`basename ${i} .sh`
	install -c ${i} sbin/$j || exit ${?}
done
ln sbin/newfs sbin/mfs || exit ${?}

for i in ${LOCALETC}
do
	j=`basename ${i} .sh`
	install -c ${i} etc/$j || exit ${?}
	ln etc/$j sbin/$j
done

for i in ${DATAFILES}
do
	sed '/^#/d' ${i} > etc/`basename ${i} .sh` || exit ${?}
done

# /etc/hosts -> /tmp/hosts -> /etc/hosts.base
# /etc/hosts.base is a minimal /etc/hosts
# when /tmp is mounted on a writable file system,
#	/etc/hosts.base is copied to /etc/hosts -> /tmp/hosts,
#	and we have a writable /etc/hosts
ln -s /tmp/hosts etc/hosts || exit ${?}
ln -s /etc/hosts.base tmp/hosts || exit ${?}
egrep -v '^#' ${HOSTS}			> etc/hosts.base || exit ${?}

# create minimal /etc/group and /etc/passwd
egrep '^wheel:|^staff:'	${GROUP}	> etc/group || exit ${?}
egrep '^root:'		${PASSWD}	> etc/passwd || exit ${?}

for i in ${LOCALUSRBIN}
do
	install -c ${i} usr/bin/`basename ${i} .sh` || exit ${?}
done

for i in ${LOCALUCB}
do
	install -c ${i} usr/ucb/`basename ${i} .sh` || exit ${?}
done

for i in ${MDEC}
do
	install -c ${i} usr/mdec/`basename ${i}` || exit ${?}
done

for i in ${IBM}
do
	install -c ${i} usr/ibm/`basename ${i}` || exit ${?}
done

for i in ${LOCALLIB}
do
	install -c ${i} lib/`basename ${i} .sh` || exit ${?}
done

install -c ${DIST}/restore.tape.sh ${TBUILD}/restore.tape || exit ${?}
install -c ${DIST}/xconf.sh ${TBUILD}/xconf || exit ${?}
#ln restore.tape restore.net || exit ${?}

tsize=`du -ks ${TBUILD} | awk '{ print $1}'`
if [ $tsize -gt 1043 ]; then
	echo "${CMD}: build tree is" $tsize "KB which larger than 1043Kb" >&2
else
	echo "${CMD}: copying build tree (" $tsize "Kb)......" >&2
fi

#exit
d10 64
a73 16
cd /
mount ${DEVICE} ${FS} || exit ${?}
rmdir ${FS}/lost+found 2>/dev/null
cd ${TBUILD}
find . -depth -print | cpio -pdlmv ${FS} || exit ${?}
sync; sync
cd /
df ${DEVICE}
umount ${DEVICE}
if fsck -n ${RDEVICE}
then : fsck succeeded
	echo "${CMD}: completed successfully" >&2
else
	echo "${CMD}: fsck ${RDEVICE} failed" >&2
	exit 1
fi
@


1.2
log
@-md
@
text
@d1 4
a4 1
#!/usr/bin/sed -f
d6 1
a6 1
# 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1987,1988
d10 309
a318 2
# This sed script converts a GENERIC kernel config file into
# a MINIROOT kernel config file
d320 16
a335 56
# set comments up right
/^#.*[$]Header/s:#: #:
/^#.*[$]Source/s:#: #:
/^#/s:.*::
/^ #/s: #:#:
1i\
\# This is a MINIROOT kernel config file.\
\# It was created from a GENERIC kernel config file by mkMINIROOT.\
\# $Header: /sys/dist/RCS/mkMINIROOT,v 1.1 1988/12/09 22:53:51 md Exp md $\
\# $ACIS:mkMINIROOT 12.1$\
\# $Source: /sys/dist/RCS/mkMINIROOT,v $

# delete blank lines
/^[ 	]*$/d

# change ident to MINIROOT, maxusers to 1
s:^\(ident[ 	]*\)GENERIC:\1MINIROOT:
s:^\(maxusers[ 	]*\)[0-9]*:\11:

# insert ROROOT and MINIDISKSIZE options, specify swap on hd0
s:^\(config[ 	]*vmunix[ 	]*\)swap .*:options	"ROROOT=0x0300"\
options NOFPA\
options "NOMC881"\
options NOTCP_DEBUG\
options	"MINIROOTSIZE=2400"\
\1root on fd0 swap on hd0:

# delete unnecessary options, devices, pseudo-devices
/^options[ 	]*VICE[ 	]*/d
/^options[ 	]*DEBUG[ 	]*/d
/^options[ 	]*RDB[ 	]*/d
/^options[ 	]*XWM[ 	]*/d
/^options[ 	]*SECURE[ 	]*/d
/^options[ 	]*GENERIC[ 	]*/d
/^options[ 	]*RVD[ 	]*/d
/^options[ 	]*AFS[ 	]*/d
/^options[ 	]*NFS[ 	]*/d
/^options[ 	]*VFS[ 	]*/d
/^options[ 	]*DFS[ 	]*/d
/^options[ 	]*UCBFIX[ 	]*/d

/^device[ 	]*asy[014][ 	]*/d
/^device[ 	]*lp0[ 	]*/d
/^device[ 	]*psp0[	 ]*/d
/^device[ 	]*ps0[	 ]*/d
/^device[ 	]*mc0[	 ]*/d

/^pseudo-device[ 	]*ms$/d
/^pseudo-device[ 	]*pty$/d
/^pseudo-device[ 	]*tb$/d
/^pseudo-device[ 	]*ap$/d
/^pseudo-device[ 	]*xemul[ 	]*/d
/^pseudo-device[ 	]*vd[ 	]*/d
/^pseudo-device[ 	]*rfs[ 	]*/d
/^pseudo-device[ 	]*sl$/d
/^pseudo-device[ 	]*xtenemul$/d
@


1.1
log
@Initial revision
@
text
@d1 1
a1 1
#!/bin/sed -f
d18 1
a18 1
\# $Header:mkMINIROOT 12.1$\
d20 1
a20 1
\# $Source: /ibm/acis/usr/sys/dist/RCS/mkMINIROOT,v $
@
