From owner-freebsd-arch Thu Feb 6 21:18: 7 2003 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D8BF337B401 for ; Thu, 6 Feb 2003 21:17:59 -0800 (PST) Received: from protov.plain.co.nz (protov.plain.co.nz [202.36.174.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id D088043F93 for ; Thu, 6 Feb 2003 21:17:48 -0800 (PST) (envelope-from zombie@i4free.co.nz) Received: from i4free.co.nz (ppp65143.cyberxpress.co.nz [202.49.65.143]) by protov.plain.co.nz (Postfix) with ESMTP id CA63E3C27F for ; Fri, 7 Feb 2003 18:17:24 +1300 (NZDT) Message-ID: <3E434150.4070601@i4free.co.nz> Date: Fri, 07 Feb 2003 18:17:04 +1300 From: Andrew Turner User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3a) Gecko/20021212 X-Accept-Language: en-us, en MIME-Version: 1.0 To: arch@freebsd.org Subject: Kernel Dependency finding tool Content-Type: multipart/mixed; boundary="------------010606050505090804060806" Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. --------------010606050505090804060806 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hello, I've beed working on the attached tool to find options/drivers that depend on other options/drivers. It currently removes one option at a time from LINT and tryes to build the kernel sending the output to logs. I have only tested this script on my one FreeBSD box and would like some comments and suggestions to improve the script. Andrew Turner --------------010606050505090804060806 Content-Type: text/plain; name="build_deps.sh" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="build_deps.sh" #!/bin/sh # used to find the way home WD=`pwd`/work if [ ! -d ${WD} ] then mkdir -p ${WD} fi # I_ are the initial settings I_BASE="" I_SRCDIR="/usr/src" I_SYSDIR="/sys" I_ARCH=`uname -m` I_LOGDIR=/var/log/bdeps BASE="" SRCDIR="" SUSDIR="" ARCH="" CONFDIR="" SRCBASE="" LOGDIR="" BUILDSTART=1 BUILDEND=0 LINES="" usage () { NAME=`basename $0` echo "Usage:" echo "${NAME} [OPTIONS]" echo echo "where [OPTIONS] are one or more of:" echo echo "--prefix=" echo " Appends src-prefix to start of src-dir" echo "--srcdir=" echo " The main source directory DEFAULT: ${I_SRCDIR}" echo "--arch=" echo " Cross build for arch (untested) DEFAULT: ${I_ARCH}" echo "--logdir=" echo " Log to log-dir DEFAULT: ${I_LOGDIR}" echo "--start=" echo " Start building on config start-cfg" echo " Intended to be used in a cluster" echo "--end=" echo " End building on config end-cfg" echo "--only-build=" echo " Only build config numbered build-cfg" echo "--clean" echo " Clean the temp files and exit" echo "--clean-logs" echo " Clean the logs and exit" } check_opts () { while test "X$1" != "X" do optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` case "$1" in --prefix=*) echo "Using $optarg as src base" BASE=$optarg shift ;; --arch=*) echo "Building for $optarg" ARCH=$optarg shift ;; --srcdir=*) echo "Using $optarg as Source dir" SRCDIR=$optarg shift ;; --logdir=*) echo "Logging to $optarg" LOGDIR=$optarg shift ;; --start=*) echo "Starting the build with config $optarg" BUILDSTART=$optarg shift ;; --end=*) echo "Ending the build with config $optarg" BUILDEND=$optarg shift ;; --only-build=*) echo "Only building config $optarg" BUILDSTART=$optarg BUILDEND=$optarg shift ;; --clean) CLEAN=1 shift ;; --clean-logs) CLEANLOG=1 shift ;; *) usage exit ;; esac done # set the final values to the Initial if are unset if test "X$BASE" = "X" then BASE=${I_BASE} fi if test "X$ARCH" = "X" then ARCH=${I_ARCH} fi if test "X$SRCDIR" = "X" then SRCDIR=${I_SRCDIR} fi if test "X${SYSDIR}" = "X" then SYSDIR=${I_SYSDIR} fi if test "X${LOGDIR}" = "X" then LOGDIR=${I_LOGDIR} fi CONFDIR=${BASEDIR}${SRCDIR}${SYSDIR}/${ARCH}/conf SRCBASE=${BASEDIR}${SRCDIR} EXIT=0 if test "X${CLEAN}" != "X" then do_clean # Clean the Workdir # rm -fr ${WD} # rm -f ${CONFDIR}/CONFIG.* EXIT=1 fi if test "X${CLEANLOG}" != "X" then rm ${LOGDIR}/* EXIT=1 fi if [ ${EXIT} -ne 0 ] then exit 1 fi } # Clean the workdir and config files do_clean () { rm -fr ${WD} rm -f ${CONFDIR}/CONFIG.* } # Remove all temp files on kill on_trap () { do_clean exit 1 } # Load exit traps on HUP, INT, QUIT and TERM load_traps () { trap on_trap 1 2 3 15 } # Build the LINT config make_lint () { echo "Building the LINT config from NOTES" cd ${CONFDIR} make LINT > /dev/null cd ${WD} } # Copy the LINT config file copy_lint () { echo "Copying LINT file" cp ${CONFDIR}/LINT ${WD} } # Splitd lint into 2 files: # 1) the parts that are needed in all config files # 2) the parts that are changed in each config file split_lint () { echo "Splitting LINT file" # rm -f ${WD}/LINT.all ALL_OPTS="ident machine profile cpu maxusers makeoptions" SOME_OPTS="device options" rm -f ${WD}/LINT.* for opt in $ALL_OPTS do awk "{ if ( \$1 == \"$opt\" ) { print \$0 } }" < LINT >> LINT.all done for opt in $SOME_OPTS do awk "{ if ( \$1 == \"$opt\" ) { print \$0 } }" < LINT >> LINT.some done } # Create the n config files build_configs () { if [ -d ${WD}/configure ] then rm -f ${WD}/configure/CONFIG.* else mkdir ${WD}/configure fi LINES=`cat LINT.some | wc -l | xargs echo` echo "Creating ${LINES} config files" n=0 while [ $n -lt $LINES ] do n=`expr $n + 1` cp ${WD}/LINT.all ${WD}/configure/CONFIG.$n awk "BEGIN { LINE=0 } { LINE++ ; if ( LINE != $n ) { print \$0 } }" < LINT.some >> configure/CONFIG.$n done } copy_configs () { echo "Copying config files to build" cp ${WD}/configure/CONFIG.* ${CONFDIR} } build_kernels () { echo "Building ${LINES} configs" n=`expr $BUILDSTART - 1` if [ $BUILDEND -eq 0 ] then BUILDEND=$LINES elif [ $BUILDEND -gt $LINES ] then BUILDEND=$LINES fi cd ${SRCBASE} while [ $n -lt $BUILDEND ] do n=`expr $n + 1` echo "Building config $n starts at `date`" date > ${LOGDIR}/buildkernel.$n make buildkernel KERNCONF=CONFIG.$n >> ${LOGDIR}/buildkernel.$n 2>&1 if [ $? -ne 0 ] then #touch ${LOGDIR}/fail.$n head -n $n ${WD}/LINT.some | tail -n 1 > ${LOGDIR}/fail.$n else head -n $n ${WD}/LINT.some | tail -n 1 > ${LOGDIR}/pass.$n fi date >> ${LOGDIR}/buildkernel.$n done cd ${WD} } load_traps check_opts $* make_lint copy_lint split_lint build_configs copy_configs build_kernels --------------010606050505090804060806-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message