Page 1 of 2

Improving The Wrappers From Xarchive

Posted: Fri 11 Jun 2010, 12:41
by abushcrafter
My aim is for all the formats that Peazip supports for Xarchiver to support too. I could do with a lot of help with adding the formats left as my bash knowledge is near to none.

Achievements:
One of the new formats that xarchive can now support is PET at last! It only need 4 extra characters added to the tar-wrap.sh!

Green means format is tested and should work.

To Do:

Add support for:
  • swf
  • SLP (Stampede Linux packages)
  • pea
Check wherever these added formats work:
  • 7zip-wrap.sh
  • gnm
  • 7z
  • cab
  • chm
  • cpio
  • dmg
  • hfs
  • iso
  • lzh
  • msi
  • nsis
  • udf
  • wim
  • xar
  • exe
  • swm
  • chw
  • hxs
  • zip-wrap.sh
  • ear
  • war
  • pak
  • pk3
  • pk4
  • smzip
  • up3
  • xpi
  • ods
  • ots
  • odb
  • odf
  • odg
  • otg
  • odp
  • otp
  • odt
  • ott
  • oth
  • odm
  • odt
  • oxt
  • pup
tar-wrap.sh
  • tar.7z
  • pet
  • tar.xz/txz/pxt (Added: Sun13/6/2010 Version:002)
  • (NEW: Wed7/7/2010 Version:003)tar.lzma, tar.lz, tlz
(NEW: Sat25/9/2010) lha-wrap.sh
  • lha
  • lzh
(NEW: Sat25/9/2010) uu-wrap.sh
  • uu
(NEW: Sat25/9/2010) zoo-wrap.sh
  • zoo
(NEW: THU26/5/2011) pupzip
  • shar
Latest version of p7zip binary is here:
Puppy Linux Discussion Forum :: View topic - [PET] p7zip 9.13 Full

Latest version of ZOO binary is here:
Puppy Linux Discussion Forum :: View topic - [PET] ZOO 2.10-21

Latest version of LHA binary is here:
Puppy Linux Discussion Forum :: View topic - [PET] LHA 1.17

To use, extract to "/".

PV=Package Version

Posted: Fri 11 Jun 2010, 17:31
by sc0ttman
Good luck with this, great idea.. if I knew how to help, I would..

Maybe the authors of unrar, undeb, etc, can post their wrappers as examples?

Posted: Fri 11 Jun 2010, 20:33
by abushcrafter
sc0ttman wrote:Maybe the authors of unrar, undeb, etc, can post their wrappers as examples?
Puppy comes with the wrapper for unrar it just needs the unrar binary. Puppy comes the the deb binary so that works out of the box.
sc0ttman wrote:Good luck with this, great idea.. if I knew how to help, I would..
Thanks. It's ok. No hard feelings.

Posted: Fri 11 Jun 2010, 21:22
by abushcrafter
Update!

Posted: Sat 12 Jun 2010, 01:43
by technosaurus
I have already patched it to work with lzma and xz (and also to be more compatible with busybox versions) - sent it to Barry a few months ago ... should be in any new package since then. If not it is easy to reproduce using tar.gz as a template for lzma and xz ... for busybox compatibility just use short options instead of long versions

Posted: Sun 13 Jun 2010, 22:21
by abushcrafter
Thanks technosaurus. Added tar.xz support. Still need to add lzma support.

Update!

Posted: Wed 07 Jul 2010, 13:38
by abushcrafter
Updated!
Package Version (PV)=003

tar-wrap.sh:

Code: Select all

#	2010-06-13  Alexander .S.T. Ross (abushcrafter) Email: <http://www.google.com/recaptcha/mailhide/d?k=01uNeUuXxeNm9FA3Zciuoqzw==&c=nVfKeb7kjqZVVIQanqJwEC2DP5zrALkSERTopYvj_pU=>
#		* 0.0.2: Added support for tar.xz, txz, pxt, and t7z files.
#		* 0.0.2: Added the changelog.
7z-wrap.sh:

Code: Select all

