3
0

unrpm 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/sh
  2. #
  3. # This should work with the GNU version of cpio and gzip!
  4. # This should work with the bash or ash shell!
  5. # Requires the programs (cpio, gzip, and the pager more or less).
  6. #
  7. usage() {
  8. echo "Usage: unrpm -l package.rpm <List contents of rpm package>"
  9. echo " unrpm -x package.rpm /foo/boo <Extract rpm package to this directory,"
  10. echo " put . for current directory>"
  11. exit
  12. }
  13. rpm=$2
  14. exist() {
  15. if [ "$rpm" = "" ]; then
  16. usage
  17. elif [ ! -s "$rpm" ]; then
  18. echo "Can't find $rpm!"
  19. exit
  20. fi
  21. }
  22. if [ "$1" = "" ]; then
  23. usage
  24. elif [ "$1" = "-l" ]; then
  25. exist
  26. type more >/dev/null 2>&1 && pager=more
  27. type less >/dev/null 2>&1 && pager=less
  28. [ "$pager" = "" ] && echo "No pager found!" && exit
  29. (echo -e "\nPress enter to scroll, q to Quit!\n" ; rpm2cpio $rpm | cpio -tv --quiet) | $pager
  30. exit
  31. elif [ "$1" = "-x" ]; then
  32. exist
  33. if [ "$3" = "" ]; then
  34. usage
  35. elif [ ! -d "$3" ]; then
  36. echo "No such directory $3!"
  37. exit
  38. fi
  39. rpm2cpio $rpm | (umask 0 ; cd $3 ; cpio -idmuv) || exit
  40. echo
  41. echo "Extracted $rpm to $3!"
  42. exit
  43. else
  44. usage
  45. fi