Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
Eric Andersen | 5ec241d | 2000-12-12 16:49:12 +0000 | [diff] [blame] | 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 | # |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 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," |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 10 | echo " put . for current directory>" |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 11 | exit |
| 12 | } |
| 13 | |
| 14 | rpm=$2 |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 15 | |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 16 | exist() { |
| 17 | if [ "$rpm" = "" ]; then |
| 18 | usage |
| 19 | elif [ ! -s "$rpm" ]; then |
| 20 | echo "Can't find $rpm!" |
| 21 | exit |
| 22 | fi |
| 23 | } |
| 24 | |
| 25 | if [ "$1" = "" ]; then |
| 26 | usage |
| 27 | elif [ "$1" = "-l" ]; then |
| 28 | exist |
| 29 | type more >/dev/null 2>&1 && pager=more |
| 30 | type less >/dev/null 2>&1 && pager=less |
Eric Andersen | 5ec241d | 2000-12-12 16:49:12 +0000 | [diff] [blame] | 31 | [ "$pager" = "" ] && echo "No pager found!" && exit |
Glenn L McGrath | f8736d2 | 2001-06-26 01:19:34 +0000 | [diff] [blame] | 32 | (echo -e "\nPress enter to scroll, q to Quit!\n" ; rpm2cpio $rpm | cpio -tv --quiet) | $pager |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 33 | exit |
| 34 | elif [ "$1" = "-x" ]; then |
| 35 | exist |
| 36 | if [ "$3" = "" ]; then |
| 37 | usage |
| 38 | elif [ ! -d "$3" ]; then |
| 39 | echo "No such directory $3!" |
| 40 | exit |
| 41 | fi |
Glenn L McGrath | f8736d2 | 2001-06-26 01:19:34 +0000 | [diff] [blame] | 42 | rpm2cpio $rpm | (umask 0 ; cd $3 ; cpio -idmuv) || exit |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 43 | echo |
| 44 | echo "Extracted $rpm to $3!" |
| 45 | exit |
| 46 | else |
| 47 | usage |
| 48 | fi |