[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.24, Mon Oct 20 22:06:57 2008 UTC (15 years, 7 months ago) by andrew
Branch: MAIN
Changes since 1.23: +23 -20 lines

move the rc file to /etc/releaserc
make the TAG in the environment override the config files
other display changes

#!/bin/sh
# $RedRiver$
#
# Copyright (c) 2002, 2008 Steven Roberts <sroberts@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.
#

local _origtag=${TAG}
TAG=`uname -sr | tr '[:lower:] .' '[:upper:]_'`
KERNEL="GENERIC"
ARCH=`machine`
DEST="/home/destdir"
RELEASE="/home/releasedir"
XSRCDIR="/usr/xenocara"
PORTSPATH="/usr/ports"

if [ -e /etc/releaserc ]; then
    . /etc/releaserc
fi

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.

update_sources() {
echo "---------- Update sources ----------"
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
    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
}

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
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
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 ----------"
cd $XSRCDIR
make bootstrap
make obj
make build
}

make_xenocara_release() {
echo "---------- Make and validate the xenocara release ----------"
export DESTDIR=$DEST RELEASEDIR=$RELEASE
rm -rf $DESTDIR
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 "  full-release     - Do system, xenocara, system-release, xenocara-release"
echo
}

if [ `whoami` != "root" ]; then
echo "You must be root to build 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

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

for i in $*
do
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
;;
full-release)
build_system
build_xenocara
make_xenocara_release
make_system_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