1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#!/usr/bin/env bash
if test $# != 1 || ! test -d $1; then
echo "Usage: distcomp <path to alternate distribution>"
echo
echo "- call within source directory, e.g. dvdisaster-0.72"
echo "- make sure both are in distclean state"
exit 1
fi
HEAD_LINES=10
ref=$1
new=$(pwd)
# Make sure we're talking about same stuff
echo "Old distribution: $ref"
echo "New distribution: $new"
echo
# Looks for added files
ADDED=0
echo "Files and dirs ADDED in this distribution:"
for i in $(find .); do
if test -d $i && ! test -e $ref/$i; then
ADDED=$((ADDED+1))
echo " Dir : $i"
fi
if test -f $i && ! test -e $ref/$i; then
ADDED=$((ADDED+1))
echo " File: $i"
fi
done
if test $ADDED == 0; then
echo " None"
fi
# Looks for removed files
cd $ref
REMOVED=0
echo
echo "Files and dirs REMOVED in this distribution:"
for i in $(find .); do
if test -d $i && ! test -e $new/$i; then
REMOVED=$((REMOVED+1))
echo " Dir : $i"
fi
if test -f $i && ! test -e $new/$i; then
REMOVED=$((REMOVED+1))
echo " File: $i"
fi
done
if test $REMOVED == 0; then
echo " None"
fi
cd $new
CHANGED=0
echo
echo "Files CHANGED in this distribution:"
for i in $(find .); do
if test -f $i && test -f $ref/$i; then
if ! cmp -s $i $ref/$i; then
echo $i
diff $ref/$i $i | head -n $HEAD_LINES
echo
CHANGED=$((CHANGED+1))
fi
fi
done
if test $CHANGED == 0; then
echo " None"
fi
echo
if test $((CHANGED+ADDED+REMOVED)) == 0; then
echo "No changes."
else
echo "$CHANGED changed, $ADDED added and $REMOVED removed."
fi
|