[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.33, Mon Nov 1 22:39:44 2010 UTC (13 years, 6 months ago) by andrew
Branch: MAIN
Changes since 1.32: +3 -3 lines

easier to type

#!/bin/sh
# $AFresh1: release.sh,v 1.33 2010/11/01 22:39:44 andrew Exp $
#
# 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/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 ----------"
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
_status=$?
if [ $_status == 0 ]; then
    make install
    _status=$?
fi
if [ $_status != 0 ]; then 
    echo Kernel Build Failed
    exit $_status
fi
}

build_system() {
echo "---------- Build a new system ----------"
local _status=0
unset DESTDIR RELEASEDIR
empty_dir /usr/obj &
cd /usr/src && nice make obj
_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
    exit $_status
else 
    echo Update /etc, /var, and /dev/MAKEDEV, either by hand or using sysmerge\(8\).
fi
}

make_system_release() {
echo "---------- Make and validate the system release ----------"
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 /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
    exit $_status
fi
}

build_xenocara() {
echo "---------- Build and install xenocara ----------"
local _status=0
unset DESTDIR RELEASEDIR
empty_dir /usr/xobj &
cd $XSRCDIR
_status=$?
if [ $_status == 0 ]; then 
    make bootstrap
    _status=$?
fi
if [ $_status == 0 ]; then 
    make obj
    _status=$?
fi
if [ $_status == 0 ]; then 
    make build
    _status=$?
fi
if [ $_status != 0 ]; then 
    echo Xenocara Build Failed
    exit $_status
fi
}

make_xenocara_release() {
echo "---------- Make and validate the xenocara release ----------"
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
_status=$?
if [ $_status == 0 ]; then 
    nice make release
    _status=$?
fi
unset DESTDIR RELEASEDIR
if [ $_status != 0 ]; then 
    echo Xenocara Release Failed
    exit $_status
fi
}

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             - xenocara, xenocara-release, system, system-release"
echo
}

if [ X"" == X"${SUDO}" -a `whoami` != "root" ]; then
echo "You must be root or set SUDO 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"
if [ X"$CVSROOT" != X"" ]; then
	echo "   Root: $CVSROOT"
fi
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)
build_xenocara
make_xenocara_release
build_system
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