Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 06 Jul 2002 04:37:19 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Garance A Drosihn <drosih@rpi.edu>
Cc:        Paul Richards <paul@freebsd-services.com>, Sheldon Hearn <sheldonh@starjuice.net>, current@FreeBSD.ORG
Subject:   Re: Removing perl in make world
Message-ID:  <3D26D66F.E107F645@mindspring.com>
References:  <1025862341.1573.40.camel@lobster.originative.co.uk> 	 <20020705095258.GC775@starjuice.net>	 <1025864161.1573.45.camel@lobster.originative.co.uk> <p05111730b94b6a140d74@[128.113.24.47]> <3D261EA4.ABC3AEC@mindspring.com> <p05111736b94be16e068e@[128.113.24.47]>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------876B036AE35B5777F5EDA84A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Here are two files that make stateful configuration of world
building somewhat easier.

I expect that the way this will be used is to allow Paul, et. al.
the option of setting a default, and having the system ask users
if they want to live with Paul's default, or if they want to
select their own default instead.

This is a proof of concept; it works on my machine, but obviously
it could be hacked until the end of time, and not everyone would
be satisfied.

Basically, you dump these two files int /usr/src, and then add

	#
	# System configuration
	#     
	.include <Makefile.world>

Before "TGTS=" at the top of /usr/src/Makefile.

It will force you to select options (offerring defaults) for
two example knobs.  It then writes the results to a file called
/etc/world.mk, which is then sucked back in by the Makefile.world,
after it adds a .BEGIN target that causes the file to be rebuilt
if it's missing any options.

Basically, this means that you can incrementally add knobs, and
anyone who builds, instead of getting surprised by the new knobs,
ends up getting asked to select the new knob.

If you are afraid of running from a cron script, you can:

	yes x | make world

or
	make world < /dev/null

And it will select the defaults, or:

	yes n | make world

And it will turn all new knobs off automatically.

You can edit the file by hand if you need/want to; knobs the script
doesn't know about will go away, as will anything other than the
default comments, but the ability is there for knobs it knows about.

The script as written has two default knobs, "PRISTINE" and "BOB";
these are terrible names, but the are only intended as examples (I
expect that the actuall names will be things like "KNOB_DELETE_INCLUDES"
and "KNOB_DELETE_PERL", etc.).

Basically, it ends up being three data lines in a shell script,
per new knob.

Note that I haven't tried a "make release" with this yet; I expect
you will want to copy in the /etc/world.mk from the local system
to do the build, or add the /dev/null redirect to the sub-shell in
the jail for the build.

-- Terry
--------------876B036AE35B5777F5EDA84A
Content-Type: text/plain; charset=us-ascii;
 name="Makefile.world"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="Makefile.world"

# Support mandatory option recording
#
# Original: 06 Jul 2002, Terry Lambert
#
WORLD_CONFIG= /etc/world.mk

.BEGIN:
	@sh ${.CURDIR}/worldconfig.sh ${WORLD_CONFIG}

.if exists(${WORLD_CONFIG})
.include "${WORLD_CONFIG}"
.endif


--------------876B036AE35B5777F5EDA84A
Content-Type: application/x-sh;
 name="worldconfig.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="worldconfig.sh"

#!/bin/sh
#
# worldconfig.sh
#
# Original: 06 Jul 2002, Terry Lambert
#
PROGNAME=`basename $0`

# mandatory shell variables
VARS=""

# ------------------------------------------------------------------------

VARS="PRISTINE $VARS"
DEF_PRISTINE="NO"
MSG_PRISTINE="\
	\tYou must select whether or not to delete header files automatically\n
	\tand recreate them as part of the 'installworld' target.\n"

VARS="BOB $VARS"
DEF_BOB="YES"
MSG_BOB="\
	\tThis is a test\n
	\tThis is only a test\n"

# ------------------------------------------------------------------------

# visual spacing
ONCE=N

#
# Read yes/no from user, with default for no input
#
yesno()
{
	printf "\tThe recommended answer is $2.\n\n"
	printf "\tEnable this option? "
	if [ "$2" = "YES" ]
	then
		echo -n "(YES)/NO : "
		read rdyn
		case $rdyn in
		N*|n*|F*|f*|0)	rdyn="NO" ;;
		*)		rdyn="YES" ;;
		esac
	else
		echo -n "YES/(NO) : "
		read rdyn
		case $rdyn in
		Y*|y*|T*|t*|1)	rdyn="YES" ;;
		*)		rdyn="NO" ;;
		esac
	fi
}

#
# Handle a single element configuration
#
configone()
{
	v_val=`eval echo \\$$1`
	v_def=`eval echo \\$DEF_$1`
	v_msg=`eval echo \\$MSG_$1`

	if [ "${v_val}x" = "x" ]
	then
		if [ "${ONCE}" = "N" ]
		then
			printf "\n\n"
			ONCE=Y
		fi
		printf "$1: No default\n\n"
		printf "${v_msg}\n"
		yesno $1 $v_def
		echo "$1=$rdyn" >> ${CONFIG}
		echo
		echo
	else
		echo "$1=${v_val}" >> ${CONFIG}
	fi
}


#
# err: echo to stderr
#
err()
{
	echo $* >&2
}

fatal()
{
	err "${PROGNAME}: $*"
	exit 1
}

usage()
{
	err "Usage: ${PROGNAME} config"
	exit 1
}


# ------------------------------------------------

# Start
printf "${PROGNAME}: Begin autoselect\n"


#
# Verify 1 argument -- the config file
#
if [ "$1x" = "x" -o "$2x" != "x" ]
then
	usage
fi
CONFIG="$1"
if [ ! -f ${CONFIG} ]
then
	echo "Creating configuration file '${CONFIG}' (first time)"
	touch ${CONFIG}
	if [ "$?" != "0" ]
	then
		fatal "Could not create file ${CONFIG}"
		exit 1
	fi
fi

#
# Pull in the contents of "foo"; if this is the first time, then
# this will do nothing, because the file is empty
#
. ${CONFIG}


#
# Create new file
#
cp ${CONFIG} ${CONFIG}.old
if [ "$?" != "0" ]
then
	fatal "Could not copy '${CONFIG}' to '${CONFIG}.old'"
fi

DATE=`date`
cat > ${CONFIG} <<EOF
# ${DATE}
#
# This file is machine generated.  User added comments, or variables
# unknown to /usr/src/worldconfig.sh will be lost.

EOF

if [ "$?" != "0" ]
then
	fatal "Could not erase old '${CONFIG}'"
fi

#
# Output vars list to config file
#
for v_name in ${VARS}
do
	configone $v_name
done

# End
printf "${PROGNAME}: End autoselect\n"

exit 0

--------------876B036AE35B5777F5EDA84A--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D26D66F.E107F645>