diff options
-rwxr-xr-x | examples/unrpm | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/examples/unrpm b/examples/unrpm index 7fd3676f6..f48550b0a 100755 --- a/examples/unrpm +++ b/examples/unrpm | |||
@@ -5,44 +5,49 @@ | |||
5 | # Requires the programs (cpio, gzip, and the pager more or less). | 5 | # Requires the programs (cpio, gzip, and the pager more or less). |
6 | # | 6 | # |
7 | usage() { | 7 | usage() { |
8 | echo "Usage: unrpm -l package.rpm <List contents of rpm package>" | 8 | cat <<EOF |
9 | echo " unrpm -x package.rpm /foo/boo <Extract rpm package to this directory," | 9 | Usage: unrpm -l package.rpm <List contents of rpm package> |
10 | echo " put . for current directory>" | 10 | unrpm -x package.rpm /foo/boo <Extract rpm package to this directory, |
11 | exit | 11 | put . for current directory> |
12 | EOF | ||
13 | exit | ||
12 | } | 14 | } |
13 | 15 | ||
14 | rpm=$2 | 16 | rpm=$2 |
15 | 17 | ||
16 | exist() { | 18 | exist() { |
17 | if [ "$rpm" = "" ]; then | 19 | if [ -z "${rpm}" ]; then |
18 | usage | 20 | usage |
19 | elif [ ! -s "$rpm" ]; then | 21 | elif [ ! -s "${rpm}" ]; then |
20 | echo "Can't find $rpm!" | 22 | echo "Can't find ${rpm}!" |
21 | exit | 23 | exit 1 |
22 | fi | 24 | fi |
23 | } | 25 | } |
24 | 26 | ||
25 | if [ "$1" = "" ]; then | 27 | if [ -z "$1" ]; then |
26 | usage | 28 | usage |
27 | elif [ "$1" = "-l" ]; then | 29 | elif [ "$1" = "-l" ]; then |
28 | exist | 30 | exist |
29 | type more >/dev/null 2>&1 && pager=more | 31 | type more >/dev/null 2>&1 && pager=more |
30 | type less >/dev/null 2>&1 && pager=less | 32 | type less >/dev/null 2>&1 && pager=less |
31 | [ "$pager" = "" ] && echo "No pager found!" && exit | 33 | [ "$pager" = "" ] && echo "No pager found!" && exit |
32 | (echo -e "\nPress enter to scroll, q to Quit!\n" ; rpm2cpio $rpm | cpio -tv --quiet) | $pager | 34 | ( |
33 | exit | 35 | printf "\nPress enter to scroll, q to Quit!\n\n" |
36 | rpm2cpio "${rpm}" | cpio -tv --quiet | ||
37 | ) | ${pager} | ||
38 | exit | ||
34 | elif [ "$1" = "-x" ]; then | 39 | elif [ "$1" = "-x" ]; then |
35 | exist | 40 | exist |
36 | if [ "$3" = "" ]; then | 41 | if [ -z "$3" ]; then |
37 | usage | 42 | usage |
38 | elif [ ! -d "$3" ]; then | 43 | elif [ ! -d "$3" ]; then |
39 | echo "No such directory $3!" | 44 | echo "No such directory $3!" |
40 | exit | 45 | exit 1 |
41 | fi | 46 | fi |
42 | rpm2cpio $rpm | (umask 0 ; cd $3 ; cpio -idmuv) || exit | 47 | rpm2cpio "${rpm}" | (umask 0 ; cd "$3" ; cpio -idmuv) || exit |
43 | echo | 48 | echo |
44 | echo "Extracted $rpm to $3!" | 49 | echo "Extracted ${rpm} to $3!" |
45 | exit | 50 | exit |
46 | else | 51 | else |
47 | usage | 52 | usage |
48 | fi | 53 | fi |