aboutsummaryrefslogtreecommitdiff
path: root/deb2tgz
diff options
context:
space:
mode:
Diffstat (limited to 'deb2tgz')
-rwxr-xr-xdeb2tgz24
1 files changed, 24 insertions, 0 deletions
diff --git a/deb2tgz b/deb2tgz
new file mode 100755
index 0000000..bb7b3d0
--- /dev/null
+++ b/deb2tgz
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+INPUT="$1"
+
+if [ -z "$INPUT" -o "$INPUT" = "--help" ]; then
+ echo "deb2tgz by B. Watson <yalhcru@gmail.com>, WTFPL"
+ echo "Usage: `basename $0` filename.deb"
+ exit 0
+fi
+
+OUTPUT="`basename $1 .deb`.tgz"
+
+# 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
+
+ar p "$INPUT" "$DATA" > $OUTPUT