#!/bin/sh # $Id: verify-revisions.sh 280 2010-08-19 15:57:27Z stsp $ # Copyright 2010 Stefan Sperling , elego Software Solutions GmbH # # Permission to use, copy, modify, and/or 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 checks all revisions in one or more Subversion FSFS repositories, # using fsfsverify.py. if [ -z "$1" ] then echo "Usage: `basename $0` repos1 [repos2 ...]" exit 1 fi # Select a UNIX tool to produce numerical sequences if which seq >/dev/null 2>/dev/null then _seq="`which seq`" elif which jot >/dev/null 2>/dev/null then _seq="`which jot`" else echo "No tool for producing numerical sequences found in \$PATH" echo "Please install one of these tools: seq, jot" exit 1 fi # Make sure fsfsverify.py is in $PATH if ! which fsfsverify.py >/dev/null 2>/dev/null then echo -n "fsfsverify.py not found in \$PATH - " echo -n "please get fsfsverify.py from " echo "http://svn.apache.org/repos/asf/subversion/trunk/contrib/server-side/fsfsverify.py" exit 1 fi let n_repos=0 for repository in "$@" do head_rev="`svnlook youngest \"$repository\"`" if [ -z "$head_rev" ] then echo -n "Cannot determine HEAD revision of repository " echo "$repository - skipping" continue fi if [ "$head_rev" == "0" ] then echo "Repository $repository has zero revisions - skipping" continue fi if [ "`cat $repository/db/fs-type`" != "fsfs" ] then echo -n "Repository $repository " echo "does not use an FSFS database - skipping" continue fi # Check if the repository is sharded layout_sharded=`grep "^layout sharded" "$repository/db/format"` if [ -n "$layout_sharded" ] then shards="`echo $layout_sharded | \ sed -e 's/layout sharded \([0-9]*\)/\1/'`" if [ -z "$shards" ] then echo -n "Repository $repository seems to be shared, " echo -n "but could not determine number of shards - " echo "skipping" continue fi else shards="" fi bad_revs="" for revision in `$_seq $head_rev` do if [ -n "$shards" ] then shard_dir="`expr $revision / $shards`" else shard_dir="" fi if [ -f "$repository/db/revs/${shard_dir}.pack" ] then echo -n "Repository $repository has packing enabled " echo "but fsfsverify.py does not support packed FSFS " echo "repositories - skipping" break fi echo -n "Checking $repository r${revision}: " fsfsverify.py "$repository/db/revs/$shard_dir/$revision" >/dev/null if [ "$?" != "0" ] then echo "BAD" bad_revs="$bad_revs $revision" else echo "ok" fi done let n_repos="`expr $n_repos + 1`" if [ -n "$bad_revs" ] then this_bad_repos="The following revisions of $repository" this_bad_repos="$this_bad_repos are bad: $bad_revs" echo "$this_bad_repos" all_bad_repos="${all_bad_repos}$this_bad_repos\n" fi done if [ $n_repos -gt 1 ] then echo echo "Summary:" echo "$all_bad_repos" fi