diff options
author | sat <sat@FreeBSD.org> | 2008-05-07 00:17:01 +0800 |
---|---|---|
committer | sat <sat@FreeBSD.org> | 2008-05-07 00:17:01 +0800 |
commit | 6df7861e808907e0aa8d2fe2263dfa3738363360 (patch) | |
tree | 6c47fbdfc64b204ea69834f8c5837cce967bff98 /Tools/scripts | |
parent | c3e4dabdba17abbfec7d09b4d76c25ecd32522ea (diff) | |
download | freebsd-ports-gnome-6df7861e808907e0aa8d2fe2263dfa3738363360.tar.gz freebsd-ports-gnome-6df7861e808907e0aa8d2fe2263dfa3738363360.tar.zst freebsd-ports-gnome-6df7861e808907e0aa8d2fe2263dfa3738363360.zip |
Add a tiny sh hack - ardiff - compares two archives.
Diffstat (limited to 'Tools/scripts')
-rw-r--r-- | Tools/scripts/README | 1 | ||||
-rwxr-xr-x | Tools/scripts/ardiff | 97 |
2 files changed, 98 insertions, 0 deletions
diff --git a/Tools/scripts/README b/Tools/scripts/README index 46474fdafb8d..54578c86b49e 100644 --- a/Tools/scripts/README +++ b/Tools/scripts/README @@ -1,5 +1,6 @@ $FreeBSD$ +ardiff - compare two archives easily addport - replacement for easy-import bump_revision.pl - Small script to bump the PORTREVISION variable of ports which are depending on a port with a changed shared lib diff --git a/Tools/scripts/ardiff b/Tools/scripts/ardiff new file mode 100755 index 000000000000..1840ec0d4001 --- /dev/null +++ b/Tools/scripts/ardiff @@ -0,0 +1,97 @@ +#!/bin/sh + +# +# ardiff tries to make it easy for you to compare two archives. It makes no +# claims about originality, correctness or usefulness, but it saved a lot of +# time for at least one port maintainer. +# +# DEPS: vim, p7zip +# TODO: word-by-word, more intelligent diffs +# + +usage () { + if [ "$#" -gt 0 ]; then + echo "Error: $*" >&2 + fi + echo "Usage: $0 <archive1> <archive2>" >&2 + exit 0 +} + +debug () { + echo "Debug: $*" >&2 +} + +die () { + echo "Fatal: $*" >&2 + exit 2 +} + +extract () { + if [ "$#" != 2 ]; then + die "extract () miscalled" >&2 + fi + cd $2 + if tar tf $1 >&-; then + debug "file $1 looks like a good tar archive" + tar xf $1 && debug "file $1 untar'ed successfully" || die "file $1 failed to untar" + elif 7z t $1 >&-; then + debug "file $1 looks like a good non-tar archive" + 7z x $1 >&- && debug "file $1 un7z'ed successfully" || die "file $1 failed to un7z" + else + die "file $1 was not recognized" + fi +} + +if [ "$#" != "2" ]; then + usage +fi + +ar1=`realpath $1` +ar2=`realpath $2` + +for i in $ar1 $ar2;do if [ ! -r $i ]; then + usage "file \"$i\" unreadable" +fi;done + +for i in tar 7z;do if [ ! -x `which $i` ]; then + die "missing a decompressor, please make sure tar and 7z are available" +fi;done +if [ ! -x `which vim` ]; then + die "missing vim, please install it" +fi + +art1=`mktemp -d -t /tmp` && debug "created tmp dir $art1" || usage "could not create a tmp dir" +art2=`mktemp -d -t /tmp` && debug "created tmp dir $art2" || usage "could not create a tmp dir" + +extract $ar1 $art1 +extract $ar2 $art2 + +if [ "`ls $art1|wc -l`" -eq 1 ]; then + dart1=$art1/`ls $art1|head -n1` +else + dart1=$art1 +fi +if [ "`ls $art2|wc -l`" -eq 1 ]; then + dart2=$art2/`ls $art2|head -n1` +else + dart2=$art2 +fi +#if [ "`ls $art1|wc -l`" -eq 1 ]&&[ "`ls $art2|wc -l`" -eq 1 ]; then +# dart1=$art1/`ls $art1|head -n1` +# dart2=$art2/`ls $art2|head -n1` +#else +# dart1=$art1 +# dart2=$art2 +#fi + +{ + echo "====== Appeared and disappeared ======" + diff -urq $dart1 $dart2|sed -e "s|$art1|OLD|;s|$art2|NEW|"|grep '^Only' + echo "====== Modified ======" + diff -urq $dart1 $dart2|sed -e "s|$art1|OLD|;s|$art2|NEW|"|grep -v '^Only' + echo "====== Modifications ======" + diff -ur $dart1 $dart2|sed -e "s|$art1|OLD|;s|$art2|NEW|" +}|vim -R -c "syntax on" -c "set syntax=diff" -c "set nowrap" \ + -c 'let @/="^--- "' -c "set so=20" - + +rm -rf $art1 $art2 && debug "removed tmp dirs" |