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() { |
Mike Frysinger | ee22fe8 | 2016-04-04 01:35:34 -0400 | [diff] [blame] | 8 | cat <<EOF |
| 9 | Usage: undeb -c package.deb <Print control file info> |
| 10 | undeb -l package.deb <List contents of deb package> |
| 11 | undeb -x package.deb /foo/boo <Extract deb package to this directory, |
| 12 | put . for current directory> |
| 13 | EOF |
| 14 | exit |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | deb=$2 |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 18 | |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 19 | exist() { |
Mike Frysinger | ee22fe8 | 2016-04-04 01:35:34 -0400 | [diff] [blame] | 20 | if [ -z "${deb}" ]; then |
| 21 | usage |
| 22 | elif [ ! -s "${deb}" ]; then |
| 23 | echo "Can't find ${deb}!" |
| 24 | exit 1 |
| 25 | fi |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 26 | } |
| 27 | |
Mike Frysinger | ee22fe8 | 2016-04-04 01:35:34 -0400 | [diff] [blame] | 28 | if [ -z "$1" ]; then |
| 29 | usage |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 30 | elif [ "$1" = "-l" ]; then |
Mike Frysinger | ee22fe8 | 2016-04-04 01:35:34 -0400 | [diff] [blame] | 31 | exist |
| 32 | type more >/dev/null 2>&1 && pager=more |
| 33 | type less >/dev/null 2>&1 && pager=less |
| 34 | [ -z "${pager}" ] && echo "No pager found!" && exit 1 |
| 35 | ( |
| 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 |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 41 | elif [ "$1" = "-c" ]; then |
Mike Frysinger | ee22fe8 | 2016-04-04 01:35:34 -0400 | [diff] [blame] | 42 | exist |
| 43 | ar -p "${deb}" control.tar.gz | tar -xzO *control |
| 44 | exit |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 45 | elif [ "$1" = "-x" ]; then |
Mike Frysinger | ee22fe8 | 2016-04-04 01:35:34 -0400 | [diff] [blame] | 46 | exist |
| 47 | if [ -z "$3" ]; then |
| 48 | usage |
| 49 | elif [ ! -d "$3" ]; then |
| 50 | echo "No such directory $3!" |
| 51 | exit 1 |
| 52 | fi |
| 53 | ar -p "${deb}" data.tar.gz | tar -xzvpf - -C "$3" || exit |
| 54 | echo |
| 55 | echo "Extracted ${deb} to $3!" |
| 56 | exit |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 57 | else |
Mike Frysinger | ee22fe8 | 2016-04-04 01:35:34 -0400 | [diff] [blame] | 58 | usage |
Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 59 | fi |