summaryrefslogtreecommitdiff
path: root/contrib/image-convert/tar2ext2
diff options
context:
space:
mode:
authorMichael Lauer <mickey@vanille-media.de>2008-02-07 23:32:09 +0000
committerMichael Lauer <mickey@vanille-media.de>2008-02-07 23:32:09 +0000
commitba4001fe8c00586b71fb1043795e1b99e3234025 (patch)
treece66a6f384b00812ad533d7b8975d5f8a8bd3402 /contrib/image-convert/tar2ext2
parentd9a05430e070a497ca4db0a3f8f746fb952b5ecd (diff)
parenta962c31f95cc3e4eb996eff609e973bcd2d2fc5c (diff)
merge of '2b4e1c7a35c118cf363c771f015c4fdfa5f84731'
and '36fe2f5bf87b5a8eedda174012a2e93f8bb5a8f5'
Diffstat (limited to 'contrib/image-convert/tar2ext2')
-rwxr-xr-xcontrib/image-convert/tar2ext225
1 files changed, 25 insertions, 0 deletions
diff --git a/contrib/image-convert/tar2ext2 b/contrib/image-convert/tar2ext2
new file mode 100755
index 0000000000..d5756a4733
--- /dev/null
+++ b/contrib/image-convert/tar2ext2
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+if [ $# -ne 2 ]; then
+ echo "Usage: $0 <tarball> <ext2 size>"
+ exit
+fi
+
+ext=`echo $1 | sed -r -e 's/.+\.([^.]+\.[^.]+)/\1/'`
+base=$(basename $1 .$ext)
+dir=$(dirname $1)
+
+if [ "$ext" == "tar.bz2" ]; then
+ uncompress=j
+else
+ uncompress=z
+fi
+
+rm -rf mnt
+mkdir -p mnt
+
+fakeroot bash -c "\
+tar -x$uncompress -f $1 -C mnt; \
+genext2fs -d mnt -b $(($2 * 1024)) $dir/$base.img; \
+rm -rf mnt; \
+"