#	2010-06-30  Alexander S.T. Ross (abushcrafter) Email: <http://www.google.com/recaptcha/mailhide/d?k=01uNeUuXxeNm9FA3Zciuoqzw==&c=nVfKeb7kjqZVVIQanqJwEC2DP5zrALkSERTopYvj_pU=>
#		* 0.0.3: Added support for tar.lzma, tar.lz, tlz files.
#		* 0.0.3: Fixed missing info from the changelog.

Posted: Wed 07 Jul 2010, 18:10
by amigo
Here's a chunk of code for you which covers quite a few formats:

gitunpack:

Code: Select all

#! /bin/sh

###############################################################################
###									    ###
###			GNU Interactive Tools unpack script	    	    ###
###	 Copyright (C) 1997-2000, 2006-2007 Free Software Foundation, Inc.  ###
###                                                                         ###
###                  This file is part of gnuit.                            ###
###                                                                         ###
###  gnuit is free software: you can redistribute it and/or modify it       ###
###  under the terms of the GNU General Public License as published         ###
###  by the Free Software Foundation, either version 3 of the               ###
###  License, or (at your option) any later version.                        ###
###                                                                         ###
###  gnuit is distributed in the hope that it will be useful, but           ###
###  WITHOUT ANY WARRANTY; without even the implied warranty of             ###
###  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          ###
###  GNU General Public License for more details.                           ###
###                                                                         ###
###  You should have received a copy of the GNU General Public              ###
###  License along with this program. If not, see                           ###
###  http://www.gnu.org/licenses/.                                          ###
###									    ###
###		    Written by Tudor Hulubei and Viorel Anghel.		    ###
###									    ###
###############################################################################


# We can have one or two arguments.
if test "$#" -lt 2; then
    echo "usage: $0 destdir archives..."
    exit 1
fi

destdir="$1"
shift
srcdir=`pwd`

cd "$destdir" 2> /dev/null
if test "$?" -ne 0; then
    gitmkdirs "$destdir"
    if test "$?" -ne 0; then
	exit 1;
    fi

    cd "$destdir"
    if test "$?" -ne 0; then
	exit 1;
    fi
fi

exit_code=0
while [ $# -gt 0 ] ; do
    archive=$1

    if [ ! -e "$archive" ] ; then
	echo "$0: $archive: not found"
    elif [ -d "$archive" ] ; then
	echo "$0: $archive: not a regular file" >&2
	exit_code=1
    else
	# `ln' will fail if $destdir is the same as $srcdir.
	ln -s "$srcdir/$archive" "$archive" 2> /dev/null
	link_created=$?

	lcarchive="$(echo "$archive"|tr '[:upper:]' '[:lower:]')"
	case "$lcarchive" in
        *.tar|*.cbt)                tar -xvf "$archive";;
        *.tar.bz)                   bzip -dc "$archive"|tar -xvf -;;
        *.tar.bz2)                  bzip2 -dc "$archive"|tar -xvf -;;
        *.tar.gz)                   gzip -dc -- "$archive"|tar -xvf -;;
        *.tar.z)                    uncompress -dc "$archive"|tar -xvf -;;
        *.tar.z)                    uncompress -dc "$archive"|tar -xvf -;;
	*.tar.7z)                   7z x -y -so -- "$archive" | tar -xvf -;;
	*.tar.lzma)                 lzma -c -d -- "$archive" | tar -xvf -;;
        *.cpio)                     cat "$archive"|cpio -i -d;;
        *.cpio.bz)                  bzip -dc "$archive"|cpio -i -d;;
        *.cpio.bz2)                 bzip2 -dc "$archive"|cpio -i -d;;
        *.cpio.gz)                  gzip -dc -- "$archive"|cpio -i -d;;
        *.cpio.z)                   uncompress -dc "$archive"|cpio -i -d;;
	*.cpio.7z)                  7z x -y -so -- "$archive" | cpio -i -d;;
	*.cpio.lzma)                lzma -c -d -- "$archive" | cpio -i -d;;
	*.7z)                       7z x -- "$archive";;
	*.lzma)                     lzma -d -- "$archive";;
        *.tgz)                      gzip -dc -- "$archive"|tar -xvf -;;
        *.t[ar]z)                   uncompress -dc "$archive"|tar -xvf -;;
        *.jar)                      jar -xvf "$archive";;
        *.zip|*.cbz)                unzip -o "$archive";;
        *.arj|*.a[0-9][0-9])        unarj x "$archive";;
        *.rar|*.cbr|*.r[0-9][0-9])  rar x -y -r -v "$archive";;
        *.lha|*.lzh)                lha -xvf "$archive";;
        *.z)                        uncompress "$archive";;
        *.bz)                       bzip -d "$archive";;
        *.bz2)                      bzip2 -d "$archive";;
        *.gz)                       gunzip "$archive";;
        *.shar)                     sh "$archive";;
        *.uu)                       uudecode "$archive";;
        *.rpm)                      rpm2cpio "$archive"|cpio -v -i -d;;
        *.deb)                      ar -xv "$archive";;
        *.a)                        ar -xv "$archive";;
	*.zoo)                      zoo --extract "$archive";;
        *) echo "$0: $archive: unknown archive type" >&2
           exit_code=1
        esac

	if test $? -ne 0; then
	    exit_code=$?
	fi

	if test "$link_created" -eq 0; then
	    rm "$archive"
	fi
    fi

    shift
