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

Annotation of openbsd/update_openbsd/release.sh, Revision 1.35

1.1       andrew      1: #!/bin/sh
1.35    ! andrew      2: # $AFresh1: release.sh,v 1.34 2012/05/27 20:48:56 andrew Exp $
1.1       andrew      3: #
1.19      andrew      4: # Copyright (c) 2002, 2008 Steven Roberts <sroberts@fenderq.com>
1.1       andrew      5: #
1.14      andrew      6: # Permission to use, copy, modify, and distribute this software for any
                      7: # purpose with or without fee is hereby granted, provided that the above
                      8: # copyright notice and this permission notice appear in all copies.
                      9: #
                     10: # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     11: # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     12: # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     13: # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14: # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     15: # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     16: # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     17: #
                     18:
1.24      andrew     19: local _origtag=${TAG}
                     20: TAG=`uname -sr | tr '[:lower:] .' '[:upper:]_'`
1.14      andrew     21: KERNEL="GENERIC"
1.19      andrew     22: ARCH=`machine`
1.14      andrew     23: DEST="/home/destdir"
                     24: RELEASE="/home/releasedir"
1.22      andrew     25: XSRCDIR="/usr/xenocara"
1.14      andrew     26: PORTSPATH="/usr/ports"
1.1       andrew     27:
1.27      andrew     28: if [ -e /etc/release.conf ]; then
                     29:     . /etc/release.conf
1.18      andrew     30: fi
1.25      andrew     31: export CVSROOT
1.14      andrew     32:
1.24      andrew     33: if [ X"" != X"${_origtag}" ]; then
                     34:     TAG=$_origtag
                     35: fi
                     36:
                     37:
1.14      andrew     38: # See http://www.openbsd.org/anoncvs.html for instructions on fetching the
                     39: # sources for the first time.
1.1       andrew     40:
1.30      andrew     41: empty_dir() {
                     42: [ X"" == X"$1" ] && exit
                     43: cd $1 || exit
                     44:
                     45: local _old=`${SUDO} mktemp -d .old.XXXXXXX`
                     46: ${SUDO} mv -f * .* $_old 2>/dev/null
                     47: ${SUDO} rm -rf $_old
                     48:
                     49: sync
                     50: }
                     51:
1.1       andrew     52: update_sources() {
1.14      andrew     53: echo "---------- Update sources ----------"
1.24      andrew     54: local _d
                     55: for _d in /usr/src "${XSRCDIR}" "${PORTSPATH}"; do
1.34      andrew     56:     if [ -d $_d -a -e $_d/CVS ]; then
1.35    ! andrew     57:         R="-r$TAG"
        !            58:         [ "$TAG" = "HEAD" ] && R="-A"
        !            59:         echo [$_d] cvs update $R -Pd
        !            60:         cd $_d &&  cvs update $R -Pd || exit 255
1.24      andrew     61:     fi
1.14      andrew     62: done
1.1       andrew     63: }
                     64:
                     65: build_kernel() {
1.14      andrew     66: echo "---------- Build and install a new kernel ----------"
1.30      andrew     67: local _status=0
                     68: unset DESTDIR RELEASEDIR
1.14      andrew     69: cd /usr/src/sys/arch/$ARCH/conf
                     70: config $KERNEL
                     71: cd ../compile/$KERNEL
                     72: make clean depend && make
1.30      andrew     73: _status=$?
                     74: if [ $_status == 0 ]; then
                     75:     make install
                     76:     _status=$?
                     77: fi
                     78: if [ $_status != 0 ]; then
                     79:     echo Kernel Build Failed
1.32      andrew     80:     exit $_status
1.30      andrew     81: fi
1.1       andrew     82: }
                     83:
                     84: build_system() {
1.14      andrew     85: echo "---------- Build a new system ----------"
1.30      andrew     86: local _status=0
                     87: unset DESTDIR RELEASEDIR
                     88: empty_dir /usr/obj &
1.14      andrew     89: cd /usr/src && nice make obj
1.30      andrew     90: _status=$?
                     91: if [ $_status == 0 ]; then
                     92:     cd /usr/src/etc && env DESTDIR=/ $SUDO make distrib-dirs
                     93:     _status=$?
                     94: fi
                     95: if [ $_status == 0 ]; then
                     96:     cd /usr/src && nice make SUDO="${SUDO}" build
                     97: fi
                     98: if [ $_status != 0 ]; then
                     99:     echo System Build Failed
1.32      andrew    100:     exit $_status
                    101: else
                    102:     echo Update /etc, /var, and /dev/MAKEDEV, either by hand or using sysmerge\(8\).
1.30      andrew    103: fi
1.14      andrew    104: }
                    105:
                    106: make_system_release() {
                    107: echo "---------- Make and validate the system release ----------"
1.30      andrew    108: local _status=0
1.14      andrew    109: export DESTDIR=$DEST; export RELEASEDIR=$RELEASE
1.26      andrew    110: if [ X"$DESTDIR" == X"" ]; then
                    111:        echo PLEASE SET \$DEST! >2&
                    112:        exit
                    113: fi
1.14      andrew    114: mkdir -p $DESTDIR $RELEASEDIR
1.30      andrew    115: empty_dir $DESTDIR &
                    116: cd /usr/src/etc && ${SUDO} nice make release
                    117: _status=$?
                    118: if [ $_status == 0 ]; then
                    119:     cd /usr/src/distrib/sets && ${SUDO} sh checkflist
                    120:     _status=$?
                    121: fi
1.14      andrew    122: unset DESTDIR RELEASEDIR
1.30      andrew    123: if [ $_status != 0 ]; then
                    124:     echo System Release Failed
1.32      andrew    125:     exit $_status
1.30      andrew    126: fi
1.14      andrew    127: }
                    128:
                    129: build_xenocara() {
                    130: echo "---------- Build and install xenocara ----------"
1.30      andrew    131: local _status=0
                    132: unset DESTDIR RELEASEDIR
                    133: empty_dir /usr/xobj &
1.14      andrew    134: cd $XSRCDIR
1.30      andrew    135: _status=$?
                    136: if [ $_status == 0 ]; then
1.32      andrew    137:     make bootstrap
                    138:     _status=$?
                    139: fi
                    140: if [ $_status == 0 ]; then
1.30      andrew    141:     make obj
                    142:     _status=$?
                    143: fi
                    144: if [ $_status == 0 ]; then
                    145:     make build
                    146:     _status=$?
                    147: fi
                    148: if [ $_status != 0 ]; then
                    149:     echo Xenocara Build Failed
1.32      andrew    150:     exit $_status
1.30      andrew    151: fi
1.14      andrew    152: }
                    153:
                    154: make_xenocara_release() {
                    155: echo "---------- Make and validate the xenocara release ----------"
1.30      andrew    156: local _status=0
                    157: export DESTDIR=$DEST;export RELEASEDIR=$RELEASE
1.26      andrew    158: if [ X"$DESTDIR" == X"" ]; then
                    159:        echo PLEASE SET \$DEST! >2&
                    160:        exit
                    161: fi
1.14      andrew    162: mkdir -p $DESTDIR $RELEASEDIR
1.30      andrew    163: empty_dir $DESTDIR &
1.14      andrew    164: cd $XSRCDIR
1.30      andrew    165: _status=$?
1.32      andrew    166: if [ $_status == 0 ]; then
                    167:     nice make release
                    168:     _status=$?
                    169: fi
1.14      andrew    170: unset DESTDIR RELEASEDIR
1.30      andrew    171: if [ $_status != 0 ]; then
                    172:     echo Xenocara Release Failed
1.32      andrew    173:     exit $_status
1.30      andrew    174: fi
1.1       andrew    175: }
                    176:
                    177: usage() {
1.14      andrew    178: echo "  Usage: $0 <options>"
                    179: echo
                    180: echo "Options:"
                    181: echo
                    182: echo "  update           - Update sources"
                    183: echo "  kernel           - Build and install a new kernel"
                    184: echo "  system           - Build a new system"
                    185: echo "  system-release   - Make and validate the system release"
                    186: echo "  xenocara         - Build and install xenocara"
                    187: echo "  xenocara-release - Make and validate the xenocara release"
1.33      andrew    188: echo "  full             - xenocara, xenocara-release, system, system-release"
1.14      andrew    189: echo
1.1       andrew    190: }
                    191:
