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