[BACK]Return to release.sh CVS log [TXT][DIR] Up to [local] / openbsd / update_openbsd

File: [local] / openbsd / update_openbsd / release.sh (download)

Revision 1.14, Tue Nov 20 20:08:31 2007 UTC (16 years, 6 months ago) by andrew
Branch: MAIN
Changes since 1.13: +144 -158 lines

new release.sh for 4.2.  Seems to work well.

#!/bin/sh
# $RedRiver: release.sh,v 1.13 2007/11/19 22:08:37 andrew Exp $
#
# Copyright (c) 2002 - 2007 Steven Roberts <fenderq@fenderq.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

#TAG="OPENBSD_4_2"
KERNEL="GENERIC"
ARCH="i386"
DEST="/home/destdir"
RELEASE="/home/releasedir"
XSRCDIR="/usr/src/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"
export CVSROOT


# See http://www.openbsd.org/anoncvs.html for instructions on fetching the
# sources for the first time.

update_sources() {
echo "---------- Update sources ----------"
for d in $SOURCES; do
	_cvstag=-r$CVSTAG
	if [ X"$CVSTAG" == X"HEAD" ]; then
		_cvstag=-A
	fi
	cd $d && cvs -q -z6 update $_cvstag -Pd
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
cp /bsd /bsd.old && cp bsd /
}

build_system() {
echo "---------- Build a new system ----------"
rm -rf /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.
}

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
if (-e $DESTDIR); then
	mkdir $DESTDIR/old-
	mv $DESTDIR/* $DESTDIR/old- 2>/dev/null
	rm -rf $DESTDIR/old- &
fi
mkdir -p $DESTDIR $RELEASEDIR
cd /usr/src/etc && nice make release
cd /usr/src/distrib/sets && sh checkflist
unset DESTDIR RELEASEDIR
}

build_xenocara() {
echo "---------- Build and install xenocara ----------"
rm -rf /usr/xobj/*
cd $XSRCDIR
make bootstrap
make obj
make build
}

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- &
fi
mkdir -p $DESTDIR $RELEASEDIR
cd $XSRCDIR
nice make release
unset DESTDIR RELEASEDIR
}

usage() {
echo "  Usage: $0 <options>" 
echo 
echo "Options:"
echo 
echo "  update           - Update sources" 
echo "  kernel           - Build and install a new kernel"
echo "  system           - Build a new system"
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
}

if [ $# = 0 ]; then usage; exit 1; fi

if [ `whoami` != "root" ]; then
echo "You must be root to create a release." 
exit 1
fi

START=`date`
echo
echo ".: release.sh - building an OpenBSD release :."
echo "----------------------------------------------"
echo
echo "    Tag: $TAG"
echo " Kernel: $KERNEL-$ARCH"
echo "   Dest: $DEST"
echo "Release: $RELEASE"
echo

for i in $*
do
case $i in
full-release)
build_xenocara
build_system
make_xenocara_release
make_system_release
;;
case $i in
update)
update_sources
;;
kernel)
build_kernel
;;
system)
build_system
;;
system-release)
make_system_release
;;
xenocara)
build_xenocara
;;
xenocara-release)
make_xenocara_release
;;
*)
echo "---------- Abort! Abort! ----------"
echo "Invalid option encountered: $i"
echo "Exiting......."
echo
exit 1
;; 
esac
done
echo
echo " Start Time : $START"
echo "Finish Time : `date`"
echo