diff options
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/undeb | 74 | ||||
-rwxr-xr-x | examples/unrpm | 65 |
2 files changed, 75 insertions, 64 deletions
diff --git a/examples/undeb b/examples/undeb index 37104e9d8..c30baf31b 100755 --- a/examples/undeb +++ b/examples/undeb | |||
@@ -5,49 +5,55 @@ | |||
5 | # Requires the programs (ar, tar, gzip, and the pager more or less). | 5 | # Requires the programs (ar, tar, gzip, and the pager more or less). |
6 | # | 6 | # |
7 | usage() { | 7 | usage() { |
8 | echo "Usage: undeb -c package.deb <Print control file info>" | 8 | cat <<EOF |
9 | echo " undeb -l package.deb <List contents of deb package>" | 9 | Usage: undeb -c package.deb <Print control file info> |
10 | echo " undeb -x package.deb /foo/boo <Extract deb package to this directory," | 10 | undeb -l package.deb <List contents of deb package> |
11 | echo " put . for current directory>" | 11 | undeb -x package.deb /foo/boo <Extract deb package to this directory, |
12 | exit | 12 | put . for current directory> |
13 | EOF | ||
14 | exit | ||
13 | } | 15 | } |
14 | 16 | ||
15 | deb=$2 | 17 | deb=$2 |
16 | 18 | ||
17 | exist() { | 19 | exist() { |
18 | if [ "$deb" = "" ]; then | 20 | if [ -z "${deb}" ]; then |
19 | usage | 21 | usage |
20 | elif [ ! -s "$deb" ]; then | 22 | elif [ ! -s "${deb}" ]; then |
21 | echo "Can't find $deb!" | 23 | echo "Can't find ${deb}!" |
22 | exit | 24 | exit 1 |
23 | fi | 25 | fi |
24 | } | 26 | } |
25 | 27 | ||
26 | if [ "$1" = "" ]; then | 28 | if [ -z "$1" ]; then |
27 | usage | 29 | usage |
28 | elif [ "$1" = "-l" ]; then | 30 | elif [ "$1" = "-l" ]; then |
29 | exist | 31 | exist |
30 | type more >/dev/null 2>&1 && pager=more | 32 | type more >/dev/null 2>&1 && pager=more |
31 | type less >/dev/null 2>&1 && pager=less | 33 | type less >/dev/null 2>&1 && pager=less |
32 | [ "$pager" = "" ] && echo "No pager found!" && exit | 34 | [ -z "${pager}" ] && echo "No pager found!" && exit 1 |
33 | (ar -p $deb control.tar.gz | tar -xzO *control ; echo -e "\nPress enter to scroll, q to Quit!\n" ; ar -p $deb data.tar.gz | tar -tzv) | $pager | 35 | ( |
34 | exit | 36 | ar -p "${deb}" control.tar.gz | tar -xzO *control |
37 | printf "\nPress enter to scroll, q to Quit!\n\n" | ||
38 | ar -p "${deb}" data.tar.gz | tar -tzv | ||
39 | ) | ${pager} | ||
40 | exit | ||
35 | elif [ "$1" = "-c" ]; then | 41 | elif [ "$1" = "-c" ]; then |
36 | exist | 42 | exist |
37 | ar -p $deb control.tar.gz | tar -xzO *control | 43 | ar -p "${deb}" control.tar.gz | tar -xzO *control |
38 | exit | 44 | exit |
39 | elif [ "$1" = "-x" ]; then | 45 | elif [ "$1" = "-x" ]; then |
40 | exist | 46 | exist |
41 | if [ "$3" = "" ]; then | 47 | if [ -z "$3" ]; then |
42 | usage | 48 | usage |
43 | elif [ ! -d "$3" ]; then | 49 | elif [ ! -d "$3" ]; then |
44 | echo "No such directory $3!" | 50 | echo "No such directory $3!" |
45 | exit | 51 | exit 1 |
46 | fi | 52 | fi |
47 | ar -p $deb data.tar.gz | tar -xzvpf - -C $3 || exit | 53 | ar -p "${deb}" data.tar.gz | tar -xzvpf - -C "$3" || exit |
48 | echo | 54 | echo |
49 | echo "Extracted $deb to $3!" | 55 | echo "Extracted ${deb} to $3!" |
50 | exit | 56 | exit |
51 | else | 57 | else |
52 | usage | 58 | usage |
53 | fi | 59 | fi |
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 |