From 11736016c80f3f0bfdc143b05d38b445f7002c0a Mon Sep 17 00:00:00 2001 From: anomen Date: Sat, 29 Dec 2012 17:27:59 +0100 Subject: [PATCH] mivvy - customs - /usr/local/bin --- mivvy/customs/usr/local/bin/chmod.std | 5 +++ mivvy/customs/usr/local/bin/decwin | 15 +++++++ mivvy/customs/usr/local/bin/svn.addall | 4 ++ mivvy/customs/usr/local/bin/treecmp | 48 ++++++++++++++++++++++ mivvy/customs/usr/local/bin/treeprune | 16 ++++++++ mivvy/customs/usr/local/bin/unzipd | 18 ++++++++ .../usr/local/lib/anomen-toolset/treecmp.diff.sh | 42 +++++++++++++++++++ .../usr/local/lib/anomen-toolset/treecmp.sha.sh | 46 +++++++++++++++++++++ 8 files changed, 194 insertions(+) create mode 100755 mivvy/customs/usr/local/bin/chmod.std create mode 100755 mivvy/customs/usr/local/bin/decwin create mode 100755 mivvy/customs/usr/local/bin/svn.addall create mode 100755 mivvy/customs/usr/local/bin/treecmp create mode 100755 mivvy/customs/usr/local/bin/treeprune create mode 100755 mivvy/customs/usr/local/bin/unzipd create mode 100755 mivvy/customs/usr/local/lib/anomen-toolset/treecmp.diff.sh create mode 100755 mivvy/customs/usr/local/lib/anomen-toolset/treecmp.sha.sh diff --git a/mivvy/customs/usr/local/bin/chmod.std b/mivvy/customs/usr/local/bin/chmod.std new file mode 100755 index 0000000..4e43be6 --- /dev/null +++ b/mivvy/customs/usr/local/bin/chmod.std @@ -0,0 +1,5 @@ +#! /bin/sh +echo chmod 755 DIRS... +find . -type d -exec chmod 755 '{}' ';' +echo chmod 644 FILES... +find . -type f -exec chmod 644 '{}' ';' diff --git a/mivvy/customs/usr/local/bin/decwin b/mivvy/customs/usr/local/bin/decwin new file mode 100755 index 0000000..ec44b6d --- /dev/null +++ b/mivvy/customs/usr/local/bin/decwin @@ -0,0 +1,15 @@ +#! /bin/sh + +for A do + + AB=`basename "$A"` + TEMP=`mktemp -t "${AB}.XXXXXX"` + BAK=`mktemp -t "${AB}.XXXXXX"` + + iconv -f windows-1250 "$A" > "$TEMP" + + mv -f "$A" "$BAK" + + mv "$TEMP" "$A" + +done diff --git a/mivvy/customs/usr/local/bin/svn.addall b/mivvy/customs/usr/local/bin/svn.addall new file mode 100755 index 0000000..74cb296 --- /dev/null +++ b/mivvy/customs/usr/local/bin/svn.addall @@ -0,0 +1,4 @@ +#!/bin/sh + + svn add `svn stat | sed -n -e 's/$/@HEAD/;s/^\?//p' ` + diff --git a/mivvy/customs/usr/local/bin/treecmp b/mivvy/customs/usr/local/bin/treecmp new file mode 100755 index 0000000..6227035 --- /dev/null +++ b/mivvy/customs/usr/local/bin/treecmp @@ -0,0 +1,48 @@ +#! /bin/sh + +TPATH=/usr/local/lib/anomen-toolset + +if [ -z "$1" ] +then + echo "Removes same files from src/current directory." + echo "arguments: [source_dir] dest_dir" + exit 1 +fi + +SRCDIR="$1" +DESTDIR="$2" + +if [ -z "$2" ] +then + SRCDIR=`pwd` + DESTDIR="$1" +fi + +if [ ! -d "$SRCDIR" ] +then + echo "Specified source directory does not exist ($SRCDIR)" + exit 2 +fi + +if [ ! -d "$DESTDIR" ] +then + echo "Specified destination directory does not exist ($DESTDIR)" + exit 3 +fi + +if [ "$SRCDIR" -ef "$DESTDIR" ] +then + echo "WARNING: source and destination directories are same!" + exit 4 +fi + +find "$SRCDIR" -type f -exec $TPATH/treecmp.sha.sh "$SRCDIR" "$DESTDIR" '{}' ';' + + +DODIFF=`expr match "$0" '.*treecmp\(d\)$'` + +if [ -n "$DODIFF" ] +then + echo "##DIFF" + find "$SRCDIR" -type f -exec $TPATH/treecmp.diff.sh "$SRCDIR" "$DESTDIR" '{}' ';' +fi diff --git a/mivvy/customs/usr/local/bin/treeprune b/mivvy/customs/usr/local/bin/treeprune new file mode 100755 index 0000000..2b520ea --- /dev/null +++ b/mivvy/customs/usr/local/bin/treeprune @@ -0,0 +1,16 @@ +#! /bin/sh + +if [ "$1" == "-h" ] +then + echo "Removes empty directories from given directory" + echo "arguments: [dir]" + exit 1 + +else if [ -n "$1" ] +then + cd "$1" +fi + +fi + +find . -depth -mindepth 1 -type d -print -exec rmdir --ignore-fail-on-non-empty '{}' ';' diff --git a/mivvy/customs/usr/local/bin/unzipd b/mivvy/customs/usr/local/bin/unzipd new file mode 100755 index 0000000..1f82437 --- /dev/null +++ b/mivvy/customs/usr/local/bin/unzipd @@ -0,0 +1,18 @@ +#!/bin/sh + +if test '!' -f "$1" ; then + echo zip filename expected + exit 1 +fi + +F="$1" +D=${F%.zip} + +echo $D + +if test -e "$D" ; then + echo "Target \"$D\" already exists" + exit 2 +fi + +exec unzip -d "$D" "$F" diff --git a/mivvy/customs/usr/local/lib/anomen-toolset/treecmp.diff.sh b/mivvy/customs/usr/local/lib/anomen-toolset/treecmp.diff.sh new file mode 100755 index 0000000..fe78255 --- /dev/null +++ b/mivvy/customs/usr/local/lib/anomen-toolset/treecmp.diff.sh @@ -0,0 +1,42 @@ +#! /bin/sh + +# NOT TO BE CALLED DIRECTLY + +# removes same files from SRC directory +#used by the "treecmp" script + +# args: srcdir, destdir, file_in_srcdir + +DL=`expr length "$1"` +FL=`expr length "$3"` +FNL=`expr $FL '-' $DL` + +FN=`expr substr "$3" '(' $DL '+' 2 ')' $FNL ` + +if [ "$1" '!=' "`expr substr "$3" 1 $DL`" ] +then + echo "INVALID FILE: $3 !!!" + exit 1 +fi + +if [ ! -f "$2/$FN" ] +then + echo "D MISS: $2/$FN" + exit 2 +fi + +#echo "#########" +#echo "$FN" + +#echo "$1 / $2 / $3" +DIFF=`diff -wu "$1/$FN" "$2/$FN" | wc -l` + +if [ 0 -eq "$DIFF" ] +then +# echo "same $FN ($SUM1)" + echo "D KILL: $FN" + rm -f "$1/$FN" +else +#echo "" + echo "D DIFF: $FN" +fi diff --git a/mivvy/customs/usr/local/lib/anomen-toolset/treecmp.sha.sh b/mivvy/customs/usr/local/lib/anomen-toolset/treecmp.sha.sh new file mode 100755 index 0000000..10eadac --- /dev/null +++ b/mivvy/customs/usr/local/lib/anomen-toolset/treecmp.sha.sh @@ -0,0 +1,46 @@ +#! /bin/sh + +# NOT TO BE CALLED DIRECTLY + +# removes same files from SRC directory +#used by the "treecmp" script + +# args: srcdir, destdir, file_in_srcdir + +DL=`expr length "$1"` +FL=`expr length "$3"` +FNL=`expr $FL '-' $DL` + +FN=`expr substr "$3" '(' $DL '+' 2 ')' $FNL ` + +if [ "$1" '!=' "`expr substr "$3" 1 $DL`" ] +then + echo "INVALID FILE: $3 !!!" + exit 1 +fi + +if [ ! -f "$2/$FN" ] +then + echo "S MISS: $2/$FN" + exit 2 +fi + +#echo "#########" +#echo "$FN" + +#echo "$1 / $2 / $3" +SUM1=`sha1sum "$1/$FN"` +SUM2=`sha1sum "$2/$FN"` + +S1=`expr substr "$SUM1" 1 40` +S2=`expr substr "$SUM2" 1 40` + +if [ "$S1" = "$S2" ] +then +# echo "same $FN ($SUM1)" + echo "S KILL: $FN" + rm -f "$1/$FN" +else +#echo "" + echo "S DIFF: $FN" +fi -- 2.11.4.GIT