Annotation of openbsd/update_openbsd/release.sh, Revision 1.36
1.1 andrew 1: #!/bin/sh
1.36 ! andrew 2: # $AFresh1: release.sh,v 1.35 2014/11/08 20:32:55 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.36 ! andrew 108: if [ X"$DEST" == X"" ]; then
1.26 andrew 109: echo PLEASE SET \$DEST! >2&
1.36 ! andrew 110: exit 1
1.26 andrew 111: fi
1.36 ! andrew 112:
! 113: local _status=0
! 114: local DESTDIR RELEASEDIR
! 115:
! 116: [ -e $DEST ] && empty_dir $DEST
! 117: ${SUDO} install -d -g wheel -m 775 $DEST $RELEASE
! 118:
! 119: export DESTDIR=$DEST RELEASEDIR=$RELEASE
! 120: cd /usr/src/etc && ${SUDO} nice make SUDO="" release
! 121: _status=$?
! 122: [ $_status == 0 ] && cd /usr/src/distrib/sets && ${SUDO} sh checkflist
1.30 andrew 123: _status=$?
1.36 ! andrew 124:
! 125: [ $_status == 0 ] || echo System Release Failed
! 126: exit $_status
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>