| version 1.12, 2007/09/09 22:40:41 | version 1.15, 2008/02/13 16:31:47 | 
|  |  | 
| #!/bin/sh | #!/bin/sh | 
| # $RedRiver: release.sh,v 1.11 2007/05/04 20:57:34 andrew Exp $ | # $RedRiver: release.sh,v 1.14 2007/11/20 20:08:31 andrew Exp $ | 
| # Copyright (c) 2002 - 2006, FenderQ |  | 
| # All rights reserved. |  | 
| # | # | 
| # Redistribution and use in source and binary forms, with or without | # Copyright (c) 2002 - 2007 Steven Roberts <fenderq@fenderq.com> | 
| # modification, are permitted provided that the following conditions are met: |  | 
| # | # | 
| #   * Redistributions of source code must retain the above copyright | # Permission to use, copy, modify, and distribute this software for any | 
| #     notice, this list of conditions and the following disclaimer. | # purpose with or without fee is hereby granted, provided that the above | 
| #   * Redistributions in binary form must reproduce the above copyright | # copyright notice and this permission notice appear in all copies. | 
| #     notice, this list of conditions and the following disclaimer in the |  | 
| #     documentation and/or other materials provided with the distribution. |  | 
| #   * Neither the name of FenderQ nor the names of its contributors |  | 
| #     may be used to endorse or promote products derived from this software |  | 
| #     without specific prior written permission. |  | 
| # | # | 
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 
| # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 
| # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 
| # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 
| # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 
| # 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) |  | 
| # |  | 
|  |  | 
|  | #TAG="OPENBSD_4_2" | 
|  | KERNEL="GENERIC" | 
|  | ARCH="i386" | 
|  | DEST="/home/destdir" | 
|  | RELEASE="/home/releasedir" | 
|  | XSRCDIR="/usr/src/xenocara" | 
|  | PORTSPATH="/usr/ports" | 
|  |  | 
| DEST="/usr/dest" | DEST="/usr/dest" | 
| RELEASE="/usr/release" | RELEASE="/usr/release" | 
| CVSTAG=${CVSTAG:=`uname -sr | tr '[:lower:] .' '[:upper:]_'`} | TAG=${TAG:=`uname -sr | tr '[:lower:] .' '[:upper:]_'`} | 
|  | ARCH=`machine` | 
| #SOURCES="src ports XF4" | #SOURCES="src ports XF4" | 
| #SOURCES="src ports" | #SOURCES="src ports" | 
| SOURCES="src ports XF4" | SOURCES="/usr/src $XSRCDIR $PORTSPATH" | 
|  |  | 
| # Anonymous CVS - http://www.openbsd.org/anoncvs.html | # Anonymous CVS - http://www.openbsd.org/anoncvs.html | 
| CVSROOT="anoncvs@anoncvs3.usa.openbsd.org:/cvs" | #CVSROOT="anoncvs@anoncvs3.usa.openbsd.org:/cvs" | 
|  | #CVSROOT="anoncvs@anoncvs1.usa.openbsd.org:/cvs" | 
|  | CVSROOT="anoncvs@rt.fm:/cvs" | 
| export CVSROOT | export CVSROOT | 
|  |  | 
| install_sources() { |  | 
| echo "********** Install sources **********" |  | 
| cd /usr |  | 
| for d in $SOURCES; do |  | 
| rm -rf $d/* |  | 
| cvs -q -z6 checkout -r$CVSTAG -P $d |  | 
| done |  | 
| } |  | 
|  |  | 
|  | # See http://www.openbsd.org/anoncvs.html for instructions on fetching the | 
|  | # sources for the first time. | 
|  |  | 
| update_sources() { | update_sources() { | 
| echo "********** Update sources **********" | echo "---------- Update sources ----------" | 
| for d in $SOURCES; do | for d in $SOURCES; do | 
| _cvstag=-r$CVSTAG | _cvstag=-r$CVSTAG | 
| if [ X"$CVSTAG" == X"HEAD" ]; then | if [ X"$CVSTAG" == X"HEAD" ]; then | 
| _cvstag=-A | _cvstag="" | 
| fi | fi | 
| cd /usr && cvs -q -z6 update $_cvstag -Pd $d | cd $d && cvs -q -z6 update $_cvstag -Pd | 
| done | 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 | cd /usr/src/sys/arch/$ARCH/conf | 
| config GENERIC | config $KERNEL | 
| cd ../compile/GENERIC | cd ../compile/$KERNEL | 
| make clean depend && make | make clean depend && make | 
| cp /bsd /bsd.old && cp bsd / | cp /bsd /bsd.old && cp bsd / | 
| } | } | 
|  |  | 
| build_system() { | build_system() { | 
| echo "********** Build a new system **********" | echo "---------- Build a new system ----------" | 
| rm -rf /usr/obj/* | rm -rf /usr/obj/* | 
| cd /usr/src && nice make obj | cd /usr/src && nice make obj | 
| cd /usr/src/etc && export DESTDIR=/ && make distrib-dirs | cd /usr/src/etc && export DESTDIR=/ && make distrib-dirs | 
| cd /usr/src && nice make build | cd /usr/src && nice make build | 
|  | # Update /etc, /var, and /dev/MAKEDEV by hand. | 
| } | } | 
|  |  | 
| 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 | cd /usr/src/distrib/crunch && make obj depend && make all install | 
| export DESTDIR=$DEST RELEASEDIR=$RELEASE | export DESTDIR=$DEST; export RELEASEDIR=$RELEASE | 
| rm -rf $DESTDIR/* | if (-e $DESTDIR); then | 
| mkdir -p $DESTDIR $RELEASEDIR | mkdir $DESTDIR/old- | 
| cd /usr/src/etc && nice make release | mv $DESTDIR/* $DESTDIR/old- 2>/dev/null | 
| cd /usr/src/distrib/sets && sh checkflist | rm -rf $DESTDIR/old- & | 
| ls $RELEASEDIR | grep -v index.txt | sort > $RELEASEDIR/index.txt | fi | 
| unset DESTDIR RELEASEDIR | mkdir -p $DESTDIR $RELEASEDIR | 
|  | cd /usr/src/etc && nice make release | 
|  | cd /usr/src/distrib/sets && sh checkflist | 
|  | unset DESTDIR RELEASEDIR | 
| } | } | 
|  |  | 
| build_XF4() { | build_xenocara() { | 
| echo "********** Build and install XF4 **********" | echo "---------- Build and install xenocara ----------" | 
| rm -rf /usr/Xbuild | rm -rf /usr/xobj/* | 
| mkdir -p /usr/Xbuild | cd $XSRCDIR | 
| cd /usr/ports/lang/tcl/8.4 && make install | make bootstrap | 
| cd /usr/ports/x11/tk/8.4 && make install | make obj | 
| cd /usr/Xbuild && lndir /usr/XF4 && nice make build | make build | 
| } | } | 
|  |  | 
| make_release_XF4() { | make_xenocara_release() { | 
| echo "********** Make and validate the XF4 release **********" | echo "---------- Make and validate the xenocara release ----------" | 
| export DESTDIR=$DEST RELEASEDIR=$RELEASE | export DESTDIR=$DEST RELEASEDIR=$RELEASE | 
| rm -rf $DESTDIR/* | if (-e $DESTDIR); then | 
| mkdir -p $DESTDIR $RELEASEDIR | mkdir $DESTDIR/old- | 
| cd /usr/Xbuild && nice make release | mv $DESTDIR/* $DESTDIR/old- 2>/dev/null | 
| cd /usr/Xbuild/distrib/sets && sh checkflist | rm -rf $DESTDIR/old- & | 
| ls $RELEASEDIR | grep -v index.txt | sort > $RELEASEDIR/index.txt | fi | 
| unset DESTDIR RELEASEDIR | mkdir -p $DESTDIR $RELEASEDIR | 
|  | cd $XSRCDIR | 
|  | nice make release | 
|  | unset DESTDIR RELEASEDIR | 
| } | } | 
|  |  | 
| clean_everything() { |  | 
| echo "********** Clean everything **********" |  | 
| rm -rf /usr/obj/* $DEST/* /usr/Xbuild |  | 
| } |  | 
|  |  | 
| 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 | 
| echo "  clean              - Clean everything" |  | 
| 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` | 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" |  | 
| echo "CVS Revision Tag: $CVSTAG" |  | 
| echo | echo | 
|  |  | 
| if [ $# = 0 ]; then usage; exit 1; fi |  | 
|  |  | 
| if [ `id -u` != "0" ]; then |  | 
| echo "You probably should be root instead of `whoami` to run this safely." |  | 
| exit 1 |  | 
| fi |  | 
|  |  | 
| for i in $* | for i in $* | 
| do | do | 
| case $i in | case $i in | 
| install) | full-release) | 
| install_sources | build_xenocara | 
| ;; | build_system | 
| update) | make_xenocara_release | 
| update_sources | make_system_release | 
| ;; | ;; | 
| kernel) | update) | 
| build_kernel | update_sources | 
| ;; | ;; | 
| system) | kernel) | 
| build_system | build_kernel | 
| ;; | ;; | 
| release) | system) | 
| make_release | build_system | 
| ;; | ;; | 
| xwindow) | system-release) | 
| build_XF4 | make_system_release | 
| ;; | ;; | 
| xwindow-release) | xenocara) | 
| make_release_XF4 | build_xenocara | 
| ;; | ;; | 
| clean) | xenocara-release) | 
| clean_everything | make_xenocara_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 |