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 tar and gzip! |
| 4 | # This should work with the bash or ash shell! |
| 5 | # Requires the programs (ar, tar, gzip, and the pager more or less). |
| 6 | # |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 7 | usage() { |
| 8 | echo "Usage: undeb -c package.deb <Print control file info>" |
| 9 | echo " undeb -l package.deb <List contents of deb package>" |
| 10 | echo " undeb -x package.deb /foo/boo <Extract deb package to this directory," |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 11 | echo " put . for current directory>" |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 12 | exit |
| 13 | } |
| 14 | |
| 15 | deb=$2 |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 16 | |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 17 | exist() { |
| 18 | if [ "$deb" = "" ]; then |
| 19 | usage |
| 20 | elif [ ! -s "$deb" ]; then |
| 21 | echo "Can't find $deb!" |
| 22 | exit |
| 23 | fi |
| 24 | } |
| 25 | |
| 26 | if [ "$1" = "" ]; then |
| 27 | usage |
| 28 | elif [ "$1" = "-l" ]; then |
| 29 | exist |
| 30 | type more >/dev/null 2>&1 && pager=more |
| 31 | type less >/dev/null 2>&1 && pager=less |
Eric Andersen | 5ec241d | 2000-12-12 16:49:12 +0000 | [diff] [blame] | 32 | [ "$pager" = "" ] && echo "No pager found!" && exit |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 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 |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 34 | exit |
| 35 | elif [ "$1" = "-c" ]; then |
| 36 | exist |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 37 | ar -p $deb control.tar.gz | tar -xzO *control |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 38 | exit |
| 39 | elif [ "$1" = "-x" ]; then |
| 40 | exist |
| 41 | if [ "$3" = "" ]; then |
| 42 | usage |
| 43 | elif [ ! -d "$3" ]; then |
| 44 | echo "No such directory $3!" |
| 45 | exit |
| 46 | fi |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 47 | ar -p $deb data.tar.gz | tar -xzvpf - -C $3 || exit |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 48 | echo |
| 49 | echo "Extracted $deb to $3!" |
| 50 | exit |
| 51 | else |
| 52 | usage |
| 53 | fi |