From: Chris Koeritz Date: Fri, 15 Nov 2013 03:35:44 +0000 (-0500) Subject: nice new tester for archives, plus a renaming. X-Git-Tag: 2.140.90~869 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=dfe6c3aedd3487a00acf94683163be7ed0baa6da;p=feisty_meow.git nice new tester for archives, plus a renaming. --- diff --git a/scripts/archival/list_arch.sh b/scripts/archival/list_arch.sh new file mode 100644 index 00000000..eba1fc8f --- /dev/null +++ b/scripts/archival/list_arch.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +############## +# Name : list_arch +# Author : Chris Koeritz +# Rights : Copyright (C) 2012-$now by Feisty Meow Concerns, Ltd. +############## +# This script is free software; you can modify/redistribute it under the terms +# of the GNU General Public License. [ http://www.gnu.org/licenses/gpl.html ] +# Feel free to send updates to: [ fred@gruntose.com ] +############## +# +# An arbitrary format archive lister, although really we are mainly supporting +# tar and zip currently, including compressed formats. + +archive_file="$1"; shift +if [ -z "$archive_file" ]; then + echo "This script takes one archive name (in .tar.gz, .zip, etc. formats) and" + echo "lists the archive with the appropriate tool." + exit 1 +fi +if [ ! -f "$archive_file" ]; then + echo "The file specified cannot be located: $archive_file" + exit 1 +fi + +if [ -z "$PAGER" ]; then + PAGER=$(which less) + if [ -z "$PAGER" ]; then + PAGER=$(which more) + if [ -z "$PAGER" ]; then + PAGER="cat" + fi + fi +fi + +# save where we started out. +ORIGINATING_FOLDER="$( \pwd )" + +if [ ! -f "$archive_file" ]; then + # we're assuming we left it behind in our previous directory. + archive_file="$ORIGINATING_FOLDER/$archive_file" + if [ ! -f "$archive_file" ]; then + echo "Could not find file to unpack after shifting directories. Sorry." + echo "Tried to locate it as: $archive_file" + exit 1 + fi +fi + +if [[ $archive_file =~ .*\.tar$ \ + || $archive_file =~ .*\.tar\.gz$ \ + || $archive_file =~ .*\.tar\.bz2$ \ + || $archive_file =~ .*\.iar$ \ + || $archive_file =~ .*\.oar$ \ + || $archive_file =~ .*\.tgz$ \ + || $archive_file =~ .*\.ova$ \ + || $archive_file =~ .*\.snarf$ \ + ]]; then + tar -tf $archive_file | $PAGER +elif [[ $archive_file =~ .*\.zip$ \ + || $archive_file =~ .*\.epub$ \ + || $archive_file =~ .*\.odt$ \ + || $archive_file =~ .*\.jar$ \ + || $archive_file =~ .*\.war$ \ + ]]; then + unzip -v $archive_file | $PAGER +fi diff --git a/scripts/archival/listarch.sh b/scripts/archival/listarch.sh deleted file mode 100644 index 972295c0..00000000 --- a/scripts/archival/listarch.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -############## -# Name : listarch -# Author : Chris Koeritz -# Rights : Copyright (C) 2012-$now by Feisty Meow Concerns, Ltd. -############## -# This script is free software; you can modify/redistribute it under the terms -# of the GNU General Public License. [ http://www.gnu.org/licenses/gpl.html ] -# Feel free to send updates to: [ fred@gruntose.com ] -############## -# -# An arbitrary format archive lister, although really we are mainly supporting -# tar and zip currently, including compressed formats. - -archive_file="$1"; shift -if [ -z "$archive_file" ]; then - echo "This script takes one archive name (in .tar.gz, .zip, etc. formats) and" - echo "lists the archive with the appropriate tool." - exit 1 -fi -if [ ! -f "$archive_file" ]; then - echo "The file specified cannot be located: $archive_file" - exit 1 -fi - -if [ -z "$PAGER" ]; then - PAGER=$(which less) - if [ -z "$PAGER" ]; then - PAGER=$(which more) - if [ -z "$PAGER" ]; then - PAGER="cat" - fi - fi -fi - -# save where we started out. -ORIGINATING_FOLDER="$( \pwd )" - -if [ ! -f "$archive_file" ]; then - # we're assuming we left it behind in our previous directory. - archive_file="$ORIGINATING_FOLDER/$archive_file" - if [ ! -f "$archive_file" ]; then - echo "Could not find file to unpack after shifting directories. Sorry." - echo "Tried to locate it as: $archive_file" - exit 1 - fi -fi - -if [[ $archive_file =~ .*\.tar$ \ - || $archive_file =~ .*\.tar\.gz$ \ - || $archive_file =~ .*\.tar\.bz2$ \ - || $archive_file =~ .*\.iar$ \ - || $archive_file =~ .*\.oar$ \ - || $archive_file =~ .*\.tgz$ \ - || $archive_file =~ .*\.ova$ \ - || $archive_file =~ .*\.snarf$ \ - ]]; then - tar -tf $archive_file | $PAGER -elif [[ $archive_file =~ .*\.zip$ \ - || $archive_file =~ .*\.epub$ \ - || $archive_file =~ .*\.odt$ \ - || $archive_file =~ .*\.jar$ \ - || $archive_file =~ .*\.war$ \ - ]]; then - unzip -v $archive_file | $PAGER -fi diff --git a/scripts/archival/search_arch.sh b/scripts/archival/search_arch.sh index 7b2761ff..68ec6856 100644 --- a/scripts/archival/search_arch.sh +++ b/scripts/archival/search_arch.sh @@ -32,7 +32,7 @@ find "$dir" -iname "*.jar" -o -iname "*.zip" -o -iname "*.tar" \ >"$TMPFILE" while read line; do - bash $FEISTY_MEOW_SCRIPTS/archival/listarch.sh "$line" 2>&1 | grep -i "$pattern" >/dev/null + bash $FEISTY_MEOW_SCRIPTS/archival/list_arch.sh "$line" 2>&1 | grep -i "$pattern" >/dev/null if [ $? -eq 0 ]; then echo ==== Found pattern in $line ====; fi done <"$TMPFILE" diff --git a/scripts/archival/test_arch.sh b/scripts/archival/test_arch.sh new file mode 100644 index 00000000..be1fddb4 --- /dev/null +++ b/scripts/archival/test_arch.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +############## +# Name : test_arch +# Author : Chris Koeritz +# Rights : Copyright (C) 2012-$now by Feisty Meow Concerns, Ltd. +############## +# This script is free software; you can modify/redistribute it under the terms +# of the GNU General Public License. [ http://www.gnu.org/licenses/gpl.html ] +# Feel free to send updates to: [ fred@gruntose.com ] +############## +# +# An arbitrary format archive tester, although really we are mainly supporting +# tar and zip currently, including compressed formats. + +archive_file="$1"; shift +if [ -z "$archive_file" ]; then + echo "This script takes one archive name (in .tar.gz, .zip, etc. formats) and" + echo "tests the archive with the appropriate tool." + exit 1 +fi +if [ ! -f "$archive_file" ]; then + echo "The file specified cannot be located: $archive_file" + exit 1 +fi + +# save where we started out. +ORIGINATING_FOLDER="$( \pwd )" + +if [ ! -f "$archive_file" ]; then + # we're assuming we left it behind in our previous directory. + archive_file="$ORIGINATING_FOLDER/$archive_file" + if [ ! -f "$archive_file" ]; then + echo "Could not find file to unpack after shifting directories. Sorry." + echo "Tried to locate it as: $archive_file" + exit 1 + fi +fi + +if [[ $archive_file =~ .*\.tar$ \ + || $archive_file =~ .*\.tar\.gz$ \ + || $archive_file =~ .*\.tar\.bz2$ \ + || $archive_file =~ .*\.iar$ \ + || $archive_file =~ .*\.oar$ \ + || $archive_file =~ .*\.tgz$ \ + || $archive_file =~ .*\.ova$ \ + || $archive_file =~ .*\.snarf$ \ + ]]; then + tar -tf $archive_file &>/dev/null +elif [[ $archive_file =~ .*\.zip$ \ + || $archive_file =~ .*\.epub$ \ + || $archive_file =~ .*\.odt$ \ + || $archive_file =~ .*\.jar$ \ + || $archive_file =~ .*\.war$ \ + ]]; then + unzip -t $archive_file &>/dev/null +else + # we don't know this as an archive. + exit 0 +fi + +if [ $? -ne 0 ]; then + echo "** failure while testing: $archive_file" + exit 1 +else + echo "good: $archive_file" +fi +