There’s probably a small number of people who’ll find this useful, but this is one of those scripts that I’ve had kicking around for ages that I use daily, so thought it was worth a mention here.

This sets up a developer environment for IPS, pointing $PATH and $PYTHONPATH to the right place. Just run it from anywhere beneath any of your development workspaces, and you’ll be set to run pkg from the proto area of that workspace.

timf@linn[990] echo $PATH
/usr/bin:/usr/sbin:/usr/X11/bin:/export/home/timf/bin:/export/home/timf/script:/opt/SunStudioExpress/bin/:/opt/onbld/bin
timf@linn[991] $(ips-env)
timf@linn[992] echo $PATH
/export/home/timf/projects/ips/pkglint-pkg.hg/proto/root_i386/usr/bin:/usr/bin:/usr/sbin:/usr/X11/bin:/export/home/timf/bin:/export/home/timf/script:/opt/SunStudioExpress/bin/:/opt/onbld/bin
timf@linn[993] echo $PYTHONPATH
/export/home/timf/projects/ips/pkglint-pkg.hg/proto/root_i386/usr/lib/python2.6/vendor-packages
timf@linn[994] cat ~/bin/ips-env
#!/usr/bin/ksh

function find_proto {
	PROTO=""
	while [ -z "$PROTO" ] && [ "$PWD" != "/" ] ; do
		if [ ! -d "$PWD/proto/root_$(uname -p)/usr/lib/python2.6/vendor-packages/pkg" ] ; then
			cd ..
		else
			PROTO=$PWD/proto
		fi
	done
	if [ -d "$PROTO" ] ; then
		echo $PWD/proto
	fi

}

PROTO=$(find_proto)
if [ -z "$PROTO" ] ; then
	echo "No proto found at or above current directory" > /dev/stderr
	exit 2
fi

echo export PYTHONPATH=$PROTO/root_$(uname -p)/usr/lib/python2.6/vendor-packages
echo export PATH=$PROTO/root_$(uname -p)/usr/bin:${PATH}
echo export SRC=$PROTO/../src
timf@linn[995] 

Advertisements