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

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

1.1       andrew      1: #!/bin/sh
1.33    ! andrew      2: # $AFresh1: release.sh,v 1.32 2010/02/24 21:58:18 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
                     56:     if [ -d $_d ]; then
1.30      andrew     57:         echo [$_d] cvs update -r$TAG -Pd
                     58:         cd $_d &&  cvs update -r$TAG -Pd || exit 255
1.24      andrew     59:     fi
1.14      andrew     60: done
1.1       andrew     61: }
                     62:
                     63: build_kernel() {
1.14      andrew     64: echo "---------- Build and install a new kernel ----------"
1.30      andrew     65: local _status=0
                     66: unset DESTDIR RELEASEDIR
1.14      andrew     67: cd /usr/src/sys/arch/$ARCH/conf
                     68: config $KERNEL
                     69: cd ../compile/$KERNEL
                     70: make clean depend && make
1.30      andrew     71: _status=$?
                     72: if [ $_status == 0 ]; then
                     73:     make install
                     74:     _status=$?
                     75: fi
                     76: if [ $_status != 0 ]; then
                     77:     echo Kernel Build Failed
1.32      andrew     78:     exit $_status
1.30      andrew     79: fi
1.1       andrew     80: }
                     81:
                     82: build_system() {
1.14      andrew     83: echo "---------- Build a new system ----------"
1.30      andrew     84: local _status=0
                     85: unset DESTDIR RELEASEDIR
                     86: empty_dir /usr/obj &
1.14      andrew     87: cd /usr/src && nice make obj
1.30      andrew     88: _status=$?
                     89: if [ $_status == 0 ]; then
                     90:     cd /usr/src/etc && env DESTDIR=/ $SUDO make distrib-dirs
                     91:     _status=$?
                     92: fi
                     93: if [ $_status == 0 ]; then
                     94:     cd /usr/src && nice make SUDO="${SUDO}" build
                     95: fi
                     96: if [ $_status != 0 ]; then
                     97:     echo System Build Failed
1.32      andrew     98:     exit $_status
                     99: else
                    100:     echo Update /etc, /var, and /dev/MAKEDEV, either by hand or using sysmerge\(8\).
1.30      andrew    101: fi
1.14      andrew    102: }
                    103:
                    104: make_system_release() {
                    105: echo "---------- Make and validate the system release ----------"
1.30      andrew    106: local _status=0
1.14      andrew    107: export DESTDIR=$DEST; export RELEASEDIR=$RELEASE
1.26      andrew    108: if [ X"$DESTDIR" == X"" ]; then
                    109:        echo PLEASE SET \$DEST! >2&
                    110:        exit
                    111: fi
1.14      andrew    112: mkdir -p $DESTDIR $RELEASEDIR
1.30      andrew    113: empty_dir $DESTDIR &
                    114: cd /usr/src/etc && ${SUDO} nice make release
                    115: _status=$?
                    116: if [ $_status == 0 ]; then
                    117:     cd /usr/src/distrib/sets && ${SUDO} sh checkflist
                    118:     _status=$?
                    119: fi
1.14      andrew    120: unset DESTDIR RELEASEDIR
1.30      andrew    121: if [ $_status != 0 ]; then
                    122:     echo System Release Failed
1.32      andrew    123:     exit $_status
1.30      andrew    124: fi
1.14      andrew    125: }
                    126:
                    127: build_xenocara() {
                    128: echo "---------- Build and install xenocara ----------"
1.30      andrew    129: local _status=0
                    130: unset DESTDIR RELEASEDIR
                    131: empty_dir /usr/xobj &
1.14      andrew    132: cd $XSRCDIR
1.30      andrew    133: _status=$?
                    134: if [ $_status == 0 ]; then
1.32      andrew    135:     make bootstrap
                    136:     _status=$?
                    137: fi
                    138: if [ $_status == 0 ]; then
1.30      andrew    139:     make obj
                    140:     _status=$?
                    141: fi
                    142: if [ $_status == 0 ]; then
                    143:     make build
                    144:     _status=$?
                    145: fi
                    146: if [ $_status != 0 ]; then
                    147:     echo Xenocara Build Failed
1.32      andrew    148:     exit $_status
1.30      andrew    149: fi
1.14      andrew    150: }
                    151:
                    152: make_xenocara_release() {
                    153: echo "---------- Make and validate the xenocara release ----------"
1.30      andrew    154: local _status=0
                    155: export DESTDIR=$DEST;export RELEASEDIR=$RELEASE
1.26      andrew    156: if [ X"$DESTDIR" == X"" ]; then
                    157:        echo PLEASE SET \$DEST! >2&
                    158:        exit
                    159: fi
1.14      andrew    160: mkdir -p $DESTDIR $RELEASEDIR
1.30      andrew    161: empty_dir $DESTDIR &
1.14      andrew    162: cd $XSRCDIR
1.30      andrew    163: _status=$?
1.32      andrew    164: if [ $_status == 0 ]; then
                    165:     nice make release
                    166:     _status=$?
                    167: fi
1.14      andrew    168: unset DESTDIR RELEASEDIR
1.30      andrew    169: if [ $_status != 0 ]; then
                    170:     echo Xenocara Release Failed
1.32      andrew    171:     exit $_status
1.30      andrew    172: fi
1.1       andrew    173: }
                    174:
                    175: usage() {
1.14      andrew    176: echo "  Usage: $0 <options>"
                    177: echo
                    178: echo "Options:"
                    179: echo
                    180: echo "  update           - Update sources"
                    181: echo "  kernel           - Build and install a new kernel"
                    182: echo "  system           - Build a new system"
                    183: echo "  system-release   - Make and validate the system release"
                    184: echo "  xenocara         - Build and install xenocara"
                    185: echo "  xenocara-release - Make and validate the xenocara release"
1.33    ! andrew    186: echo "  full             - xenocara, xenocara-release, system, system-release"
1.14      andrew    187: echo
1.1       andrew    188: }
                    189:
