test; CVS updater with submodule tag bug workaround



[This is something of a test; the CMU backbone decided it didn't know about
our subnet any more, and it looks like the GNOME list has forgotten about me.]

This ugly shell script is how I currently update my CVS checkouts.  You won't
want to use it unchanged, but the cvs_get function might be useful as a
nice way to cope with the vagaries of CVS servers.

#! /bin/sh

me="`basename \"$0\"`"

rm=n
bld=y
level=4
retries=5

while [ $# -ne 0 ]; do
    case "x$1" in
    x--)
	shift
	break
	;;
    x-R)
	rm=y
	shift
	;;
    x-k)
	rm=n
	shift
	;;
    x-b)
	bld=y
	shift
	;;
    x-N)
	bld=n
	shift
	;;
    x-r)
	if [ "x`echo \"$2\" | tr -d '[0-9]'`" != x ]; then
	    echo "$me: invalid retries $2"
	    exit 1
	fi
	retries=$2
	shift
	shift
	;;
    x-z)
	if [ "x`echo \"$2\" | tr -d '[0-9]'`" != x ]; then
	    echo "$me: invalid compression $2"
	    exit 1
	fi
	level=$2
	shift
	shift
	;;
    x-*)
	echo "usage: $me [-RkbN] [-r retries] [-z level] [modules]" >&2
	exit 1
	;;
    *)
	break
	;;
    esac
done

# This makes the command line module list available for quick testing.
# (It also gets us away from $* in case this is run on System V /bin/sh.)
modules="/`echo \"$*\" | sed 's/ /\//g'`/"

# encapsulates the checkout intelligence
cvs_get() {
    __cvs_get_lvl=$level
    __cvs_get_tries=$retries
    __cvs_get_rm=$rm
    __cvs_get_tag=
    while [ $# -ne 0 ]; do
	case "x$1" in
	x-r)
	    if [ $# -lt 2 ]; then
		echo "usage: cvs-get [-r tag] [-z level] [-c retries] [-RN] env pkg ..." >&2
		return 1
	    fi
	    __cvs_get_tag="$2"
	    shift
	    shift
	    ;;
	x-z)
	    if [ $# -lt 2 ]; then
		echo "usage: cvs-get [-r tag] [-z level] [-c retries] [-RN] env pkg ..." >&2
		return 1
	    fi
	    if [ "x`echo \"$2\" | tr -d '[0-9]'`" != x ]; then
		echo "cvs-get: invalid compression $2"
		return 1
	    fi
	    __cvs_get_lvl=$2
	    shift
	    shift
	    ;;
	x-c)
	    if [ $# -lt 2 ]; then
		echo "usage: cvs-get [-r tag] [-z level] [-c retries] [-RN] env pkg ..." >&2
		return 1
	    fi
	    if [ "x`echo \"$2\" | tr -d '[0-9]'`" != x ]; then
		echo "cvs-get: invalid retries $2"
		return 1
	    fi
	    __cvs_get_tries=$2
	    shift
	    shift
	    ;;
	x-R)
	    __cvs_get_rm=1
	    shift
	    ;;
	x-N)
	    __cvs_get_rm=n
	    shift
	    ;;
	x--)
	    shift
	    break
	    ;;
	x-*)
	    echo "usage: cvs-get [-r tag] [-z level] [-c retries] [-RN] env pkg ..." >&2
	    return 1
	    ;;
	*)
	    break
	    ;;
	esac
    done
    if [ $# -lt 2 ]; then
	echo "usage: cvs-get [-r tag] [-z level] [-c retries] [-RN] env pkg ..." >&2
	return 1
    fi
    if test ! -f ".ENV-$1"; then
	echo "cvs-get: .ENV-$1 not found" >&2
	return 1
    fi
    __cvs_get_root="`sed 's/^export CVSROOT=//' \".ENV-$1\"`"
    shift
    for dir in "$@"; do
	case "$modules" in
	//|*/"$dir"/*)
	    ;;
	*)
	    continue
	    ;;
	esac
	if [ $rm = y ]; then
	    echo "=== [$dir/pre-get] rm -rf $dir"
	    /bin/rm -rf "$dir"
	else
	    echo "=== [$dir/pre-get] find $dir -type d -name .deps -exec /bin/rm -rf {} ;"
	    find "$dir" -type d -name .deps -exec /bin/rm -rf '{}' ';' >/dev/null 2>&1
	fi
	# @@@@ workaround for CVS bug with submodules
	if test -f "$dir/CVS/Repository"; then
	    __cvs_get_hack="`cat \"$dir/CVS/Repository\"`"
	    find "$dir"/* -type d \( -name CVS -prune -o -print \) |
	    while read module; do
		test -f "$module/CVS/Repository" || continue
		case "`cat \"$module/CVS/Repository\"`" in
		"$__cvs_get_hack"/*)
		    ;;
		*)
		    echo "=== [$dir/get-cvshack] rm -rf $module"
		    /bin/rm -rf "$module"
		    ;;
		esac
	    done
	fi
	__cvs_get_cnt=$__cvs_get_tries
	while [ $__cvs_get_cnt -gt 0 ]; do
	    echo "=== [$dir/get] cvs -z$__cvs_get_lvl get ${__cvs_get_tag:+-r$__cvs_get_tag }$dir"
	    CVSROOT="$__cvs_get_root" cvs -z$__cvs_get_lvl get ${__cvs_get_tag:+"-r$__cvs_get_tag"} "$dir"
	    __cvs_get_err=$?
	    if [ $__cvs_get_err = 0 ]; then
		break
	    fi
	    echo "=== [$dir/get] Error $__cvs_get_err"
	    __cvs_get_cnt=`expr $__cvs_get_cnt - 1`
	done
	if [ $__cvs_get_err != 0 ]; then
	    echo "=== [$2/get] Too many retries; aborted"
	    break
	fi
    done
    return $__cvs_get_err
}

cvs_get -r FOR_PANEL gnome ORBit || exit 1
cvs_get -r GNOME_STABLE gnome gnome-libs gnome-core || exit 1
cvs_get gnome gtk-engines audiofile ee esound fnlib gdm glib gmedia \
	      gnome-games gnome-http gnome-media gtkicq ggv gnome-admin \
	      gnome-guile libPropList gnome-python gnome-pilot pilot-link \
	      gnome-network gnome-objc gnome-perl gnome-utils gnome-xml \
	      gtk+ gtop imlib libgtop mc stringlist gedit balsa || exit 1
cvs_get guile guile-core || exit 1

[ $bld = y ] && ./:BUILD -A

-- 
brandon s. allbery	[os/2][linux][solaris][japh]	 allbery@kf8nh.apk.net
system administrator	     [WAY too many hats]	   allbery@ece.cmu.edu
electrical and computer engineering					 KF8NH
carnegie mellon university	      ["God, root, what is difference?" -Pitr]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]