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