aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/undeb74
-rwxr-xr-xexamples/unrpm65
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#
7usage() { 7usage() {
8echo "Usage: undeb -c package.deb <Print control file info>" 8 cat <<EOF
9echo " undeb -l package.deb <List contents of deb package>" 9Usage: undeb -c package.deb <Print control file info>
10echo " undeb -x package.deb /foo/boo <Extract deb package to this directory," 10 undeb -l package.deb <List contents of deb package>
11echo " put . for current directory>" 11 undeb -x package.deb /foo/boo <Extract deb package to this directory,
12exit 12 put . for current directory>
13EOF
14 exit
13} 15}
14 16
15deb=$2 17deb=$2
16 18
17exist() { 19exist() {
18if [ "$deb" = "" ]; then 20 if [ -z "${deb}" ]; then
19usage 21 usage
20elif [ ! -s "$deb" ]; then 22 elif [ ! -s "${deb}" ]; then
21echo "Can't find $deb!" 23 echo "Can't find ${deb}!"
22exit 24 exit 1
23fi 25 fi
24} 26}
25 27
26if [ "$1" = "" ]; then 28if [ -z "$1" ]; then
27usage 29 usage
28elif [ "$1" = "-l" ]; then 30elif [ "$1" = "-l" ]; then
29exist 31 exist
30type more >/dev/null 2>&1 && pager=more 32 type more >/dev/null 2>&1 && pager=more
31type 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 (
34exit 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
35elif [ "$1" = "-c" ]; then 41elif [ "$1" = "-c" ]; then
36exist 42 exist
37ar -p $deb control.tar.gz | tar -xzO *control 43 ar -p "${deb}" control.tar.gz | tar -xzO *control
38exit 44 exit
39elif [ "$1" = "-x" ]; then 45elif [ "$1" = "-x" ]; then
40exist 46 exist
41if [ "$3" = "" ]; then 47 if [ -z "$3" ]; then
42usage 48 usage
43elif [ ! -d "$3" ]; then 49 elif [ ! -d "$3" ]; then
44echo "No such directory $3!" 50 echo "No such directory $3!"
45exit 51 exit 1
46fi 52 fi
47ar -p $deb data.tar.gz | tar -xzvpf - -C $3 || exit 53 ar -p "${deb}" data.tar.gz | tar -xzvpf - -C "$3" || exit
48echo 54 echo
49echo "Extracted $deb to $3!" 55 echo "Extracted ${deb} to $3!"
50exit 56 exit
51else 57else
52usage 58 usage
53fi 59fi
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