=================================================================== RCS file: /cvs/openbsd/update_openbsd/release.sh,v retrieving revision 1.15 retrieving revision 1.30 diff -u -r1.15 -r1.30 --- openbsd/update_openbsd/release.sh 2008/02/13 16:31:47 1.15 +++ openbsd/update_openbsd/release.sh 2009/12/03 17:28:37 1.30 @@ -1,7 +1,7 @@ #!/bin/sh -# $RedRiver: release.sh,v 1.14 2007/11/20 20:08:31 andrew Exp $ +# $RedRiver: release.sh,v 1.29 2009/04/25 00:14:12 andrew Exp $ # -# Copyright (c) 2002 - 2007 Steven Roberts +# Copyright (c) 2002, 2008 Steven Roberts # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -16,97 +16,153 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # -#TAG="OPENBSD_4_2" +local _origtag=${TAG} +TAG=`uname -sr | tr '[:lower:] .' '[:upper:]_'` KERNEL="GENERIC" -ARCH="i386" +ARCH=`machine` DEST="/home/destdir" RELEASE="/home/releasedir" -XSRCDIR="/usr/src/xenocara" +XSRCDIR="/usr/xenocara" PORTSPATH="/usr/ports" -DEST="/usr/dest" -RELEASE="/usr/release" -TAG=${TAG:=`uname -sr | tr '[:lower:] .' '[:upper:]_'`} -ARCH=`machine` -#SOURCES="src ports XF4" -#SOURCES="src ports" -SOURCES="/usr/src $XSRCDIR $PORTSPATH" - -# Anonymous CVS - http://www.openbsd.org/anoncvs.html -#CVSROOT="anoncvs@anoncvs3.usa.openbsd.org:/cvs" -#CVSROOT="anoncvs@anoncvs1.usa.openbsd.org:/cvs" -CVSROOT="anoncvs@rt.fm:/cvs" +if [ -e /etc/release.conf ]; then + . /etc/release.conf +fi export CVSROOT +if [ X"" != X"${_origtag}" ]; then + TAG=$_origtag +fi + # See http://www.openbsd.org/anoncvs.html for instructions on fetching the # sources for the first time. +empty_dir() { +[ X"" == X"$1" ] && exit +cd $1 || exit + +local _old=`${SUDO} mktemp -d .old.XXXXXXX` +${SUDO} mv -f * .* $_old 2>/dev/null +${SUDO} rm -rf $_old + +sync +} + update_sources() { echo "---------- Update sources ----------" -for d in $SOURCES; do - _cvstag=-r$CVSTAG - if [ X"$CVSTAG" == X"HEAD" ]; then - _cvstag="" - fi - cd $d && cvs -q -z6 update $_cvstag -Pd +local _d +for _d in /usr/src "${XSRCDIR}" "${PORTSPATH}"; do + if [ -d $_d ]; then + echo [$_d] cvs update -r$TAG -Pd + cd $_d && cvs update -r$TAG -Pd || exit 255 + fi done } build_kernel() { echo "---------- Build and install a new kernel ----------" +local _status=0 +unset DESTDIR RELEASEDIR cd /usr/src/sys/arch/$ARCH/conf config $KERNEL cd ../compile/$KERNEL make clean depend && make -cp /bsd /bsd.old && cp bsd / +_status=$? +if [ $_status == 0 ]; then + make install + _status=$? +fi +if [ $_status != 0 ]; then + echo Kernel Build Failed +fi +exit $_status } build_system() { echo "---------- Build a new system ----------" -rm -rf /usr/obj/* +local _status=0 +unset DESTDIR RELEASEDIR +empty_dir /usr/obj & cd /usr/src && nice make obj -cd /usr/src/etc && export DESTDIR=/ && make distrib-dirs -cd /usr/src && nice make build -# Update /etc, /var, and /dev/MAKEDEV by hand. +_status=$? +if [ $_status == 0 ]; then + cd /usr/src/etc && env DESTDIR=/ $SUDO make distrib-dirs + _status=$? +fi +if [ $_status == 0 ]; then + cd /usr/src && nice make SUDO="${SUDO}" build +fi +if [ $_status != 0 ]; then + echo System Build Failed +fi +echo Update /etc, /var, and /dev/MAKEDEV, either by hand or using sysmerge\(8\). +exit $_status } make_system_release() { echo "---------- Make and validate the system release ----------" -cd /usr/src/distrib/crunch && make obj depend && make all install +local _status=0 export DESTDIR=$DEST; export RELEASEDIR=$RELEASE -if (-e $DESTDIR); then - mkdir $DESTDIR/old- - mv $DESTDIR/* $DESTDIR/old- 2>/dev/null - rm -rf $DESTDIR/old- & +if [ X"$DESTDIR" == X"" ]; then + echo PLEASE SET \$DEST! >2& + exit fi mkdir -p $DESTDIR $RELEASEDIR -cd /usr/src/etc && nice make release -cd /usr/src/distrib/sets && sh checkflist +empty_dir $DESTDIR & +cd /usr/src/etc && ${SUDO} nice make release +_status=$? +if [ $_status == 0 ]; then + cd /usr/src/distrib/sets && ${SUDO} sh checkflist + _status=$? +fi unset DESTDIR RELEASEDIR +if [ $_status != 0 ]; then + echo System Release Failed +fi +exit $_status } build_xenocara() { echo "---------- Build and install xenocara ----------" -rm -rf /usr/xobj/* +local _status=0 +unset DESTDIR RELEASEDIR +empty_dir /usr/xobj & cd $XSRCDIR make bootstrap -make obj -make build +_status=$? +if [ $_status == 0 ]; then + make obj + _status=$? +fi +if [ $_status == 0 ]; then + make build + _status=$? +fi +if [ $_status != 0 ]; then + echo Xenocara Build Failed +fi +exit $_status } make_xenocara_release() { echo "---------- Make and validate the xenocara release ----------" -export DESTDIR=$DEST RELEASEDIR=$RELEASE -if (-e $DESTDIR); then - mkdir $DESTDIR/old- - mv $DESTDIR/* $DESTDIR/old- 2>/dev/null - rm -rf $DESTDIR/old- & +local _status=0 +export DESTDIR=$DEST;export RELEASEDIR=$RELEASE +if [ X"$DESTDIR" == X"" ]; then + echo PLEASE SET \$DEST! >2& + exit fi mkdir -p $DESTDIR $RELEASEDIR +empty_dir $DESTDIR & cd $XSRCDIR nice make release +_status=$? unset DESTDIR RELEASEDIR +if [ $_status != 0 ]; then + echo Xenocara Release Failed +fi +exit $_status } usage() { @@ -120,13 +176,12 @@ echo " system-release - Make and validate the system release" echo " xenocara - Build and install xenocara" echo " xenocara-release - Make and validate the xenocara release" +echo " full-release - xenocara, xenocara-release, system, system-release" echo } -if [ $# = 0 ]; then usage; exit 1; fi - -if [ `whoami` != "root" ]; then -echo "You must be root to create a release." +if [ X"" == X"${SUDO}" -a `whoami` != "root" ]; then +echo "You must be root or set SUDO to build a release." exit 1 fi @@ -139,34 +194,39 @@ echo " Kernel: $KERNEL-$ARCH" echo " Dest: $DEST" echo "Release: $RELEASE" +if [ X"$CVSROOT" != X"" ]; then + echo " Root: $CVSROOT" +fi echo +if [ $# = 0 ]; then usage; exit 1; fi + for i in $* do case $i in -full-release) -build_xenocara -build_system -make_xenocara_release -make_system_release -;; update) -update_sources +update_sources || exit 10 ;; kernel) -build_kernel +build_kernel || exit 20 ;; system) -build_system +build_system || exit 30 ;; system-release) -make_system_release +make_system_release || exit 35 ;; xenocara) -build_xenocara +build_xenocara || exit 40 ;; xenocara-release) -make_xenocara_release +make_xenocara_release || exit 45 +;; +full-release) +build_xenocara || exit 51 +make_xenocara_release || exit 52 +build_system || exit 53 +make_system_release || exit 54 ;; *) echo "---------- Abort! Abort! ----------"