done

exit $exit_code

I started once to adapt the code so it would check to make sure the indicated decompressor is available and warn if not.

Posted: Wed 07 Jul 2010, 21:36
by abushcrafter
I will try this out and see how it compares to unp unp installation and configuration in debian.

Posted: Wed 07 Jul 2010, 23:21
by vovchik
Dear puppians,

Here is unp 2.0~pre4 (Debian Sid) as a pet.

With kind regards,
vovchik

Posted: Thu 08 Jul 2010, 06:04
by amigo
The bas things about unp is it is a perl script...

Posted: Sun 11 Jul 2010, 21:46
by abushcrafter
Thanks for the new version of unp. I have decided to stick with unp as it is very powerful. For example it supports PET out of the box. Not because it knows about the .pet extension but because (I think. Do correct me if I am wrong.) it is able to find out what it's MIME is/what archive type it is. Another feature I like is the "-u" parameter.

Now to extract code from that gitunpack script for xarchiver which I get around to it :roll:. Remind me if I forget to do it.

Update!

Posted: Sat 25 Sep 2010, 19:48
by abushcrafter
New wrappers and a few miner bug fixes.

Thanks to amigofor the suggestion/info. New wrappers:
  • lha-wrap.sh
  • uu-wrap.sh
  • zoo-wrap.sh
I have begun work on a CPIO wrapper but have got stuck due to lack of knowledge and probably time and the ability to face it :x.

So someone please finish it! Here it is:

Update! See First Post!

Posted: Mon 11 Oct 2010, 20:25
by abushcrafter
I have successfully extracted a "pup" archive with this new version.

"zip-wrap.sh":

Code: Select all

#ChangeLog ----------------------------------------------------------------------
#	2010-10-02-Sat 10:03:28  Alexander S.T. Ross (abushcrafter) Email: <http://www.google.com/recaptcha/mailhide/d?k=01uNeUuXxeNm9FA3Zciuoqzw==&c=nVfKeb7kjqZVVIQanqJwEC2DP5zrALkSERTopYvj_pU=>
#		* 0.0.2: Added support for "pup".
"tar-wrap.sh":

Code: Select all

#ChangeLog ----------------------------------------------------------------------
#	2010-10-02-Sat 10:03:28  Alexander S.T. Ross (abushcrafter) Email: <http://www.google.com/recaptcha/mailhide/d?k=01uNeUuXxeNm9FA3Zciuoqzw==&c=nVfKeb7kjqZVVIQanqJwEC2DP5zrALkSERTopYvj_pU=>
#		* 0.0.5: Removed suport for "pup" as it is a "zip" not a "tar.gz".
I have attached a ".tar.bz2" which contains just the "tar-wrap.sh" and the "zip-wrap.sh" updated wrappers.

I also added to the first post, links to the threads for the ZOO and LHA PETs I made.

Posted: Tue 08 Feb 2011, 22:51
by Karl Godt
I would like to suggest to change the error output from the wrapper files from ">/dev/stderr" ["> /dev/stderr"] to something like this :
">>/tmp/xarchive_errs.log" , because many times my /tmp/xerrs.log becomes unreadable and/or overwritten .

Code: Select all

