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