home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / local / bin / pupzip < prev    next >
Encoding:
Text File  |  2005-11-21  |  4.2 KB  |  148 lines

  1. #!/bin/sh
  2. #Barry Kauler 2005 www.puppylinux.com
  3. #frontend for XArchive.
  4. #well, i want this to be a universal archiver frontend for puppy.
  5.  
  6. PARAMIN="$@"
  7.  
  8. CDIR="`pwd`"
  9.  
  10. #note, do not cd to directory this app is located in.
  11.  
  12. #in order of preference...
  13. if [ ! "`which xarchive`" = "" ];then
  14.  XARCHIVE="xarchive"
  15. else
  16.  if [ ! "`which TkZip`" = "" ];then
  17.   XARCHIVE="TkZip"
  18.  else
  19.   if [ ! "`which guitar`" = "" ];then
  20.    XARCHIVE="guitar"
  21.   else
  22.    exec xmessage -bg "orange red" -center -title "PupZip: ERROR" "No archive GUI program found.
  23. Please install XArchiver."
  24.   fi
  25.  fi
  26. fi
  27.  
  28. #the full alternatives, dotpups by GuestToo...
  29. DPKGDEB="dpkg-deb"
  30. [ ! "`which dpkg-deb2`" = "" ] && DPKGDEB="dpkg-deb2"
  31. RPM2CPIO="rpm2cpio2"
  32. [ ! "`which rpm2cpio2`" = "" ] && RPM2CPIO="rpm2cpio2"
  33.  
  34. if [ "$PARAMIN" = "" ];then
  35.  #just start xarchive...
  36.  exec $XARCHIVE
  37. fi
  38.  
  39. if [ "$XARCHIVE" = "xarchive" ];then
  40.  MSGE="Drag and drop invocation of XArchive is achieved by dragging any file or
  41. directory the \"pupzip\" icon on the desktop. If you drag one of the
  42. recognised archived files, such as .tar.gz, .rpm, .deb, .zip, .tar.bz2,
  43. it will open in XArchive and you will be given the opportunity to extract
  44. it. If you drag an ordinary file to the desktop icon, such as for example
  45. \"myfile.txt\", a XArchive will popup a dialog asking if you want to add
  46. it to an existing archive or create a new one."
  47. else
  48.  MSGE="There is support for drag-and-drop of archive files to the desktop icon,
  49. however not for files and directories -- for that you need to have 
  50. XArchiver installed, the preferred archiver program for Puppy."
  51. fi
  52.  
  53. if [ "$PARAMIN" = "--help" ];then
  54.  xmessage -bg "orange" -center -title "PupZip: help" "
  55. This is a frontend to $XARCHIVE, which in turn is a frontend to the
  56. archiver utilities in Puppy (such as gzip, bzip2, dpkg, rpm, zip).
  57.  
  58. Note: $XARCHIVE can be started in the conventional way via the menu.
  59.  
  60. $MSGE
  61.  
  62. PupZip can also be invoked from Rox by the \"Open With...\" menu,
  63. by right-clicking on a file or directory."
  64.  exit
  65. fi
  66.  
  67.  
  68. 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"`"
  69.  
  70. if [ "$NORMFILE" = "" ];then
  71.  #it is an archive file...
  72.  
  73.  #get absolute path of file...
  74.  if [ "`echo -n "$PARAMIN" | cut -b 1`" = "/" ];then
  75.   FULLSPEC="$PARAMIN"
  76.  else
  77.   #relative path...
  78.   if [ "$CDIR" = "/" ];then
  79.    FULLSPEC="/$PARAMIN"
  80.   else
  81.    FULLSPEC="$CDIR/$PARAMIN"
  82.   fi
  83.  fi
  84.  
  85.  #busybox applets are not adequate for handling rpm, deb...
  86.  AFILE="`basename "$PARAMIN"`"
  87.  if [ "`echo -n "$AFILE" | grep '\.'`" = "" ];then
  88.   #file has no extension, so treat as ordinary file...
  89.   if [ "$XARCHIVE" = "xarchive" ];then
  90.    exec xarchive --add=ask "$PARAMIN"
  91.   else
  92.    exec xmessage -bg "orange red" -center -title "PupZip: ERROR" "Not an archive file"
  93.   fi
  94.  else
  95.   AEXT="$AFILE"
  96.   while [ ! "`echo -n "$AEXT" | grep '\.'`" = "" ];do
  97.    AEXT="`echo -n "$AEXT" | cut -f 2-6 -d '.'`"
  98.   done
  99.  fi
  100.  #drops here with AEXT=extension.
  101.  case $AEXT in
  102.   rpm|RPM)
  103.    mkdir /tmp/temprpm
  104.    cd /tmp/temprpm
  105.    $RPM2CPIO "$FULLSPEC" | cpio -d -i -m
  106.    if [ ! $? -eq 0 ];then
  107.     exec xmessage -bg "orange red" -center -title "PupZip: ERROR" "An error has occurred opening the RPM file.
  108. Suggestion: install unrpm.pup DotPup package, which contains an alternative
  109. RPM extraction program, that PupZip will automatically use if present."
  110.    fi
  111.    sync
  112.    tar -c -f /tmp/temprpm.tar .
  113.    rm -rf /tmp/temprpm
  114.    cd /
  115.    $XARCHIVE /tmp/temprpm.tar
  116.    rm -f /tmp/temprpm.tar
  117.    cd $CDIR
  118.    exit
  119.    ;;
  120.   deb|DEB)
  121.    mkdir /tmp/temprpm
  122.    cd /tmp/temprpm
  123.    $DPKGDEB -x "$FULLSPEC"
  124.    if [ ! $? -eq 0 ];then
  125.     exec xmessage -bg "orange red" -center -title "PupZip: ERROR" "An error has occurred opening the DEB file.
  126. Suggestion: install undeb.pup DotPup package, which contains an alternative
  127. DEB extraction program, that PupZip will automatically use if present."
  128.    fi
  129.    tar -c -f /tmp/temprpm.tar .
  130.    rm -rf /tmp/temprpm
  131.    cd /
  132.    $XARCHIVE /tmp/temprpm.tar
  133.    rm -f /tmp/temprpm.tar
  134.    cd $CDIR
  135.    exit
  136.    ;;
  137.  esac
  138.  exec $XARCHIVE "$PARAMIN"
  139. else
  140.  if [ "$XARCHIVE" = "xarchive" ];then
  141.   exec xarchive --add=ask "$NORMFILE"
  142.  else
  143.   exec xmessage -bg "orange red" -center -title "PupZip: ERROR" "Not an archive file"
  144.  fi
  145. fi
  146.  
  147. ###END###
  148.