#!/bin/sh _find_cvs() { for _basepath in /{var/,usr/local/,}cvs ; do if [ -d ${_basepath}/CVSROOT -a \ -d ${_basepath}/src -a \ -d ${_basepath}/ports -a \ -d ${_basepath}/xenocara ]; then CVSROOT=${_basepath} return 0 fi done return 1 } _usage() { echo "Usage: `basename $0` [-h] [-t TAG]" 1>&2 } # Set the cvstag to an empty string, so that we can check if it was set via -t TAG= # Parse the command line options while getopts ht: OPT; do case "${OPT}" in h) _usage exit 0 ;; t) TAG="-r${OPTARG}" ;; \?) # Error from getopts _usage exit 1 ;; esac done BSDSRCDIR=$(grep BSDSRCDIR /etc/mk.conf 2>/dev/null | sed 's/^.*=//g') BSDSRCDIR=${BSDSRCDIR:=/usr/src} # Set the CVSROOT, if there is an @ in the cvs root we will use compression if ! _find_cvs ; then # Try to get the CVSROOT from the existing source tree _cvsroot=${BSDSRCDIR}/CVS/Root test -e ${_cvsroot} \ && CVSROOT=$(cat ${_cvsroot} | sed -e 's/[[:space:]]*//') COMPRESS=$(echo ${CVSROOT} | awk '/@/ { print "-z3"; }') fi # There is nothing we can do unless some CVSROOT was found test -z ${CVSROOT} && { echo "Unable to deduce CVSROOT, exiting..."; exit 2; } # Create the log directory if not existant mkdir -p ${HOME}/cvslogs # Create the Tag flag for cvs. Either from the uname output or an empty var # for current systems # The Tag file should not exist on -current trees if [ -f ${BSDSRCDIR}/CVS/Tag -a -z "${TAG}" ]; then # Make the openbsd specific tag for the system. TAG=$(uname -s -r | awk '{ print toupper($0); }' | tr " ." _) TAG="-r${TAG}" fi if [ "X${TAG}" = "XHEAD" ]; then TAG= fi # The date we are updateing the sources on. DATE=$(date +%F) # Update ${BSDSRCDIR} (if it exists) if [ -d "${BSDSRCDIR}/CVS" ]; then echo "Starting CVS update for ${BSDSRCDIR} at $(date +%T)." cd "${BSDSRCDIR}" && \ cvs -R ${COMPRESS} -d ${CVSROOT} -q up ${TAG} -PdA 2>&1 \ | tee -a "${HOME}/cvslogs/cvs-src-${DATE}" echo "Finished CVS update for ${BSDSRCDIR} at $(date +%T)." else echo "Skipping ${BSDSRCDIR} (does not exist)" fi PORTSDIR=$(grep PORTSDIR= /etc/mk.conf 2>/dev/null | sed 's/^.*=//g') PORTSDIR=${PORTSDIR:=/usr/ports} # Update ${PORTSDIR} if the directory exists if [ -d "${PORTSDIR}/CVS" ]; then echo "Starting CVS update for ${PORTSDIR} at $(date +%T)." cd "${PORTSDIR}" && \ cvs -R ${COMPRESS} -d ${CVSROOT} -q up ${TAG} -PdA 2>&1 \ | tee -a "${HOME}/cvslogs/cvs-ports-${DATE}" echo "Finished CVS update for ${PORTSDIR} at $(date +%T)." else echo "Skipping ${PORTSDIR} (does not exist)" fi # Update $XSRCDIR if the directory exists XSRCDIR=$(grep XSRCDIR /etc/mk.conf 2>/dev/null| sed 's/^.*=//g') XSRCDIR=${XSRCDIR:=/usr/xenocara} if [ -d "${XSRCDIR}/CVS" ]; then echo "Starting CVS update for ${XSRCDIR}" cd "${XSRCDIR}" && \ cvs -R ${COMPRESS} -d ${CVSROOT} -q up ${TAG} -PdA 2>&1 \ | tee -a "${HOME}/cvslogs/cvs-xenocara-${DATE}" echo "Finished CVS update for ${XSRCDIR} at $(date +%T)." else echo "Skipping ${XSRCDIR} (does not exist)" fi