Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Oct 2005 22:05:44 +0200
From:      Juergen Lock <nox@jelal.kn-bremen.de>
To:        Robert Millan <rmh@aybabtu.com>
Cc:        ports@freebsd.org
Subject:   Re: gzip-like CLI wrapper for p7zip
Message-ID:  <20051018200544.GA26528@saturn.kn-bremen.de>
In-Reply-To: <20051018140137.GA16159@aragorn>
References:  <20051018140137.GA16159@aragorn>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Oct 18, 2005 at 04:01:37PM +0200, Robert Millan wrote:
> 
> Hi,
> 
> I a small gzip-like wrapper for p7zip.  The upstream developers don't seem to
> like the idea, but it is going to be included in Debian, and I thought you might
> want to provide it as well.  For details, see:
> 
>   http://bugs.debian.org/334106
> 
>   (the script is attached there)
> 
> We intend to ask the gnu tar maintainers for a p7zip flag.  Having this script
> in the FreeBSD port would help in that regard.

Well I could add it to the port (see below), but I think the need for
tempfiles is unfortunate because it can cause problems like /tmp
filling up.  Maybe the 7z lib that cloop uses [1] [2] could be used
for a `real' tempfile-less p7zip?  (I dont know the 7z file format,
maybe a new format has to be created in order to require no seeking,
meaning the extension would have to be changed as well. (like gzip
had to do with the zip format.)  so maybe we shouldn't standardize
on a p7zip command just yet...)

[1]	http://advancemame.sourceforge.net/comp-readme.html
[2]	http://www.morphix.org/debian/source/cloop_2.01-6.tar.gz

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/archivers/p7zip/Makefile,v
retrieving revision 1.13
diff -u -r1.13 Makefile
--- Makefile	15 Oct 2005 12:47:26 -0000	1.13
+++ Makefile	18 Oct 2005 18:55:50 -0000
@@ -7,6 +7,7 @@
 
 PORTNAME=	p7zip
 PORTVERSION=	4.29
+PORTREVISION=	1
 CATEGORIES=	archivers
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	p7zip
@@ -65,6 +66,7 @@
 .endfor
 	${INSTALL_SCRIPT} ${FILESDIR}/7z ${PREFIX}/bin
 	${LN} -sf 7z ${PREFIX}/bin/7za
+	${INSTALL_SCRIPT} ${FILESDIR}/p7zip ${PREFIX}/bin
 .if !defined(WITHOUT_MODULES)
 .for f in Codecs Formats
 	${MKDIR} ${DLLDIR}/${f}
Index: pkg-plist
===================================================================
RCS file: /home/ncvs/ports/archivers/p7zip/pkg-plist,v
retrieving revision 1.6
diff -u -r1.6 pkg-plist
--- pkg-plist	15 Oct 2005 12:47:26 -0000	1.6
+++ pkg-plist	18 Oct 2005 18:56:38 -0000
@@ -1,5 +1,6 @@
 @unexec /bin/rm -f %D/bin/7za
 bin/7z
+bin/p7zip
 @exec /bin/ln -sf 7z %D/bin/7za
 %%MODULES%%libexec/p7zip/7z
 libexec/p7zip/7za
Index: 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}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051018200544.GA26528>