#!/bin/sh # # (C)2009, lists@nerdbynature.de # Update OpenBSD kernel/userland # http://openbsd.org/faq/faq5.html # http://openbsd.org/anoncvs.html#CVSROOT # # TODO: # - build as a normal user # - update sources as root # CONFIG=MYCONFIG # MYCONFIG GENERIC BUILDDIR=$HOME/build # unset me! # DEBUG=echo test -d $BUILDDIR || $DEBUG mkdir $BUILDDIR log() { echo "*** `date +%Y-%m-%d\ %H:%M:%S`: " "$1" test -n "$2" -a "$2" -gt 0 && exit "$2" } case $1 in kernel) log "CVS update in /usr/src/sys..." T_BEGIN=`date +%s` $DEBUG cd /usr/src/sys $DEBUG cvs update T_END=`date +%s` log "CVS update finished after `echo $T_END - $T_BEGIN | bc -l` seconds." # r/o tree log "Building new kernel..." T_BEGIN=`date +%s` $DEBUG cd $BUILDDIR $DEBUG cp /usr/src/sys/arch/`machine`/conf/$CONFIG . $DEBUG config -s /usr/src/sys -b . $CONFIG # $DEBUG cd /usr/src/sys/arch/`machine`/conf # $DEBUG config $CONFIG # $DEBUG cd ../compile/$CONFIG log "Building new kernel (make clean)..." $DEBUG make clean log "Building new kernel (make depend)..." $DEBUG make depend log "Building new kernel (make)..." $DEBUG make log "Building new kernel (make install)..." $DEBUG make install T_END=`date +%s` log "Building a new kernel finished after `echo "scale=1; ( $T_END - $T_BEGIN ) / 60" | bc -l` minutes." ;; userland) log "CVS update in /usr/src..." T_BEGIN=`date +%s` $DEBUG cd /usr/src $DEBUG cvs update T_END=`date +%s` log "CVS update finished after `echo $T_END - $T_BEGIN | bc -l` seconds." log "Building new userland..." T_BEGIN=`date +%s` $DEBUG rm -rf /usr/obj/* log "Building new userland (make obj)..." $DEBUG make obj $DEBUG cd /usr/src/etc log "Building new userland (make distrib-dirs)..." $DEBUG env DESTDIR=/ make distrib-dirs $DEBUG cd /usr/src log "Building new userland (make build)..." $DEBUG make build T_END=`date +%s` log "Building a new userland finished after `echo "scale=1; ( $T_END - $T_BEGIN ) / 60^2" | bc -l` hours." ;; *) echo "Usage: `basename $0` [kernel|userland]" exit 0 ;; esac