cd /usr/local/lib/xarchive/wrappers
for i in *; do cat $i | sed 's#> /dev/stderr#>>/tmp/xarchive_errs.log#g' > $i; done
for i in *; do cat $i | sed 's#>/dev/stderr#>>/tmp/xarchive_errs.log#g' > $i; done
also interesting to have :

Code: Select all

for FILE in *; do L=`grep -n 'E_UNSUPPORTED=' $FILE | cut -f 1 -d ':'` ; echo $L ; SEDINSL=`expr $L - 2`; SEDINS='echo >>/tmp/xarchive_errs.log' ; sed -i "$SEDINSL i $SEDINS" $FILE ; done
for FILE in *; do L=`grep -n 'opt="$1"' $FILE | cut -f 1 -d ':'` ; echo $L ; SEDINSL=`expr $L + 1`; SEDINS='echo opt $opt >>/tmp/xarchive_errs.log' ; sed -i "$SEDINSL i $SEDINS" $FILE ; done
for FILE in *; do L=`grep -n 'archive="$1"' $FILE | cut -f 1 -d ':'` ; echo $L ; SEDINSL=`expr $L + 1`; SEDINS='echo archive $archive >>/tmp/xarchive_errs.log' ; sed -i "$SEDINSL i $SEDINS" $FILE ; done
The output of
grep -n 'archive="$1"' *
7za-wrap.sh:56:archive="$1"
and
for FILE in *; do L=`grep -n 'archive="$1"' $FILE` ;echo $L; done
56:archive="$1"
differ slightly , so i put in "echo $L"

Posted: Wed 25 May 2011, 22:51
by abushcrafter
Update!

The new change is the "pupzip" script is now included and has support for the formats I added to the improved xarchive wrappers and support for "shar". I also removed some wrappers that did not have any improvements in the first place.

@Karl Godt.
I tried to understand what changes where need but I only understood one, I think :?. Though I am not at all sure that I did understood that one. So if you could apply your changes to the new version I posted and PM them to me and I will post a new version.

Posted: Thu 26 May 2011, 13:44
by Karl Godt
Done

Maybe
cat $i | sed 's#> /dev/stderr#>>/tmp/xarchive_errs.log#g' > $i
gives an empty file

This should do it better :

Code: Select all

for i in *; do cat $i | sed 's#>/dev/stderr#>>/tmp/xarchive_errs.log#g' > /tmp/$i; mv -f /tmp/$i ./$i ; done 

for i in *; do cat $i | sed 's#> /dev/stderr#>>/tmp/xarchive_errs.log#g' > /tmp/$i; mv -f /tmp/$i ./$i ; done

wrapper for lzh

Posted: Thu 27 Dec 2012, 05:28
by gcav
I could not find one.. So I hacked this up..

Code: Select all

#! /bin/bash
# Wrapper for LZH - GCL
# Based on rar-wrap.sh - bash rar wrapper for xarchive

# set up exit status variables
E_UNSUPPORTED=65

# Supported file extentions for lha
EXTS="lzh lharc lha"

# Program to wrap
if [ "$(which lha)" ]; then
    LHA_PROG="lha"
else
    LHA_PROG="lha"
fi

# Setup awk program to use
AWK_PROGS="mawk gawk awk"
AWK_PROG=""
for awkprog in $AWK_PROGS; do
    if [ "$(which $awkprog)" ]; then
        AWK_PROG="$awkprog"
        break
    fi
done

# Setup xterm program to use
XTERM_PROGS="xterm rxvt xvt wterm aterm Eterm"
XTERM_PROG=""
for xtermprog in $XTERM_PROGS; do
    if [ "$(which $xtermprog)" ]; then
        XTERM_PROG="$xtermprog"
        break
    fi
done

# setup variables opt and archive.
# the shifting will leave the files passed as
# all the remaining args "$@"
opt="$1"
shift 1
archive="$1"
shift 1

# Command line options for prog functions
# disable comments when opening
OPEN_OPTS="l"
ADD_OPTS="a"
NEW_OPTS="a"
REMOVE_OPTS="d"
EXTRACT_OPTS="x"
PASS_EXTRACT_OPTS="x"

