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

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

1.1       andrew      1: #!/bin/sh
1.38    ! andrew      2: # $AFresh1: release.sh,v 1.37 2015/11/27 22:36:12 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.38    ! andrew     23: DEST="/usr/dest"
1.14      andrew     24: RELEASE="/home/releasedir"
1.22      andrew     25: XSRCDIR="/usr/xenocara"
1.14      andrew     26: PORTSPATH="/usr/ports"
1.38    ! andrew     27: BUILDUSER=build
1.1       andrew     28:
1.38    ! andrew     29: if [ -e /etc/mk.conf ]; then
        !            30:     . /etc/mk.conf
        !            31: fi
1.27      andrew     32: if [ -e /etc/release.conf ]; then
                     33:     . /etc/release.conf
1.18      andrew     34: fi
1.25      andrew     35: export CVSROOT
1.14      andrew     36:
1.24      andrew     37: if [ X"" != X"${_origtag}" ]; then
                     38:     TAG=$_origtag
                     39: fi
                     40:
1.38    ! andrew     41: if [ X"$DEST" = X"" ]; then
        !            42:     echo PLEASE SET \$DEST! >&2
        !            43:     exit 1
        !            44: fi
        !            45: if [ X"$RELEASE" = X"" ]; then
        !            46:     echo PLEASE SET \$RELEASE! >&2
        !            47:     exit 1
        !            48: fi
1.24      andrew     49:
1.14      andrew     50: # See http://www.openbsd.org/anoncvs.html for instructions on fetching the
                     51: # sources for the first time.
1.1       andrew     52:
1.30      andrew     53: empty_dir() {
1.38    ! andrew     54: [ X"" = X"$1" ] && exit
1.30      andrew     55: cd $1 || exit
                     56:
1.38    ! andrew     57: local _old=`mktemp -d .old.XXXXXXX`
        !            58: mv -f * .* $_old 2>/dev/null
        !            59: rm -rf $_old
1.30      andrew     60:
                     61: sync
                     62: }
                     63:
