aboutsummaryrefslogtreecommitdiff
path: root/deb2tarball
blob: 6cbd2c4dcbe4e89900c7713e0a5fb59530f0eb00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

INPUT="$1"

if [ -z "$INPUT" -o "$INPUT" = "--help" ]; then
	echo "deb2tarball by B. Watson <urchlay@slackware.uk>, WTFPL"
	echo "Usage: `basename $0` filename.deb"
	exit 0
fi

# used to always be data.tar.gz, newer debs might have data.tar.xz,
# so we have to check. ar doesn't support wildcards like tar does, so
# we can't just say "data.tar.*".

DATA="$( ar t "$INPUT" 2>/dev/null | grep '^data\.tar\.' )"

if [ -z "$DATA" ]; then
  echo "Can't find any data.tar.* file(s) in the archive, invalid deb?" 2>&1
  exit 1
fi

EXT="$( echo $DATA | cut -d. -f2- )"
OUTPUT="`basename $1 .deb`".$EXT

echo "$OUTPUT"
ar p "$INPUT" "$DATA" > "$OUTPUT"