#!/bin/sh # # cvs-watch.sh - script for watching anonymous CVS repositories # # Developed by Ondrej Jombik # Copyright (c) 2003 Platon SDG, http://platon.sk/ # Licensed under terms of GNU General Public License. # All rights reserved. # # Changelog: # 17/07/2003 - created # # $Platon: scripts/shell/cvs-watch/cvs-watch.sh,v 1.1 2003/07/17 10:45:51 nepto Exp $ REPOSITORIES_FILE="./REPOSITORIES"; DOT_CHECKOUT_FILE="DOT_CHECKOUT_DONE"; # # Notice function # function notice() { echo "$1"; } # # ChDir back function # function cd_back() { dir=` echo "$1/" | sed 's/\/\+/\//g; s/\.\///g;' `; while [ "X" != "X$dir" ]; do echo $dir; cd ../; dir=` echo "$dir" | sed 's/^[^\/]*\///g;' `; done } if [ ! -r "$REPOSITORIES_FILE" ]; then notice "no '$REPOSITORIES_FILE' file found, aborting..."; exit 1; fi while read line; do line=` echo "$line" | sed 's/^[ ]*//g; s/[ ]*$//g;' `; firstchar=` echo "$line" | sed 's/^\(.\).*$/\1/g;' `; if [ "X" = "X$firstchar" -o "X#" = "X$firstchar" ]; then continue; fi directory=` echo "$line" | sed 's/[ ]\+.*$//g;' `; authstring=` echo "$line" | sed 's/^[^ ]\+[ ]\+//g; s/[ ]\+.*$//g;' `; objects=` echo "$line" | sed 's/^[^ ]\+[ ]\+//g; s/^[^ ]\+[ ]*//g;' `; notice "PROCESSING $directory"; if [ "X" = "X$objects" ]; then objects="$directory"; directory=""; else directory="$directory/"; fi if [ "X$directory" != "X" ]; then if [ ! -e "$directory" ]; then notice "directory '$directory' does not exists, creating..."; mkdir -p "$directory"; fi if [ ! -d "$directory" ]; then notice "file '$directory' is not an accessible directory, skipping..."; continue; fi cd $directory || continue; fi for i in $objects; do i=` echo "$i" | sed 's/\/*$//g' `; if [ ! -d "$i" -o \( "$i" = "." -a ! -f "$DOT_CHECKOUT_FILE" \) ]; then notice "perfoming an initial checkout for $directory$i"; cvs -d "$authstring" checkout $i && ( if [ "$i" = "." ]; then > $DOT_CHECKOUT_FILE; fi ); else notice "updating $directory$i"; cd $i || continue; cvs -d "$authstring" update; cd_back "$i"; fi done if [ "X$directory" != "X" ]; then cd_back $directory; fi #echo "$directory - $authstring - $objects"; done < $REPOSITORIES_FILE;