Subject: build.sh wrapper.
To: None <netbsd-users@NetBSD.org>
From: David Rio Deiros <driodeiros@gmail.com>
List: netbsd-users
Date: 03/03/2005 09:31:33
Hi, 

I have recently seen some emails in the list talking about problems 
using build.sh. I had problems too, but after reading some 
docs at netbsd.org everything is working fine now. This are 
the docs:

http://www.netbsd.org/guide/en/
http://www.netbsd.org/Documentation/current/

I have a little script wrapper that is working pretty good
for me. With this script you can update your sources (to 
-current), update the package tree, make a release, compile
the kernel, etc...

Here you have the script. Let me know if it is working for
you or if you have any improvements!

#!/bin/sh

WORKDIR="/home/drio/netbsd"
ARCH="i386"
#CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
CVSROOT="anoncvs@anoncvs2.us.NetBSD.org:/cvsroot"
CVS_RSH="ssh"
export $CVS_RSH

PKG_DIR="/usr/pkgsrc"

#[ ! -d ./src ] && echo "No ./src found" && exit

mkdir -p $WORKDIR/obj
mkdir -p $WORKDIR/tools

case "$1" in

	"recompile_pkgsrc")
		lintpkgsrc -i >/tmp/out_of_date
		pkgdepgraph -D /tmp/out_of_date >/tmp/delete
		pkgdepgraph -R /tmp/out_of_date >/tmp/rebuild
		pkg_delete `cat /tmp/delete`
		sh /tmp/rebuild
	;;	

	"update_pkgsrc")
		cd $PKG_DIR
		#cvs -d $CVSROOT update -Pd pkgsrc
		sudo cvs -d $CVSROOT update -Pd 
		cd -
		;;

	"checkout")
		cvs -d $CVSROOT checkout -A -P src
		;;

	"permissions")
		cd src
		sudo chown -R drio:users .
		sudo chmod -R u=rwX,g=rwX,o=rX .
		cd ..
		;;

	"tools")
		cd src
		./build.sh -O ../obj -T ../tools -U -u -m $ARCH tools
		cd ..
		;;

	"distribution")
		cd src
		./build.sh -O ../obj -T ../tools -U -u -m $ARCH distribution
		cd ..
		;;

	"kernel")
		cd src
		./build.sh -O ../obj -T ../tools -U -u -m $ARCH kernel=GENERIC
		cd ..	
		;;
	
	"world")
		cd src
		./build.sh -O ../obj -T ../tools -U -u -m $ARCH tools
		./build.sh -O ../obj -T ../tools -U -u -m $ARCH distribution
		./build.sh -O ../obj -T ../tools -U -u -m $ARCH kernel=GENERIC
		cd ..
		;;

	"update")
		cd src	
		cvs -d $CVSROOT update -dP
		cd ..
		;;

	"release")
		cd src
   	./build.sh -O ../obj -T ../tools -u -U -m $ARCH release
      cd ..
		;;

	*)
		echo "$0 <option>"
		echo
		echo "recompile_pkgsrc"
		echo "update_pkgsrc"
		echo
		echo "permissions"
		echo "checkout"
		echo "tools"
		echo "distribution"
		echo "kernel"
		echo "world"
		echo "update"
		echo "release"
	;;

esac