#!/bin/sh # # $Id: maj,v 1.19 2008/06/16 11:48:53 mattieu Exp $ # # Copyright (c) 2007 Mattieu Baptiste # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # This script enables you to rapidly fetch or update 'src', 'ports' and # xenocara trees, compile a new kernel, the userland or xenocara and install # this new kernel. # # Simply put the script in your ~/bin. # Usage is: # # # maj -g [src|ports|xenocara|all] Get tree, ports, xenocara or all # # maj -u [src|ports|xenocara|all] Update tree, ports, xenocara or all # # maj -c [kernel|uland|xenocara] Compile kernel, userland or xenocara # # maj -i Install new kernel from /usr/src # # maj -r Create release tarballs # # WARNING : before running this script, don't forget to put your nearest # OpenBSD Anonymous CVS Server. # # CVS repository readonly CVSROOT=anoncvs@anoncvs.nl.openbsd.org:/cvs # Directorys where you want to put release tarballs readonly DESTDIR=/usr/destdir readonly RELEASEDIR=/usr/releasedir BRANCH=`grep ^OpenBSD /etc/motd | awk '{print $2}' | \ sed -e "s/\`uname -r\`//g"` if [ "$BRANCH" = "-current" -o "$BRANCH" = "-beta" ]; then VERSION="" elif [ "$BRANCH" = "-stable" -o "$BRANCH" = "" ]; then VERSION="-rOPENBSD_"`uname -r | sed -e "s/\./_/"` fi if [ "$(sysctl -n hw.ncpu)" = "1" ]; then KERNCONF="GENERIC" else KERNCONF="GENERIC.MP" fi if [ -x /usr/X11R6/bin/startx ]; then WITHX="YES" fi # Use these variables to force a certain behavior #VERSION="" #KERNCONF="GENERIC.ACPI" function usage { echo 1>&2 "Usage:"'\t'"-g [src|ports|xenocara|all]"'\t'"Get the tree" echo 1>&2 '\t'"-u [src|ports|xenocara|all]"'\t'"Update the tree" echo 1>&2 '\t'"-c [kernel|uland|xenocara]"'\t'"Compile" echo 1>&2 '\t'"-i"'\t''\t''\t''\t'"Install new kernel" echo 1>&2 '\t'"-r"'\t''\t''\t''\t'"Create release tarballs" exit 1; } while getopts 'g:u:c:ir' arg do case "$arg" in g | u | c) flag="$arg" flagopt="$OPTARG" ;; i | r) flag="$arg" ;; \?) usage ;; esac done if [ "$OPTIND" -eq "1" ]; then usage fi function get_x { cd /usr && cvs -qd $CVSROOT get $VERSION -P $1 return } function up_x { cd /usr/$1 && cvs -d $CVSROOT -q up $VERSION -Pd return } case "$flag" in g) case "$flagopt" in src | ports | xenocara) get_x $flagopt ;; all) get_x src if [ "$WITHX" = "YES" ]; then get_x xenocara fi get_x ports ;; *) usage exit 1 ;; esac ;; u) case "$flagopt" in src | ports | xenocara) up_x $flagopt ;; all) up_x src if [ "$WITHX" = "YES" ]; then up_x xenocara fi up_x ports ;; *) usage exit 1 ;; esac ;; c) case "$flagopt" in kernel) temps=`date +"%Y-%m-%d %T"` cd /usr/src/sys/arch/`machine`/conf /usr/sbin/config $KERNCONF cd /usr/src/sys/arch/`machine`/compile/$KERNCONF make clean depend && make echo "Started:"'\t'$temps echo -n "Ended:"'\t''\t' date +"%Y-%m-%d %T" echo "$0: you can now install the new kernel with '-i'" ;; uland) temps=`date +"%Y-%m-%d %T"` cd /usr/obj && mkdir -p .old && mv * .old && rm -rf .old & cd /usr/src && nice make obj cd /usr/src/etc && env DESTDIR=/ make distrib-dirs cd /usr/src && nice make build echo "Started:"'\t'$temps echo -n "Ended:"'\t''\t' date +"%Y-%m-%d %T" echo "$0: you must now reboot the computer..." ;; xenocara) temps=`date +"%Y-%m-%d %T"` rm -rf /usr/xobj mkdir -p /usr/xobj cd /usr/xenocara make bootstrap make obj make build echo "Started:"'\t'$temps echo -n "Ended:"'\t''\t' date +"%Y-%m-%d %T" echo "$0: you must now reboot the computer..." ;; *) usage exit 1 ;; esac ;; i) cd /usr/src/sys/arch/`machine`/compile/$KERNCONF make install echo "$0: you can now reboot the computer..." ;; r) temps=`date +"%Y-%m-%d %T"` cd /usr/src/distrib/crunch && make obj depend && make all install test -d ${DESTDIR} && mv ${DESTDIR} ${DESTDIR}- && rm -rf ${DESTDIR}- mkdir -p ${DESTDIR} ${RELEASEDIR} cd /usr/src/etc && nice make release cd /usr/src/distrib/sets && sh checkflist if [ "$WITHX" = "YES" ]; then cd /usr/xenocara test -d ${DESTDIR} && mv ${DESTDIR} ${DESTDIR}- && rm -rf ${DESTDIR}- mkdir -p ${DESTDIR} ${RELEASEDIR} nice make release fi echo "Started:"'\t'$temps echo -n "Ended:"'\t''\t' date +"%Y-%m-%d %T" echo "$0: fresh release tarballs are populated in $RELEASEDIR" ;; esac exit 0