=================================================================== RCS file: /cvs/openbsd/update_openbsd/release.sh,v retrieving revision 1.23 retrieving revision 1.38 diff -u -r1.23 -r1.38 --- openbsd/update_openbsd/release.sh 2008/10/11 23:11:58 1.23 +++ openbsd/update_openbsd/release.sh 2017/02/16 07:08:49 1.38 @@ -1,5 +1,5 @@ #!/bin/sh -# $RedRiver: release.sh,v 1.22 2008/07/08 22:46:01 andrew Exp $ +# $AFresh1: release.sh,v 1.37 2015/11/27 22:36:12 andrew Exp $ # # Copyright (c) 2002, 2008 Steven Roberts # @@ -16,80 +16,195 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # -TAG=${TAG:=`uname -sr | tr '[:lower:] .' '[:upper:]_'`} +local _origtag=${TAG} +TAG=`uname -sr | tr '[:lower:] .' '[:upper:]_'` KERNEL="GENERIC" ARCH=`machine` -DEST="/home/destdir" +DEST="/usr/dest" RELEASE="/home/releasedir" XSRCDIR="/usr/xenocara" PORTSPATH="/usr/ports" +BUILDUSER=build -if [ -e ${HOME}/.releaserc ]; then - . ${HOME}/.releaserc +if [ -e /etc/mk.conf ]; then + . /etc/mk.conf fi +if [ -e /etc/release.conf ]; then + . /etc/release.conf +fi +export CVSROOT +if [ X"" != X"${_origtag}" ]; then + TAG=$_origtag +fi + +if [ X"$DEST" = X"" ]; then + echo PLEASE SET \$DEST! >&2 + exit 1 +fi +if [ X"$RELEASE" = X"" ]; then + echo PLEASE SET \$RELEASE! >&2 + exit 1 +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=`mktemp -d .old.XXXXXXX` +mv -f * .* $_old 2>/dev/null +rm -rf $_old + +sync +} + update_sources() { echo "---------- Update sources ----------" -_cvstag=-r$TAG -if [ X"$TAG" == X"HEAD" ]; then - _cvstag="" -fi -for d in /usr/src ${XSRCDIR} ${PORTSPATH}; do - echo "cd $d && opencvs update $_cvstag -Pd" - cd $d && opencvs update $_cvstag -Pd +local _d +for _d in /usr/src "${XSRCDIR}" "${PORTSPATH}"; do + if [ -d $_d -a -e $_d/CVS ]; then + R="-r$TAG" + [ "$TAG" = "HEAD" ] && R="-A" + echo [$_d] cvs update $R -Pd + cd $_d && cvs update $R -Pd || exit 255 + fi done } build_kernel() { echo "---------- Build and install a new kernel ----------" -cd /usr/src/sys/arch/$ARCH/conf -config $KERNEL -cd ../compile/$KERNEL -make clean depend && make -make install +local _status=0 +unset DESTDIR RELEASEDIR + +cd /usr/src/sys/arch/$ARCH/compile/$KERNEL +_status=$? + +if [ $_status -eq 0 ]; then + make obj && make config && make && make install + _status=$? +fi + +if [ $_status -ne 0 ]; then + echo Kernel Build Failed + exit $_status +fi } build_system() { echo "---------- Build a new system ----------" -rm -rf /usr/obj/* -cd /usr/src && nice make obj -cd /usr/src/etc && env DESTDIR=/ make distrib-dirs -cd /usr/src && nice make build -# Update /etc, /var, and /dev/MAKEDEV by hand. +local _status=0 +unset DESTDIR RELEASEDIR +local DESTDIR RELEASEDIR + +mkdir -p /usr/obj +chown $BUILDUSER:wheel /usr/obj +chmod 755 /usr/obj +empty_dir /usr/obj & + +cd /usr/src +_status=$? + +if [ $_status -eq 0 ]; then + nice make $BUILD_ARGS obj && nice make $BUILD_ARGS build + _status=$? +fi + +if [ $_status -ne 0 ]; then + echo System Build Failed + exit $_status +fi + +echo Update /etc, /var, and /dev/MAKEDEV, either by hand or using sysmerge\(8\). } make_system_release() { echo "---------- Make and validate the system release ----------" -cd /usr/src/distrib/crunch && make obj depend && make all install -export DESTDIR=$DEST; export RELEASEDIR=$RELEASE -rm -rf $DESTDIR + +local _status=0 +local DESTDIR RELEASEDIR + +export DESTDIR=$DEST/base; export RELEASEDIR=$RELEASE mkdir -p $DESTDIR $RELEASEDIR -cd /usr/src/etc && nice make release -cd /usr/src/distrib/sets && sh checkflist +empty_dir $DESTDIR & +chown -R $BUILDUSER:wheel $DESTDIR $RELEASEDIR +chmod -R 700 $DESTDIR $RELEASEDIR + +if [ $_status -eq 0 ]; then + cd /usr/src/etc && nice make release + _status=$? +fi + +if [ $_status -eq 0 ]; then + cd /usr/src/distrib/sets && sh checkflist + _status=$? +fi + unset DESTDIR RELEASEDIR +if [ $_status -ne 0 ]; then + echo System Release Failed + exit $_status +fi } build_xenocara() { echo "---------- Build and install xenocara ----------" -rm -rf /usr/xobj/* +local _status=0 +local DESTDIR RELEASEDIR +unset DESTDIR RELEASEDIR + mkdir -p /usr/xobj +chown $BUILDUSER:wheel /usr/xobj +chmod 755 /usr/xobj +empty_dir /usr/xobj & + cd $XSRCDIR -make bootstrap -make obj -make build +_status=$? + +if [ $_status -eq 0 ]; then + make $BUILD_ARGS bootstrap + _status=$? +fi + +if [ $_status -eq 0 ]; then + make $BUILD_ARGS obj + _status=$? +fi + +if [ $_status -eq 0 ]; then + make $BUILD_ARGS build + _status=$? +fi + +if [ $_status -ne 0 ]; then + echo Xenocara Build Failed + exit $_status +fi } make_xenocara_release() { echo "---------- Make and validate the xenocara release ----------" -export DESTDIR=$DEST RELEASEDIR=$RELEASE -rm -rf $DESTDIR +local _status=0 +local DESTDIR RELEASEDIR + +export DESTDIR=$DEST/xbase; export RELEASEDIR=$RELEASE mkdir -p $DESTDIR $RELEASEDIR -cd $XSRCDIR -nice make release +empty_dir $DESTDIR & +chown -R $BUILDUSER:wheel $DESTDIR $RELEASEDIR +chmod -R 755 $DESTDIR $RELEASEDIR + +if [ $_status -eq 0 ]; then + cd $XSRCDIR && nice make release + _status=$? +fi + unset DESTDIR RELEASEDIR +if [ $_status -ne 0 ]; then + echo Xenocara Release Failed + exit $_status +fi } usage() { @@ -103,14 +218,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 - Do system, xenocara, system-release, xenocara-release" +echo " full - xenocara, xenocara-release, system, system-release" echo -} - if [ `whoami` != "root" ]; then echo "You must be root to build a release." -exit 1 fi +} START=`date` echo @@ -121,19 +234,21 @@ 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 +if [ `whoami` != "root" ]; then +echo "You must be root to build a release." +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 ;; @@ -151,6 +266,12 @@ ;; xenocara-release) make_xenocara_release +;; +full) +build_xenocara +make_xenocara_release +build_system +make_system_release ;; *) echo "---------- Abort! Abort! ----------"