Eric Andersen | 4bfb6b7 | 2000-11-29 21:39:02 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | usage() { |
| 4 | echo "Usage: undeb -c package.deb <Print control file info>" |
| 5 | echo " undeb -l package.deb <List contents of deb package>" |
| 6 | echo " undeb -x package.deb /foo/boo <Extract deb package to this directory," |
| 7 | echo " put . for current directory>" |
| 8 | exit |
| 9 | } |
| 10 | |
| 11 | deb=$2 |
| 12 | |
| 13 | exist() { |
| 14 | if [ "$deb" = "" ]; then |
| 15 | usage |
| 16 | elif [ ! -s "$deb" ]; then |
| 17 | echo "Can't find $deb!" |
| 18 | exit |
| 19 | fi |
| 20 | } |
| 21 | |
| 22 | if [ "$1" = "" ]; then |
| 23 | usage |
| 24 | elif [ "$1" = "-l" ]; then |
| 25 | exist |
| 26 | type more >/dev/null 2>&1 && pager=more |
| 27 | type less >/dev/null 2>&1 && pager=less |
| 28 | trap "" 13 |
| 29 | (ar -p $deb control.tar.gz | gunzip -c | tar -x -O control ; echo -e "\nPress enter to scroll, q to Quit!\n" ; ar -p $deb data.tar.gz | gunzip -c | tar -t -v 2>/dev/null) | $pager |
| 30 | exit |
| 31 | elif [ "$1" = "-c" ]; then |
| 32 | exist |
| 33 | ar -p $deb control.tar.gz | gunzip -c | tar -x -O control |
| 34 | exit |
| 35 | elif [ "$1" = "-x" ]; then |
| 36 | exist |
| 37 | if [ "$3" = "" ]; then |
| 38 | usage |
| 39 | elif [ ! -d "$3" ]; then |
| 40 | echo "No such directory $3!" |
| 41 | exit |
| 42 | fi |
| 43 | ar -p $deb data.tar.gz | gunzip | (cd $3 ; tar -x -v -f -) || exit |
| 44 | echo |
| 45 | echo "Extracted $deb to $3!" |
| 46 | exit |
| 47 | else |
| 48 | usage |
| 49 | fi |