1.30      andrew    192: if [ X"" == X"${SUDO}" -a `whoami` != "root" ]; then
                    193: echo "You must be root or set SUDO to build a release."
1.14      andrew    194: exit 1
                    195: fi
                    196:
1.1       andrew    197: START=`date`
                    198: echo
1.14      andrew    199: echo ".: release.sh - building an OpenBSD release :."
                    200: echo "----------------------------------------------"
1.1       andrew    201: echo
1.14      andrew    202: echo "    Tag: $TAG"
                    203: echo " Kernel: $KERNEL-$ARCH"
                    204: echo "   Dest: $DEST"
1.1       andrew    205: echo "Release: $RELEASE"
1.25      andrew    206: if [ X"$CVSROOT" != X"" ]; then
                    207:        echo "   Root: $CVSROOT"
                    208: fi
1.1       andrew    209: echo
1.19      andrew    210:
                    211: if [ $# = 0 ]; then usage; exit 1; fi
1.1       andrew    212:
                    213: for i in $*
                    214: do
1.14      andrew    215: case $i in
                    216: update)
1.32      andrew    217: update_sources
1.14      andrew    218: ;;
                    219: kernel)
1.32      andrew    220: build_kernel
1.14      andrew    221: ;;
                    222: system)
1.32      andrew    223: build_system
1.14      andrew    224: ;;
                    225: system-release)
1.32      andrew    226: make_system_release
1.14      andrew    227: ;;
                    228: xenocara)
1.32      andrew    229: build_xenocara
1.14      andrew    230: ;;
                    231: xenocara-release)
1.32      andrew    232: make_xenocara_release
1.24      andrew    233: ;;
1.33      andrew    234: full)
1.32      andrew    235: build_xenocara
                    236: make_xenocara_release
                    237: build_system
                    238: make_system_release
1.14      andrew    239: ;;
                    240: *)
                    241: echo "---------- Abort! Abort! ----------"
                    242: echo "Invalid option encountered: $i"
                    243: echo "Exiting......."
                    244: echo
                    245: exit 1
                    246: ;;
                    247: esac
1.1       andrew    248: done
                    249: echo
1.14      andrew    250: echo " Start Time : $START"
1.1       andrew    251: echo "Finish Time : `date`"
                    252: echo

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>