1.1       andrew     64: update_sources() {
1.14      andrew     65: echo "---------- Update sources ----------"
1.24      andrew     66: local _d
                     67: for _d in /usr/src "${XSRCDIR}" "${PORTSPATH}"; do
1.34      andrew     68:     if [ -d $_d -a -e $_d/CVS ]; then
1.35      andrew     69:         R="-r$TAG"
                     70:         [ "$TAG" = "HEAD" ] && R="-A"
                     71:         echo [$_d] cvs update $R -Pd
                     72:         cd $_d &&  cvs update $R -Pd || exit 255
1.24      andrew     73:     fi
1.14      andrew     74: done
1.1       andrew     75: }
                     76:
                     77: build_kernel() {
1.14      andrew     78: echo "---------- Build and install a new kernel ----------"
1.30      andrew     79: local _status=0
                     80: unset DESTDIR RELEASEDIR
1.38    ! andrew     81:
        !            82: cd /usr/src/sys/arch/$ARCH/compile/$KERNEL
1.30      andrew     83: _status=$?
1.38    ! andrew     84:
        !            85: if [ $_status -eq 0 ]; then
        !            86:     make obj && make config && make && make install
1.30      andrew     87:     _status=$?
                     88: fi
1.38    ! andrew     89:
        !            90: if [ $_status -ne 0 ]; then
1.30      andrew     91:     echo Kernel Build Failed
1.32      andrew     92:     exit $_status
1.30      andrew     93: fi
1.1       andrew     94: }
                     95:
                     96: build_system() {
1.14      andrew     97: echo "---------- Build a new system ----------"
1.30      andrew     98: local _status=0
                     99: unset DESTDIR RELEASEDIR
1.38    ! andrew    100: local DESTDIR RELEASEDIR
        !           101:
        !           102: mkdir -p /usr/obj
        !           103: chown $BUILDUSER:wheel /usr/obj
        !           104: chmod 755              /usr/obj
1.30      andrew    105: empty_dir /usr/obj &
1.38    ! andrew    106:
        !           107: cd /usr/src
1.30      andrew    108: _status=$?
1.38    ! andrew    109:
        !           110: if [ $_status -eq 0 ]; then
        !           111:     nice make $BUILD_ARGS obj && nice make $BUILD_ARGS build
1.30      andrew    112:     _status=$?
                    113: fi
1.38    ! andrew    114:
        !           115: if [ $_status -ne 0 ]; then
1.30      andrew    116:     echo System Build Failed
1.32      andrew    117:     exit $_status
1.30      andrew    118: fi
1.38    ! andrew    119:
        !           120: echo Update /etc, /var, and /dev/MAKEDEV, either by hand or using sysmerge\(8\).
1.14      andrew    121: }
                    122:
                    123: make_system_release() {
                    124: echo "---------- Make and validate the system release ----------"
1.36      andrew    125:
                    126: local _status=0
                    127: local DESTDIR RELEASEDIR
                    128:
1.38    ! andrew    129: export DESTDIR=$DEST/base; export RELEASEDIR=$RELEASE
        !           130: mkdir -p $DESTDIR $RELEASEDIR
        !           131: empty_dir $DESTDIR &
        !           132: chown -R $BUILDUSER:wheel $DESTDIR $RELEASEDIR
        !           133: chmod -R 700              $DESTDIR $RELEASEDIR
        !           134:
        !           135: if [ $_status -eq 0 ]; then
        !           136:     cd /usr/src/etc && nice make release
        !           137:     _status=$?
        !           138: fi
1.36      andrew    139:
1.38    ! andrew    140: if [ $_status -eq 0 ]; then
        !           141:     cd /usr/src/distrib/sets && sh checkflist
        !           142:     _status=$?
        !           143: fi
1.36      andrew    144:
1.38    ! andrew    145: unset DESTDIR RELEASEDIR
        !           146: if [ $_status -ne 0 ]; then
        !           147:     echo System Release Failed
        !           148:     exit $_status
        !           149: fi
1.14      andrew    150: }
                    151:
                    152: build_xenocara() {
                    153: echo "---------- Build and install xenocara ----------"
1.30      andrew    154: local _status=0
1.38    ! andrew    155: local DESTDIR RELEASEDIR
1.30      andrew    156: unset DESTDIR RELEASEDIR
1.38    ! andrew    157:
        !           158: mkdir -p /usr/xobj
        !           159: chown $BUILDUSER:wheel /usr/xobj
        !           160: chmod 755              /usr/xobj
1.30      andrew    161: empty_dir /usr/xobj &
1.38    ! andrew    162:
1.14      andrew    163: cd $XSRCDIR
1.30      andrew    164: _status=$?
1.38    ! andrew    165:
        !           166: if [ $_status -eq 0 ]; then
1.37      andrew    167:     make $BUILD_ARGS bootstrap
1.32      andrew    168:     _status=$?
                    169: fi
1.38    ! andrew    170:
        !           171: if [ $_status -eq 0 ]; then
1.37      andrew    172:     make $BUILD_ARGS obj
1.30      andrew    173:     _status=$?
                    174: fi
1.38    ! andrew    175:
        !           176: if [ $_status -eq 0 ]; then
1.37      andrew    177:     make $BUILD_ARGS build
1.30      andrew    178:     _status=$?
                    179: fi
1.38    ! andrew    180:
        !           181: if [ $_status -ne 0 ]; then
1.30      andrew    182:     echo Xenocara Build Failed
1.32      andrew    183:     exit $_status
1.30      andrew    184: fi
1.14      andrew    185: }
                    186:
                    187: make_xenocara_release() {
                    188: echo "---------- Make and validate the xenocara release ----------"
1.30      andrew    189: local _status=0
1.38    ! andrew    190: local DESTDIR RELEASEDIR
        !           191:
        !           192: export DESTDIR=$DEST/xbase; export RELEASEDIR=$RELEASE
1.14      andrew    193: mkdir -p $DESTDIR $RELEASEDIR
1.30      andrew    194: empty_dir $DESTDIR &
1.38    ! andrew    195: chown -R $BUILDUSER:wheel $DESTDIR $RELEASEDIR
        !           196: chmod -R 755              $DESTDIR $RELEASEDIR
        !           197:
        !           198: if [ $_status -eq 0 ]; then
        !           199:     cd $XSRCDIR && nice make release
1.32      andrew    200:     _status=$?
                    201: fi
1.38    ! andrew    202:
1.14      andrew    203: unset DESTDIR RELEASEDIR
1.38    ! andrew    204: if [ $_status -ne 0 ]; then
1.30      andrew    205:     echo Xenocara Release Failed
1.32      andrew    206:     exit $_status
1.30      andrew    207: fi
1.1       andrew    208: }
                    209:
                    210: usage() {
1.14      andrew    211: echo "  Usage: $0 <options>"
                    212: echo
                    213: echo "Options:"
                    214: echo
                    215: echo "  update           - Update sources"
                    216: echo "  kernel           - Build and install a new kernel"
                    217: echo "  system           - Build a new system"
                    218: echo "  system-release   - Make and validate the system release"
                    219: echo "  xenocara         - Build and install xenocara"
                    220: echo "  xenocara-release - Make and validate the xenocara release"
1.33      andrew    221: echo "  full             - xenocara, xenocara-release, system, system-release"
1.14      andrew    222: echo
1.38    ! andrew    223: if [ `whoami` != "root" ]; then
        !           224: echo "You must be root to build a release."
        !           225: fi
1.1       andrew    226: }
                    227:
                    228: START=`date`
                    229: echo
