aboutsummaryrefslogtreecommitdiff
path: root/archivers
diff options
context:
space:
mode:
authorMarcus Alves Grando <mnag@FreeBSD.org>2005-10-23 02:39:33 +0000
committerMarcus Alves Grando <mnag@FreeBSD.org>2005-10-23 02:39:33 +0000
commitb5a4cbe2799979264df2deb84befee0c0eae03f8 (patch)
tree75adc12a6fa89eb62d2eee192ed7c9f34b3258b5 /archivers
parent848581688845cc87110119ecb6e65dd64c643946 (diff)
downloadports-b5a4cbe2799979264df2deb84befee0c0eae03f8.tar.gz
ports-b5a4cbe2799979264df2deb84befee0c0eae03f8.zip
Notes
Diffstat (limited to 'archivers')
-rw-r--r--archivers/p7zip/files/p7zip74
1 files changed, 74 insertions, 0 deletions
diff --git a/archivers/p7zip/files/p7zip b/archivers/p7zip/files/p7zip
new file mode 100644
index 000000000000..e360f3741f2d
--- /dev/null
+++ b/archivers/p7zip/files/p7zip
@@ -0,0 +1,74 @@
+#!/bin/sh
+# gzip-like CLI wrapper for p7zip
+set -e
+
+compress=true
+file=
+
+usage ()
+{
+ echo "Usage: $0 [-d] [-h|--help] [file]"
+ exit 1
+}
+
+while [ "$#" != "0" ] ; do
+ case "$1" in
+ -d) compress=false ;;
+ -c) echo "$0: ignoring $1 option (not yet implemented)" ;;
+ -h|--help) usage ;;
+ *)
+ if [ "${file}" = "" ] ; then
+ file="$1"
+ else
+ usage
+ fi
+ ;;
+ esac
+ shift
+done
+
+# make sure they're present, before we screw up
+for i in mktemp 7z rm cat tty ; do
+ if ! which $i > /dev/null ; then
+ echo "$0: $i: command not found"
+ exit 1
+ fi
+done
+
+if [ "${file}" != "" ] ; then
+ if ${compress} ; then
+ 7z a ${file}.7z ${file}
+ rm ${file}
+ else
+ case ${file} in
+ *.7z)
+ 7z x ${file}
+ rm ${file}
+ ;;
+ *)
+ echo "$0: ${file}: unknown suffix -- ignored"
+ ;;
+ esac
+ fi
+ exit 0
+fi
+
+P7ZTMP=${TMP:-/tmp}
+tmp=`mktemp ${P7ZTMP}/p7z.XXXXXXXX`
+trap "rm -f ${tmp}" 0
+
+if ${compress} ; then
+ if tty > /dev/null ; then
+ echo "$0: compressed data not written to a terminal."
+ echo "For help, type: $0 -h"
+ exit 1
+ fi
+ rm -f ${tmp}
+ 7z a ${tmp} -si >/dev/null
+ cat ${tmp}
+else
+ cat > ${tmp}
+ 7z x ${tmp} -so 2>/dev/null | cat
+fi
+
+rm -f ${tmp}