pet2tgz 936 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. #by BarryK 2006 for Puppy Linux v2.13+
  3. #passed param is file to be converted.
  4. #converts a .pet file to .tar.gz.
  5. #131122 support xz compressed pets (see dir2pet, installpkg.sh)
  6. [ "$(cat /var/local/petget/nt_category 2>/dev/null)" != "true" ] && \
  7. [ -f /tmp/install_quietly ] && set -x
  8. #; mkdir -p /tmp/PPM_LOGs ; NAME=$(basename "$0"); exec 1>> /tmp/PPM_LOGs/"$NAME".log 2>&1
  9. DL_SAVE_FLAG=$(cat /var/local/petget/nd_category)
  10. chmod +w "$1" #make it writable.
  11. FOOTERSIZE="32"
  12. export LC_ALL=C
  13. #determine the compression, extend test to 'XZ'
  14. file -b "$1" | grep -i -q "^xz" && EXT=xz || EXT=gz #131122 #140108 add -i for 'XZ'
  15. MD5SUM="`tail -c $FOOTERSIZE \"$1\"`"
  16. NEWNAME="`echo -n \"$1\" | sed -e "s/\\.pet$/\\.tar\\.$EXT/g"`" #131122
  17. head -c -$FOOTERSIZE "$1" > $NEWNAME
  18. NEWMD5SUM="`md5sum \"$NEWNAME\" | cut -f 1 -d ' '`"
  19. sync
  20. [ "$DL_SAVE_FLAG" != "true" ] && rm -f "$1"
  21. [ ! "$MD5SUM" = "$NEWMD5SUM" ] && exit 1
  22. exit 0