# the option switches
case "$opt" in
    -i) # info: output supported extentions for progs that exist
        if [ ! "$AWK_PROG" ]; then
            echo none of the awk programs $AWK_PROGS found >> /dev/stderr
            echo extentions $EXTS ignored >> /dev/stderr
        elif [ "$(which $LHA_PROG)" ]; then
            for ext in $EXTS; do
                printf "%s;" $ext
            done
        else
            echo command $LHA_PROG not found >> /dev/stderr 
            echo extentions $EXTS ignored >> /dev/stderr 
        fi
        printf "\n"
        exit
        ;;

    -o) # open: mangle output of lha cmd for xarchive 
        # format of lha output:
# PERMSSN    UID  GID      SIZE  RATIO     STAMP           NAME
# ---------- ----------- ------- ------ ------------ --------------------
# drwxr-xr-x     0/0           0 ****** Jul 11 23:46 AppBuilder-0.4/
# -rwxr-xr-x     0/500      2948 100.0% Feb 12  2002 AppBuilder-0.4/.DirIcon
# -rw-r-----     0/500       317  59.0% Mar 21  2006 AppBuilder-0.4/AppInfo.xml
# -rwxr-x---     0/500      2907  47.0% Dec  4  2006 AppBuilder-0.4/AppRun
# drwxr-xr-x     0/0           0 ****** Jul 11 23:46 AppBuilder-0.4/Help/
# -rw-r--r--   100/500      1356  59.7% Mar 10  2006 AppBuilder-0.4/Help/AppBuilder.htm
#     1           2          3       4   5   6    7    8 
        
        $LHA_PROG $OPEN_OPTS "$archive" | $AWK_PROG -v uuid=${UID-0} '
        # The body of info we wish to process starts with a dashed line 
        # so set a flag to signal when to start and stop processing.
        # The name is on one line with the info on the next so toggle
        # a line flag letting us know what kinda info to get. 
	/^-------/ { flag++; if (flag > 1) exit 0; next }
	{
	if (flag == 0) next
	#year=$7
	#month=$5
	#day=$6
	gid=$2
	time=$5"-"$6"-"$7
	attr=$1
	size=$3
	#$0=substr($0, 54)
	name=$8
	gsub(/\\/, "/", name)
															
	printf "%s;%d;%s;%d;%d;%s;-\n", name, size, attr, uid,gid,   time
	}'
																																																										
        exit
        ;;

    -a) # add:  to archive passed files
        # we only want to add the file's basename, not
        # the full path so...
        while [ "$1" ]; do
            cd "$(dirname "$1")"
            $LHA_PROG $ADD_OPTS "$archive" "$(basename "$1")"
            wrapper_status=$?
            shift 1
        done
        exit $wrapper_status
        ;;

    -n) # new: create new archive with passed files 
        # create will only be passed the first file, the
        # rest will be "added" to the new archive
        cd "$(dirname "$1")"
        $LHA_PROG $NEW_OPTS "$archive" "$(basename "$1")"
        exit
        ;;

    -r) # remove: from archive passed files 
        $LHA_PROG $REMOVE_OPTS "$archive" "$@"
        exit
        ;;

    -e) # extract: from archive passed files 
        # xarchive will put is the right extract dir
        # so we just have to extract.
        $LHA_PROG $EXTRACT_OPTS "$archive" "$@"
        if [ "$?" -ne "0" ] && [ "$XTERM_PROG" ]; then
            echo Probably password protected,
            echo Opening an x-terminal...
            $XTERM_PROG -e $LHA_PROG $PASS_EXTRACT_OPTS "$archive" "$@"
        fi
        exit
        ;;

     *) echo "error, option $opt not supported"
        echo "use one of these:" 
        echo "-i                #info" 
        echo "-o archive        #open" 
        echo "-a archive files  #add" 
        echo "-n archive file   #new" 
        echo "-r archive files  #remove" 
        echo "-e archive files  #extract" 
        exit
esac

lha... and 7z

Posted: Thu 27 Dec 2012, 14:28
by gcav
Just realized that 7z and its wrapper supports lha... oh well...

gc

Posted: Tue 05 Feb 2013, 19:18
by amigo
Just realized that my program: AppBuilder-0.4
was being used as an example. People should write me and tell me they are using my stuff -I might be able to help them!