3
0

undeb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/sh
  2. #
  3. # This should work with the GNU version of tar and gzip!
  4. # This should work with the bash or ash shell!
  5. # Requires the programs (ar, tar, gzip, and the pager more or less).
  6. #
  7. usage() {
  8. echo "Usage: undeb -c package.deb <Print control file info>"
  9. echo " undeb -l package.deb <List contents of deb package>"
  10. echo " undeb -x package.deb /foo/boo <Extract deb package to this directory,"
  11. echo " put . for current directory>"
  12. exit
  13. }
  14. deb=$2
  15. exist() {
  16. if [ "$deb" = "" ]; then
  17. usage
  18. elif [ ! -s "$deb" ]; then
  19. echo "Can't find $deb!"
  20. exit
  21. fi
  22. }
  23. if [ "$1" = "" ]; then
  24. usage
  25. elif [ "$1" = "-l" ]; then
  26. exist
  27. type more >/dev/null 2>&1 && pager=more
  28. type less >/dev/null 2>&1 && pager=less
  29. [ "$pager" = "" ] && echo "No pager found!" && exit
  30. (ar -p $deb control.tar.gz | tar -xzO *control ; echo -e "\nPress enter to scroll, q to Quit!\n" ; ar -p $deb data.tar.gz | tar -tzv) | $pager
  31. exit
  32. elif [ "$1" = "-c" ]; then
  33. exist
  34. ar -p $deb control.tar.gz | tar -xzO *control
  35. exit
  36. elif [ "$1" = "-x" ]; then
  37. exist
  38. if [ "$3" = "" ]; then
  39. usage
  40. elif [ ! -d "$3" ]; then
  41. echo "No such directory $3!"
  42. exit
  43. fi
  44. ar -p $deb data.tar.gz | tar -xzvpf - -C $3 || exit
  45. echo
  46. echo "Extracted $deb to $3!"
  47. exit
  48. else
  49. usage
  50. fi