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

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

1.1       andrew      1: #!/bin/sh
1.31    ! andrew      2: # $AFresh1: release.sh,v 1.30 2009/12/03 17:28:37 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
                     78: fi
                     79: exit $_status
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
                     98: fi
1.24      andrew     99: echo Update /etc, /var, and /dev/MAKEDEV, either by hand or using sysmerge\(8\).
1.30      andrew    100: exit $_status
1.14      andrew    101: }
                    102:
                    103: make_system_release() {
                    104: echo "---------- Make and validate the system release ----------"
1.30      andrew    105: local _status=0
1.14      andrew    106: export DESTDIR=$DEST; export RELEASEDIR=$RELEASE
1.26      andrew    107: if [ X"$DESTDIR" == X"" ]; then
                    108:        echo PLEASE SET \$DEST! >2&
                    109:        exit
                    110: fi
1.14      andrew    111: mkdir -p $DESTDIR $RELEASEDIR
1.30      andrew    112: empty_dir $DESTDIR &
                    113: cd /usr/src/etc && ${SUDO} nice make release
                    114: _status=$?
                    115: if [ $_status == 0 ]; then
                    116:     cd /usr/src/distrib/sets && ${SUDO} sh checkflist
                    117:     _status=$?
                    118: fi
1.14      andrew    119: unset DESTDIR RELEASEDIR
1.30      andrew    120: if [ $_status != 0 ]; then
                    121:     echo System Release Failed
                    122: fi
                    123: exit $_status
1.14      andrew    124: }
                    125:
                    126: build_xenocara() {
                    127: echo "---------- Build and install xenocara ----------"
1.30      andrew    128: local _status=0
                    129: unset DESTDIR RELEASEDIR
                    130: empty_dir /usr/xobj &
1.14      andrew    131: cd $XSRCDIR
                    132: make bootstrap
1.30      andrew    133: _status=$?
                    134: if [ $_status == 0 ]; then
                    135:     make obj
                    136:     _status=$?
                    137: fi
                    138: if [ $_status == 0 ]; then
                    139:     make build
                    140:     _status=$?
                    141: fi
                    142: if [ $_status != 0 ]; then
                    143:     echo Xenocara Build Failed
                    144: fi
                    145: exit $_status
1.14      andrew    146: }
                    147:
                    148: make_xenocara_release() {
                    149: echo "---------- Make and validate the xenocara release ----------"
1.30      andrew    150: local _status=0
                    151: export DESTDIR=$DEST;export RELEASEDIR=$RELEASE
1.26      andrew    152: if [ X"$DESTDIR" == X"" ]; then
                    153:        echo PLEASE SET \$DEST! >2&
                    154:        exit
                    155: fi
1.14      andrew    156: mkdir -p $DESTDIR $RELEASEDIR
1.30      andrew    157: empty_dir $DESTDIR &
1.14      andrew    158: cd $XSRCDIR
                    159: nice make release
1.30      andrew    160: _status=$?
1.14      andrew    161: unset DESTDIR RELEASEDIR
1.30      andrew    162: if [ $_status != 0 ]; then
                    163:     echo Xenocara Release Failed
                    164: fi
                    165: exit $_status
1.1       andrew    166: }
                    167:
                    168: usage() {
1.14      andrew    169: echo "  Usage: $0 <options>"
                    170: echo
                    171: echo "Options:"
                    172: echo
                    173: echo "  update           - Update sources"
                    174: echo "  kernel           - Build and install a new kernel"
                    175: echo "  system           - Build a new system"
                    176: echo "  system-release   - Make and validate the system release"
                    177: echo "  xenocara         - Build and install xenocara"
                    178: echo "  xenocara-release - Make and validate the xenocara release"
1.28      andrew    179: echo "  full-release     - xenocara, xenocara-release, system, system-release"
1.14      andrew    180: echo
1.1       andrew    181: }
                    182:
1.30      andrew    183: if [ X"" == X"${SUDO}" -a `whoami` != "root" ]; then
                    184: echo "You must be root or set SUDO to build a release."
1.14      andrew    185: exit 1
                    186: fi
                    187:
1.1       andrew    188: START=`date`
                    189: echo
1.14      andrew    190: echo ".: release.sh - building an OpenBSD release :."
                    191: echo "----------------------------------------------"
1.1       andrew    192: echo
1.14      andrew    193: echo "    Tag: $TAG"
                    194: echo " Kernel: $KERNEL-$ARCH"
                    195: echo "   Dest: $DEST"
1.1       andrew    196: echo "Release: $RELEASE"
1.25      andrew    197: if [ X"$CVSROOT" != X"" ]; then
                    198:        echo "   Root: $CVSROOT"
                    199: fi
1.1       andrew    200: echo
1.19      andrew    201:
                    202: if [ $# = 0 ]; then usage; exit 1; fi
1.1       andrew    203:
                    204: for i in $*
                    205: do
1.14      andrew    206: case $i in
                    207: update)
1.30      andrew    208: update_sources || exit 10
1.14      andrew    209: ;;
                    210: kernel)
1.30      andrew    211: build_kernel || exit 20
1.14      andrew    212: ;;
                    213: system)
1.30      andrew    214: build_system || exit 30
1.14      andrew    215: ;;
                    216: system-release)
1.30      andrew    217: make_system_release || exit 35
1.14      andrew    218: ;;
                    219: xenocara)
1.30      andrew    220: build_xenocara || exit 40
1.14      andrew    221: ;;
                    222: xenocara-release)
1.30      andrew    223: make_xenocara_release || exit 45
1.24      andrew    224: ;;
                    225: full-release)
1.30      andrew    226: build_xenocara || exit 51
                    227: make_xenocara_release || exit 52
                    228: build_system || exit 53
                    229: make_system_release || exit 54
1.14      andrew    230: ;;
                    231: *)
                    232: echo "---------- Abort! Abort! ----------"
                    233: echo "Invalid option encountered: $i"
                    234: echo "Exiting......."
                    235: echo
                    236: exit 1
                    237: ;;
                    238: esac
1.1       andrew    239: done
                    240: echo
1.14      andrew    241: echo " Start Time : $START"
1.1       andrew    242: echo "Finish Time : `date`"
                    243: echo

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