version 1.2, 2006/10/11 00:48:15 |
version 1.36, 2014/11/27 21:17:46 |
|
|
#!/bin/sh |
#!/bin/sh |
|
# $AFresh1: release.sh,v 1.35 2014/11/08 20:32:55 andrew Exp $ |
# |
# |
# Copyright (c) 2002 - 2006, FenderQ |
# Copyright (c) 2002, 2008 Steven Roberts <sroberts@fenderq.com> |
# All rights reserved. |
|
# |
# |
# Redistribution and use in source and binary forms, with or without |
# Permission to use, copy, modify, and distribute this software for any |
# modification, are permitted provided that the following conditions are met: |
# purpose with or without fee is hereby granted, provided that the above |
|
# copyright notice and this permission notice appear in all copies. |
# |
# |
# * Redistributions of source code must retain the above copyright |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
# notice, this list of conditions and the following disclaimer. |
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
# * Redistributions in binary form must reproduce the above copyright |
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
# notice, this list of conditions and the following disclaimer in the |
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
# documentation and/or other materials provided with the distribution. |
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
# * Neither the name of FenderQ nor the names of its contributors |
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
# may be used to endorse or promote products derived from this software |
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
# without specific prior written permission. |
|
# |
# |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
# POSSIBILITY OF SUCH DAMAGE. |
|
# |
|
# -------------------------------------------- |
|
# OpenBSD - Release Building Shell Script v3.9 |
|
# |
|
# FenderQ.com - Internet Security Solutions |
|
# http://www.fenderq.com/ |
|
# |
|
# SEE ALSO release(8) |
|
# |
|
|
|
DEST="/usr/dest" |
local _origtag=${TAG} |
RELEASE="/usr/release" |
TAG=`uname -sr | tr '[:lower:] .' '[:upper:]_'` |
CVSTAG="OPENBSD_3_9" |
KERNEL="GENERIC" |
#SOURCES="src ports XF4" |
ARCH=`machine` |
SOURCES="src ports" |
DEST="/home/destdir" |
|
RELEASE="/home/releasedir" |
|
XSRCDIR="/usr/xenocara" |
|
PORTSPATH="/usr/ports" |
|
|
# Anonymous CVS - http://www.openbsd.org/anoncvs.html |
if [ -e /etc/release.conf ]; then |
CVSROOT="anoncvs@anoncvs3.usa.openbsd.org:/cvs" |
. /etc/release.conf |
|
fi |
export CVSROOT |
export CVSROOT |
|
|
install_sources() { |
if [ X"" != X"${_origtag}" ]; then |
echo "********** Install sources **********" |
TAG=$_origtag |
cd /usr |
fi |
for d in $SOURCES; do |
|
rm -rf $d/* |
|
cvs -q -z6 checkout -r$CVSTAG -P $d |
# See http://www.openbsd.org/anoncvs.html for instructions on fetching the |
done |
# 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() { |
update_sources() { |
echo "********** Update sources **********" |
echo "---------- Update sources ----------" |
for d in $SOURCES; do |
local _d |
cd /usr && cvs -q -z6 update -r$CVSTAG -Pd $d |
for _d in /usr/src "${XSRCDIR}" "${PORTSPATH}"; do |
done |
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() { |
build_kernel() { |
echo "********** Build and install a new kernel **********" |
echo "---------- Build and install a new kernel ----------" |
cd /usr/src/sys/arch/i386/conf |
local _status=0 |
config GENERIC |
unset DESTDIR RELEASEDIR |
cd ../compile/GENERIC |
cd /usr/src/sys/arch/$ARCH/conf |
make clean depend && make |
config $KERNEL |
cp /bsd /bsd.old && cp bsd / |
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() { |
build_system() { |
echo "********** Build a new system **********" |
echo "---------- Build a new system ----------" |
rm -rf /usr/obj/* |
local _status=0 |
cd /usr/src && nice make obj |
unset DESTDIR RELEASEDIR |
cd /usr/src/etc && export DESTDIR=/ && make distrib-dirs |
empty_dir /usr/obj & |
cd /usr/src && nice make build |
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_release() { |
make_system_release() { |
echo "********** Make and validate the system release **********" |
echo "---------- Make and validate the system release ----------" |
cd /usr/src/distrib/crunch && make obj depend all install |
if [ X"$DEST" == X"" ]; then |
export DESTDIR=$DEST RELEASEDIR=$RELEASE |
echo PLEASE SET \$DEST! >2& |
rm -rf $DESTDIR |
exit 1 |
mkdir -p $DESTDIR $RELEASEDIR |
fi |
cd /usr/src/etc && nice make release |
|
cd /usr/src/distrib/sets && sh checkflist |
|
unset DESTDIR RELEASEDIR |
|
} |
|
|
|
build_XF4() { |
local _status=0 |
echo "********** Build and install XF4 **********" |
local DESTDIR RELEASEDIR |
rm -rf /usr/Xbuild |
|
mkdir -p /usr/Xbuild |
[ -e $DEST ] && empty_dir $DEST |
cd /usr/ports/lang/tcl/8.4 && make install |
${SUDO} install -d -g wheel -m 775 $DEST $RELEASE |
cd /usr/ports/x11/tk/8.4 && make install |
|
cd /usr/Xbuild && lndir /usr/XF4 && nice make build |
export DESTDIR=$DEST RELEASEDIR=$RELEASE |
|
cd /usr/src/etc && ${SUDO} nice make SUDO="" release |
|
_status=$? |
|
[ $_status == 0 ] && cd /usr/src/distrib/sets && ${SUDO} sh checkflist |
|
_status=$? |
|
|
|
[ $_status == 0 ] || echo System Release Failed |
|
exit $_status |
} |
} |
|
|
make_release_XF4() { |
build_xenocara() { |
echo "********** Make and validate the XF4 release **********" |
echo "---------- Build and install xenocara ----------" |
export DESTDIR=$DEST RELEASEDIR=$RELEASE |
local _status=0 |
rm -rf $DESTDIR |
unset DESTDIR RELEASEDIR |
mkdir -p $DESTDIR $RELEASEDIR |
empty_dir /usr/xobj & |
nice make release |
cd $XSRCDIR |
unset DESTDIR RELEASEDIR |
_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 |
} |
} |
|
|
clean_everything() { |
make_xenocara_release() { |
echo "********** Clean everything **********" |
echo "---------- Make and validate the xenocara release ----------" |
rm -rf /usr/obj/* $DEST /usr/Xbuild |
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() { |
usage() { |
echo "Usage: $0 options" |
echo " Usage: $0 <options>" |
echo |
echo |
echo "Options:" |
echo "Options:" |
echo |
echo |
echo " install - Install sources" |
echo " update - Update sources" |
echo " update - Update sources" |
echo " kernel - Build and install a new kernel" |
echo " kernel - Build and install a new kernel" |
echo " system - Build a new system" |
echo " system - Build a new system" |
echo " system-release - Make and validate the system release" |
echo " release - Make and validate the system release" |
echo " xenocara - Build and install xenocara" |
echo " xwindow - Build and install XF4" |
echo " xenocara-release - Make and validate the xenocara release" |
echo " xwindow-release - Make and validate the XF4 release" |
echo " full - xenocara, xenocara-release, system, system-release" |
echo " clean - Clean everything" |
echo |
echo |
|
} |
} |
|
|
if [ `whoami` != "root" ]; then |
if [ X"" == X"${SUDO}" -a `whoami` != "root" ]; then |
echo "You probably should be root instead of `whoami` to run this safely." |
echo "You must be root or set SUDO to build a release." |
exit 1 |
exit 1 |
fi |
fi |
|
|
START=`date` |
START=`date` |
echo |
echo |
echo "***** OpenBSD - Release Building *****" |
echo ".: release.sh - building an OpenBSD release :." |
|
echo "----------------------------------------------" |
echo |
echo |
echo "Dest: $DEST" |
echo " Tag: $TAG" |
|
echo " Kernel: $KERNEL-$ARCH" |
|
echo " Dest: $DEST" |
echo "Release: $RELEASE" |
echo "Release: $RELEASE" |
echo "CVS Server: $CVSROOT" |
if [ X"$CVSROOT" != X"" ]; then |
echo "CVS Revision Tag: $CVSTAG" |
echo " Root: $CVSROOT" |
|
fi |
echo |
echo |
|
|
if [ $# = 0 ]; then usage; exit 1; fi |
if [ $# = 0 ]; then usage; exit 1; fi |
|
|
for i in $* |
for i in $* |
do |
do |
case $i in |
case $i in |
install) |
update) |
install_sources |
update_sources |
;; |
;; |
update) |
kernel) |
update_sources |
build_kernel |
;; |
;; |
kernel) |
system) |
build_kernel |
build_system |
;; |
;; |
system) |
system-release) |
build_system |
make_system_release |
;; |
;; |
release) |
xenocara) |
make_release |
build_xenocara |
;; |
;; |
xwindow) |
xenocara-release) |
build_XF4 |
make_xenocara_release |
;; |
;; |
xwindow-release) |
full) |
make_release_XF4 |
build_xenocara |
;; |
make_xenocara_release |
clean) |
build_system |
clean_everything |
make_system_release |
;; |
;; |
*) |
*) |
echo "********** Abort! Abort! **********" |
echo "---------- Abort! Abort! ----------" |
echo "Invalid option encountered: $i" |
echo "Invalid option encountered: $i" |
echo "Exiting......." |
echo "Exiting......." |
echo |
echo |
exit 1 |
exit 1 |
;; |
;; |
esac |
esac |
done |
done |
echo |
echo |
echo "Start Time : $START" |
echo " Start Time : $START" |
echo "Finish Time : `date`" |
echo "Finish Time : `date`" |
echo |
echo |