projects
/
feisty_meow.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added docs for year in calendar format
[feisty_meow.git]
/
scripts
/
archival
/
unpack.sh
diff --git
a/scripts/archival/unpack.sh
b/scripts/archival/unpack.sh
index 1389d1e7a59c0a33145f8a503b42dee35b64f5c8..b67ac9788a56eaabbf00af64ac58bc3e2e35cdad 100644
(file)
--- a/
scripts/archival/unpack.sh
+++ b/
scripts/archival/unpack.sh
@@
-11,7
+11,7
@@
##############
#
# An arbitrary format archive unpacker, although really we are mainly supporting
##############
#
# An arbitrary format archive unpacker, although really we are mainly supporting
-# tar
and zip currently, including compressed formats
.
+# tar
, zip, 7z, and rar at this time
.
archive_file="$1"; shift
if [ -z "$archive_file" ]; then
archive_file="$1"; shift
if [ -z "$archive_file" ]; then
@@
-30,7
+30,7
@@
if [ -z "$unpack_dir" ]; then
fi
if [ ! -d "$unpack_dir" ]; then
fi
if [ ! -d "$unpack_dir" ]; then
- mkdir "$unpack_dir"
+ mkdir
-p
"$unpack_dir"
if [ $? -ne 0 ]; then
echo "Could not create the unpacking directory: $unpack_dir"
exit 1
if [ $? -ne 0 ]; then
echo "Could not create the unpacking directory: $unpack_dir"
exit 1
@@
-52,16
+52,27
@@
if [ ! -f "$archive_file" ]; then
fi
fi
fi
fi
+#hmmm: we could log to a file and spew the file if there's a failure, then
+# remove the file after spewing or after successful run.
+# this is a really commonly repeated pattern that would be nice to support
+# in general.
+
+# record what happened.
+save_err=1
if [[ "$archive_file" =~ .*\.tar$ \
|| "$archive_file" =~ .*\.tar\.gz$ \
|| "$archive_file" =~ .*\.tar\.bz2$ \
if [[ "$archive_file" =~ .*\.tar$ \
|| "$archive_file" =~ .*\.tar\.gz$ \
|| "$archive_file" =~ .*\.tar\.bz2$ \
+ || "$archive_file" =~ .*\.tar\.xz$ \
|| "$archive_file" =~ .*\.iar$ \
|| "$archive_file" =~ .*\.oar$ \
|| "$archive_file" =~ .*\.iar$ \
|| "$archive_file" =~ .*\.oar$ \
+ || "$archive_file" =~ .*\.tbz$ \
|| "$archive_file" =~ .*\.tgz$ \
|| "$archive_file" =~ .*\.tgz$ \
+ || "$archive_file" =~ .*\.txz$ \
|| "$archive_file" =~ .*\.ova$ \
|| "$archive_file" =~ .*\.snarf$ \
]]; then
tar -xf "$archive_file" &>/dev/null
|| "$archive_file" =~ .*\.ova$ \
|| "$archive_file" =~ .*\.snarf$ \
]]; then
tar -xf "$archive_file" &>/dev/null
+ save_err=$?
elif [[ "$archive_file" =~ .*\.zip$ \
|| "$archive_file" =~ .*\.epub$ \
|| "$archive_file" =~ .*\.odt$ \
elif [[ "$archive_file" =~ .*\.zip$ \
|| "$archive_file" =~ .*\.epub$ \
|| "$archive_file" =~ .*\.odt$ \
@@
-69,8
+80,14
@@
elif [[ "$archive_file" =~ .*\.zip$ \
|| "$archive_file" =~ .*\.war$ \
]]; then
unzip "$archive_file" &>/dev/null
|| "$archive_file" =~ .*\.war$ \
]]; then
unzip "$archive_file" &>/dev/null
+ save_err=$?
+elif [[ "$archive_file" =~ .*\.7z$ ]]; then
+ 7z x "$archive_file" &>/dev/null
+ save_err=$?
+elif [[ "$archive_file" =~ .*\.rar$ ]]; then
+ unrar x "$archive_file" &>/dev/null
+ save_err=$?
fi
fi
-save_err=$?
popd &>/dev/null
popd &>/dev/null