option_survey.sh revision 272461
1219820Sjeff#!/bin/sh
2219820Sjeff# This file is in the public domain
3219820Sjeff# $FreeBSD: releng/10.1/tools/tools/build_option_survey/option_survey.sh 157118 2006-03-25 10:50:40Z phk $
4219820Sjeff
5219820Sjeffset -ex
6219820Sjeff
7219820SjeffOPLIST=`sh listallopts.sh`
8219820Sjeff
9219820SjeffMDUNIT=47
10219820Sjeffexport MDUNIT
11219820Sjeff
12219820SjeffODIR=/usr/obj/`pwd`
13219820SjeffFDIR=${ODIR}/files
14219820SjeffMNT=${ODIR}/_.mnt
15219820SjeffRDIR=${ODIR}/_.result
16219820Sjeff
17219820Sjeffexport ODIR MNT RDIR FDIR
18219820Sjeff
19219820Sjeffbw ( ) (
20219820Sjeff	cd ../../.. 
21219820Sjeff	make showconfig \
22219820Sjeff		SRCCONF=${ODIR}/src.conf __MAKE_CONF=/dev/null \
23219820Sjeff		> ${FDIR}/_.sc 2>&1
24219820Sjeff	a=$?
25219820Sjeff	echo retval $a
26219820Sjeff	if [ $a -ne 0 ] ; then
27219820Sjeff		exit 1
28219820Sjeff	fi
29219820Sjeff	make -j 4 buildworld \
30219820Sjeff		SRCCONF=${ODIR}/src.conf __MAKE_CONF=/dev/null \
31219820Sjeff		> ${FDIR}/_.bw 2>&1
32219820Sjeff	a=$?
33219820Sjeff	echo retval $a
34219820Sjeff	if [ $a -ne 0 ] ; then
35219820Sjeff		exit 1
36219820Sjeff	fi
37219820Sjeff	make -j 4 buildkernel \
38219820Sjeff		KERNCONF=GENERIC \
39219820Sjeff		SRCCONF=${ODIR}/src.conf __MAKE_CONF=/dev/null \
40219820Sjeff		> ${FDIR}/_.bk 2>&1
41219820Sjeff	a=$?
42219820Sjeff	echo retval $a
43219820Sjeff	if [ $a -ne 0 ] ; then
44219820Sjeff		exit 1
45219820Sjeff	fi
46219820Sjeff	exit 0
47219820Sjeff)
48219820Sjeff
49219820Sjeffiw ( ) (
50219820Sjeff	trap "umount ${MNT} || true" 1 2 15 EXIT
51219820Sjeff	newfs -O1 -U -b 4096 -f 512 /dev/md$MDUNIT
52219820Sjeff	mkdir -p ${MNT}
53219820Sjeff	mount /dev/md${MDUNIT} ${MNT}
54219820Sjeff
55219820Sjeff	cd ../../..
56219820Sjeff	make installworld \
57219820Sjeff		SRCCONF=${ODIR}/src.conf __MAKE_CONF=/dev/null \
58219820Sjeff		DESTDIR=${MNT} \
59219820Sjeff		> ${FDIR}/_.iw 2>&1
60219820Sjeff	a=$?
61219820Sjeff	echo retval $a
62219820Sjeff	if [ $a -ne 0 ] ; then
63219820Sjeff		exit 1
64219820Sjeff	fi
65219820Sjeff	cd etc
66219820Sjeff	make distribution \
67219820Sjeff		SRCCONF=${ODIR}/src.conf __MAKE_CONF=/dev/null \
68219820Sjeff		DESTDIR=${MNT} \
69219820Sjeff		> ${FDIR}/_.etc 2>&1
70219820Sjeff	a=$?
71219820Sjeff	echo retval $a
72219820Sjeff	if [ $a -ne 0 ] ; then
73219820Sjeff		exit 1
74219820Sjeff	fi
75219820Sjeff	cd ..
76219820Sjeff	make installkernel \
77219820Sjeff		KERNCONF=GENERIC \
78219820Sjeff		DESTDIR=${MNT} \
79219820Sjeff		SRCCONF=${ODIR}/src.conf __MAKE_CONF=/dev/null \
80219820Sjeff		> ${FDIR}/_.ik 2>&1
81219820Sjeff	a=$?
82219820Sjeff	echo retval $a
83219820Sjeff	if [ $a -ne 0 ] ; then
84219820Sjeff		exit 1
85219820Sjeff	fi
86219820Sjeff
87219820Sjeff	sync ${MNT}
88219820Sjeff	( cd ${MNT} && mtree -c ) > ${FDIR}/_.mtree
89219820Sjeff	( cd ${MNT} && du ) > ${FDIR}/_.du
90219820Sjeff	( df -i ${MNT} ) > ${FDIR}/_.df
91219820Sjeff	echo success > ${FDIR}/_.success
92219820Sjeff	sync
93219820Sjeff	sleep 1
94219820Sjeff	sync
95219820Sjeff	sleep 1
96219820Sjeff	trap "" 1 2 15 EXIT
97219820Sjeff	umount ${MNT}
98219820Sjeff	echo "iw done"
99219820Sjeff)
100219820Sjeff
101219820Sjeff
102219820Sjeff# Clean and recreate the ODIR
103219820Sjeff
104219820Sjeffif true ; then 
105219820Sjeff	echo "=== Clean and recreate ${ODIR}"
106219820Sjeff	if rm -rf ${ODIR} ; then
107219820Sjeff		true
108219820Sjeff	else
109219820Sjeff		chflags -R noschg ${ODIR}
110219820Sjeff		rm -rf ${ODIR}
111219820Sjeff	fi
112219820Sjeff	mkdir -p ${ODIR} ${FDIR} ${MNT}
113219820Sjeff
114219820Sjefffi
115219820Sjeff
116219820Sjefftrap "umount ${MNT} || true; mdconfig -d -u $MDUNIT" 1 2 15 EXIT
117219820Sjeff
118219820Sjeffumount $MNT || true
119219820Sjeffmdconfig -d -u $MDUNIT || true
120219820Sjeffdd if=/dev/zero of=${ODIR}/imgfile bs=1m count=250 
121219820Sjeffmdconfig -a -t vnode -f ${ODIR}/imgfile -u $MDUNIT
122219820Sjeff
123219820Sjeff# Build & install the reference world
124219820Sjeff
125219820Sjeffif true ; then 
126219820Sjeff	echo "=== Build reference world"
127219820Sjeff	echo '' > ${ODIR}/src.conf
128219820Sjeff	MAKEOBJDIRPREFIX=$ODIR/_.ref 
129219820Sjeff	export MAKEOBJDIRPREFIX
130219820Sjeff	bw
131219820Sjeff	echo "=== Install reference world"
132219820Sjeff	mkdir -p ${RDIR}/Ref
133219820Sjeff	iw
134219820Sjeff	mv ${FDIR}/_.* ${RDIR}/Ref
135219820Sjefffi
136219820Sjeff
137219820Sjeff# Parse option list into subdirectories with src.conf files.
138219820Sjeff
139219820Sjeffif true ; then
140219820Sjeff	rm -rf ${RDIR}/[0-9a-f]*
141219820Sjeff	for o in $OPLIST
142219820Sjeff	do
143219820Sjeff		echo "${o}=foo" > ${FDIR}/_src.conf
144219820Sjeff		m=`md5 < ${FDIR}/_src.conf`
145219820Sjeff		mkdir -p ${RDIR}/$m
146219820Sjeff		mv ${FDIR}/_src.conf ${RDIR}/$m/src.conf
147219820Sjeff	done
148219820Sjefffi
149219820Sjeff
150219820Sjeff# Run through each testtarget in turn
151219820Sjeff
152219820Sjeffif true ; then
153219820Sjeff	for d in ${RDIR}/[0-9a-z]*
154219820Sjeff	do
155219820Sjeff		if [ ! -d $d ] ; then
156219820Sjeff			continue;
157219820Sjeff		fi
158219820Sjeff		echo '------------------------------------------------'
159219820Sjeff		cat $d/src.conf
160219820Sjeff		echo '------------------------------------------------'
161219820Sjeff		cp $d/src.conf ${ODIR}/src.conf
162219820Sjeff
163219820Sjeff		if [ ! -f $d/iw/done ] ; then
164219820Sjeff			MAKEOBJDIRPREFIX=$ODIR/_.ref
165219820Sjeff			export MAKEOBJDIRPREFIX
166219820Sjeff			echo "# BW(ref)+IW(ref) `cat $d/src.conf`"
167219820Sjeff			rm -rf $d/iw
168219820Sjeff			mkdir -p $d/iw
169219820Sjeff			iw || true
170219820Sjeff			mv ${FDIR}/_.* $d/iw || true
171219820Sjeff			touch $d/iw/done
172219820Sjeff		fi
173219820Sjeff		if [ ! -f $d/bw/done ] ; then
174219820Sjeff			MAKEOBJDIRPREFIX=$ODIR/_.tst 
175219820Sjeff			export MAKEOBJDIRPREFIX
176219820Sjeff			echo "# BW(opt) `cat $d/src.conf`"
177219820Sjeff			rm -rf $d/w $d/bw
178219820Sjeff			mkdir -p $d/w $d/bw
179219820Sjeff			if bw ; then
180219820Sjeff				mv ${FDIR}/_.* $d/bw || true
181219820Sjeff
182219820Sjeff				echo "# BW(opt)+IW(opt) `cat $d/src.conf`"
183219820Sjeff				iw || true
184219820Sjeff				mv ${FDIR}/_.* $d/w || true
185219820Sjeff				touch $d/w/done
186219820Sjeff
187219820Sjeff				echo "# BW(opt)+IW(ref) `cat $d/src.conf`"
188219820Sjeff				echo '' > ${ODIR}/src.conf
189219820Sjeff				iw || true
190219820Sjeff				mv ${FDIR}/_.* $d/bw || true
191219820Sjeff				touch $d/bw/done
192219820Sjeff			else
193219820Sjeff				mv ${FDIR}/_.* $d/bw || true
194219820Sjeff				touch $d/bw/done $d/w/done
195219820Sjeff			fi
196219820Sjeff		fi
197219820Sjeff	done
198219820Sjefffi
199219820Sjeff