aboutsummaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorAndrew Pantyukhin <sat@FreeBSD.org>2008-05-06 16:17:01 +0000
committerAndrew Pantyukhin <sat@FreeBSD.org>2008-05-06 16:17:01 +0000
commit0b5ca793beff8c28adcf7b9e152880055899f8d0 (patch)
tree247cb8f13bf83d23cd384893fbef6cd8f1b231c7 /Tools
parentb9b5b02aa2c03f12eb89312c77348f36b7438de0 (diff)
downloadports-0b5ca793beff8c28adcf7b9e152880055899f8d0.tar.gz
ports-0b5ca793beff8c28adcf7b9e152880055899f8d0.zip
Notes
Diffstat (limited to 'Tools')
-rw-r--r--Tools/scripts/README1
-rwxr-xr-xTools/scripts/ardiff97
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"