1.30      andrew    190: if [ X"" == X"${SUDO}" -a `whoami` != "root" ]; then
                    191: echo "You must be root or set SUDO to build a release."
1.14      andrew    192: exit 1
                    193: fi
                    194:
1.1       andrew    195: START=`date`
                    196: echo
1.14      andrew    197: echo ".: release.sh - building an OpenBSD release :."
                    198: echo "----------------------------------------------"
1.1       andrew    199: echo
1.14      andrew    200: echo "    Tag: $TAG"
                    201: echo " Kernel: $KERNEL-$ARCH"
                    202: echo "   Dest: $DEST"
1.1       andrew    203: echo "Release: $RELEASE"
1.25      andrew    204: if [ X"$CVSROOT" != X"" ]; then
                    205:        echo "   Root: $CVSROOT"
                    206: fi
1.1       andrew    207: echo
1.19      andrew    208:
                    209: if [ $# = 0 ]; then usage; exit 1; fi
1.1       andrew    210:
                    211: for i in $*
                    212: do
1.14      andrew    213: case $i in
                    214: update)
1.32      andrew    215: update_sources
1.14      andrew    216: ;;
                    217: kernel)
1.32      andrew    218: build_kernel
1.14      andrew    219: ;;
                    220: system)
1.32      andrew    221: build_system
1.14      andrew    222: ;;
                    223: system-release)
1.32      andrew    224: make_system_release
1.14      andrew    225: ;;
                    226: xenocara)
1.32      andrew    227: build_xenocara
1.14      andrew    228: ;;
                    229: xenocara-release)
1.32      andrew    230: make_xenocara_release
1.24      andrew    231: ;;
1.33    ! andrew    232: full)
1.32      andrew    233: build_xenocara
                    234: make_xenocara_release
                    235: build_system
                    236: make_system_release
1.14      andrew    237: ;;
                    238: *)
                    239: echo "---------- Abort! Abort! ----------"
                    240: echo "Invalid option encountered: $i"
                    241: echo "Exiting......."
                    242: echo
                    243: exit 1
                    244: ;;
                    245: esac
1.1       andrew    246: done
                    247: echo
1.14      andrew    248: echo " Start Time : $START"
1.1       andrew    249: echo "Finish Time : `date`"
                    250: echo

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