[comp.unix.wizards] Building a 4.3BSD kernel under 4.2

hoey@nrl-aic.arpa (Dan Hoey) (08/22/87)

Our upgrade path to 4.3 is to build the kernel under 4.2, then slide it
in.  But we have a few jimmies sprinkled on our vanilla sources, so I
have to patch them.  Last thing before patching, I decided to make sure
I could correctly use the 4.3 cc, ld, /usr/include, etc. to build a 4.3
kernel.  The test I decided on was to try to build an exact copy of the
distributed 4.3 GENERIC kernel.

So I mv'ed /4.3/GENERIC to /4.3/origGENERIC, and started building,
using ``cmp -l'' and ``nm -n'' to check for differences between
/4.3/{orig,}GENERIC/vmunix.  I had to edit my /4.3/GENERIC/version so
that /4.3/{orig,}GENERIC/vers.c would have the same length.  (I changed
it to "2               \n" though your mileage may differ).  The
hardest part was figuring out that I needed the 4.3 version of
/usr/ucb/symorder.  Why is some random ucb binary needed to make the
kernel?  RTFM.  But why did they change it for 4.3?  I couldn't tell
you, but it definitely makes a difference in the order of symbol table
entries.  I'm not sure I needed to link all the other files, but they
seemed likely.  Anyway, I succeeded in building a kernel for which the
only differences were in the version strings.

Here is a shell script I use to install the 4.3 tools needed to compile
the kernel, and it may be useful to you if you want to build a 4.3
kernel under 4.2.  The only tailoring you will need is to change the
definition of NEW to the place you put the 4.3 tools.  Oh, and you
might want to warn your users that for the duration of the tests they
shouldn't trust the C compiler, due to possible version skew between
/usr/include and /usr/lib and your running system.

Dan Hoey
HOEY@NRL-AIC.ARPA

#! /bin/sh
#
# 4.3mode: Install enough tools to build 4.3 kernel on 4.2 system.
# Do "init" before anything else, "undo" before redoing "init".
# Make changes in FILES only with "4.3mode undo"ne
#
# 4.3mode init -- sets up symbolic links
# 4.3mode on   -- switches links to 4.3 copies
# 4.3mode off  -- switches links back to 4.2 copies
# 4.3mode undo -- undoes the symbolic links
#
# Set NEW to where you have put part of your 4.3 directory tree,
# including all files in FILES.
#
NEW="/aic3/4.3utils/"
FILES="	lib usr/include sys usr/sys bin/as bin/cc bin/ld	\
	etc/config usr/lib/gcrt0.o usr/ucb/symorder"

NEEDBACK="! -r";RM="rm";	MV="mv"
LN="ln -s";	LNP="/";	LNS=".4.2"

case "$1" in
init)	NEEDBACK="-r";	RM="false";	MVT=".4.2";;
undo)	LN="false";	MVF=".4.2";;
on)	MV="false";	LNP="${NEW}";	LNS="";;
off)	MV="false";;
*)	echo "Usage: $0 init|on|off|undo";	exit 1;;
esac

for F in ${FILES}
do  if [ '(' ! -r /${F} ')' -o '(' ! -r ${NEW}${F} ')' -o \
	 '(' ${NEEDBACK} /${F}.4.2 ')' ]
    then echo "Problem with /${F}, /${F}.4.2, or ${NEW}${F}"
	 ABORT="exit 1"
    fi
done
${ABORT}

for F in ${FILES}
do  ${RM} /${F}
    ${MV} /${F}${MVF} /${F}${MVT}
    ${LN} ${LNP}${F}${LNS} /${F}
done

krishnan@hplabsb.UUCP (N K Krishnan) (08/22/87)

Or you could use a spare file system, mount the 4.3 root file system there,
and chroot to it.  As long as you do not use the csh after you get chrooted
you should be ok.  I had to write a real short program to chroot and exec
/bin/sh.

chris@mimsy.UUCP (Chris Torek) (08/22/87)

In article <8943@brl-adm.ARPA> hoey@nrl-aic.arpa (Dan Hoey) writes:
>... The hardest part was figuring out that I needed the 4.3 version of
>/usr/ucb/symorder.  Why is some random ucb binary needed to make the
>kernel?  RTFM.  But why did they change it for 4.3? ...

It was broken in 4.3alpha, and may have been broken in 4.2BSD.  I
forget the details (even though I found the bug) but it occurred
very rarely.  Perhaps the generic kernel got lucky.

You can boot a kernel without symordering it, but some utilities
will run slower.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
Domain:	chris@mimsy.umd.edu	Path:	seismo!mimsy!chris