home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #Barry Kauler 2005 www.puppylinux.com
- #frontend for XArchive.
- #well, i want this to be a universal archiver frontend for puppy.
-
- PARAMIN="$@"
-
- CDIR="`pwd`"
-
- #note, do not cd to directory this app is located in.
-
- #in order of preference...
- if [ ! "`which xarchive`" = "" ];then
- XARCHIVE="xarchive"
- else
- if [ ! "`which TkZip`" = "" ];then
- XARCHIVE="TkZip"
- else
- if [ ! "`which guitar`" = "" ];then
- XARCHIVE="guitar"
- else
- exec xmessage -bg "orange red" -center -title "PupZip: ERROR" "No archive GUI program found.
- Please install XArchiver."
- fi
- fi
- fi
-
- #the full alternatives, dotpups by GuestToo...
- DPKGDEB="dpkg-deb"
- [ ! "`which dpkg-deb2`" = "" ] && DPKGDEB="dpkg-deb2"
- RPM2CPIO="rpm2cpio2"
- [ ! "`which rpm2cpio2`" = "" ] && RPM2CPIO="rpm2cpio2"
-
- if [ "$PARAMIN" = "" ];then
- #just start xarchive...
- exec $XARCHIVE
- fi
-
- if [ "$XARCHIVE" = "xarchive" ];then
- MSGE="Drag and drop invocation of XArchive is achieved by dragging any file or
- directory the \"pupzip\" icon on the desktop. If you drag one of the
- recognised archived files, such as .tar.gz, .rpm, .deb, .zip, .tar.bz2,
- it will open in XArchive and you will be given the opportunity to extract
- it. If you drag an ordinary file to the desktop icon, such as for example
- \"myfile.txt\", a XArchive will popup a dialog asking if you want to add
- it to an existing archive or create a new one."
- else
- MSGE="There is support for drag-and-drop of archive files to the desktop icon,
- however not for files and directories -- for that you need to have
- XArchiver installed, the preferred archiver program for Puppy."
- fi
-
- if [ "$PARAMIN" = "--help" ];then
- xmessage -bg "orange" -center -title "PupZip: help" "
- This is a frontend to $XARCHIVE, which in turn is a frontend to the
- archiver utilities in Puppy (such as gzip, bzip2, dpkg, rpm, zip).
-
- Note: $XARCHIVE can be started in the conventional way via the menu.
-
- $MSGE
-
- PupZip can also be invoked from Rox by the \"Open With...\" menu,
- by right-clicking on a file or directory."
- exit
- fi
-
-
- NORMFILE="`echo -n "$PARAMIN" | grep -iv "\\.tar" | grep -iv "\\.bz" | grep -iv "\\.gz" | grep -iv "\\.rpm" | grep -iv "\\.deb" | grep -iv "\\.zip" | grep -iv "\\.tgz" | grep -iv "\\.tbz"`"
-
- if [ "$NORMFILE" = "" ];then
- #it is an archive file...
-
- #get absolute path of file...
- if [ "`echo -n "$PARAMIN" | cut -b 1`" = "/" ];then
- FULLSPEC="$PARAMIN"
- else
- #relative path...
- if [ "$CDIR" = "/" ];then
- FULLSPEC="/$PARAMIN"
- else
- FULLSPEC="$CDIR/$PARAMIN"
- fi
- fi
-
- #busybox applets are not adequate for handling rpm, deb...
- AFILE="`basename "$PARAMIN"`"
- if [ "`echo -n "$AFILE" | grep '\.'`" = "" ];then
- #file has no extension, so treat as ordinary file...
- if [ "$XARCHIVE" = "xarchive" ];then
- exec xarchive --add=ask "$PARAMIN"
- else
- exec xmessage -bg "orange red" -center -title "PupZip: ERROR" "Not an archive file"
- fi
- else
- AEXT="$AFILE"
- while [ ! "`echo -n "$AEXT" | grep '\.'`" = "" ];do
- AEXT="`echo -n "$AEXT" | cut -f 2-6 -d '.'`"
- done
- fi
- #drops here with AEXT=extension.
- case $AEXT in
- rpm|RPM)
- mkdir /tmp/temprpm
- cd /tmp/temprpm
- $RPM2CPIO "$FULLSPEC" | cpio -d -i -m
- if [ ! $? -eq 0 ];then
- exec xmessage -bg "orange red" -center -title "PupZip: ERROR" "An error has occurred opening the RPM file.
- Suggestion: install unrpm.pup DotPup package, which contains an alternative
- RPM extraction program, that PupZip will automatically use if present."
- fi
- sync
- tar -c -f /tmp/temprpm.tar .
- rm -rf /tmp/temprpm
- cd /
- $XARCHIVE /tmp/temprpm.tar
- rm -f /tmp/temprpm.tar
- cd $CDIR
- exit
- ;;
- deb|DEB)
- mkdir /tmp/temprpm
- cd /tmp/temprpm
- $DPKGDEB -x "$FULLSPEC"
- if [ ! $? -eq 0 ];then
- exec xmessage -bg "orange red" -center -title "PupZip: ERROR" "An error has occurred opening the DEB file.
- Suggestion: install undeb.pup DotPup package, which contains an alternative
- DEB extraction program, that PupZip will automatically use if present."
- fi
- tar -c -f /tmp/temprpm.tar .
- rm -rf /tmp/temprpm
- cd /
- $XARCHIVE /tmp/temprpm.tar
- rm -f /tmp/temprpm.tar
- cd $CDIR
- exit
- ;;
- esac
- exec $XARCHIVE "$PARAMIN"
- else
- if [ "$XARCHIVE" = "xarchive" ];then
- exec xarchive --add=ask "$NORMFILE"
- else
- exec xmessage -bg "orange red" -center -title "PupZip: ERROR" "Not an archive file"
- fi
- fi
-
- ###END###
-