1.14      andrew    230: echo ".: release.sh - building an OpenBSD release :."
                    231: echo "----------------------------------------------"
1.1       andrew    232: echo
1.14      andrew    233: echo "    Tag: $TAG"
                    234: echo " Kernel: $KERNEL-$ARCH"
                    235: echo "   Dest: $DEST"
1.1       andrew    236: echo "Release: $RELEASE"
1.25      andrew    237: if [ X"$CVSROOT" != X"" ]; then
                    238:        echo "   Root: $CVSROOT"
                    239: fi
1.1       andrew    240: echo
1.19      andrew    241:
                    242: if [ $# = 0 ]; then usage; exit 1; fi
1.38    ! andrew    243:
        !           244: if [ `whoami` != "root" ]; then
        !           245: echo "You must be root to build a release."
        !           246: exit 1
        !           247: fi
1.1       andrew    248:
                    249: for i in $*
                    250: do
1.14      andrew    251: case $i in
                    252: update)
1.32      andrew    253: update_sources
1.14      andrew    254: ;;
                    255: kernel)
1.32      andrew    256: build_kernel
1.14      andrew    257: ;;
                    258: system)
1.32      andrew    259: build_system
1.14      andrew    260: ;;
                    261: system-release)
1.32      andrew    262: make_system_release
1.14      andrew    263: ;;
                    264: xenocara)
1.32      andrew    265: build_xenocara
1.14      andrew    266: ;;
                    267: xenocara-release)
1.32      andrew    268: make_xenocara_release
1.24      andrew    269: ;;
1.33      andrew    270: full)
1.32      andrew    271: build_xenocara
                    272: make_xenocara_release
                    273: build_system
                    274: make_system_release
1.14      andrew    275: ;;
                    276: *)
                    277: echo "---------- Abort! Abort! ----------"
                    278: echo "Invalid option encountered: $i"
                    279: echo "Exiting......."
                    280: echo
                    281: exit 1
                    282: ;;
                    283: esac
1.1       andrew    284: done
                    285: echo
1.14      andrew    286: echo " Start Time : $START"
1.1       andrew    287: echo "Finish Time : `date`"
                    288: echo

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