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() { |
Mike Frysinger | d7d4750 | 2016-04-04 01:39:17 -0400 | [diff] [blame] | 8 | cat <<EOF |
| 9 | Usage: unrpm -l package.rpm <List contents of rpm package> |
| 10 | unrpm -x package.rpm /foo/boo <Extract rpm package to this directory, |
| 11 | put . for current directory> |
| 12 | EOF |
| 13 | exit |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | rpm=$2 |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 17 | |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 18 | exist() { |
Mike Frysinger | d7d4750 | 2016-04-04 01:39:17 -0400 | [diff] [blame] | 19 | if [ -z "${rpm}" ]; then |
| 20 | usage |
| 21 | elif [ ! -s "${rpm}" ]; then |
| 22 | echo "Can't find ${rpm}!" |
| 23 | exit 1 |
| 24 | fi |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 25 | } |
| 26 | |
Mike Frysinger | d7d4750 | 2016-04-04 01:39:17 -0400 | [diff] [blame] | 27 | if [ -z "$1" ]; then |
| 28 | usage |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 29 | elif [ "$1" = "-l" ]; then |
Mike Frysinger | d7d4750 | 2016-04-04 01:39:17 -0400 | [diff] [blame] | 30 | exist |
| 31 | type more >/dev/null 2>&1 && pager=more |
| 32 | type less >/dev/null 2>&1 && pager=less |
| 33 | [ "$pager" = "" ] && echo "No pager found!" && exit |
| 34 | ( |
| 35 | printf "\nPress enter to scroll, q to Quit!\n\n" |
| 36 | rpm2cpio "${rpm}" | cpio -tv --quiet |
| 37 | ) | ${pager} |
| 38 | exit |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 39 | elif [ "$1" = "-x" ]; then |
Mike Frysinger | d7d4750 | 2016-04-04 01:39:17 -0400 | [diff] [blame] | 40 | exist |
| 41 | if [ -z "$3" ]; then |
| 42 | usage |
| 43 | elif [ ! -d "$3" ]; then |
| 44 | echo "No such directory $3!" |
| 45 | exit 1 |
| 46 | fi |
| 47 | rpm2cpio "${rpm}" | (umask 0 ; cd "$3" ; cpio -idmuv) || exit |
| 48 | echo |
| 49 | echo "Extracted ${rpm} to $3!" |
| 50 | exit |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 51 | else |
Mike Frysinger | d7d4750 | 2016-04-04 01:39:17 -0400 | [diff] [blame] | 52 | usage |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 53 | fi |