summaryrefslogtreecommitdiff
path: root/contrib/image-convert/tar2ext2
diff options
context:
space:
mode:
authorFlorian Boor <florian.boor@kernelconcepts.de>2008-02-07 13:08:35 +0000
committerFlorian Boor <florian.boor@kernelconcepts.de>2008-02-07 13:08:35 +0000
commitbe3429189fb5eb2c12936f8d568bd8ba7d111ddc (patch)
tree3a96cda412e61a886aae321d88c6ed16bf994e51 /contrib/image-convert/tar2ext2
parent6853e674e42ffa97b62d6354c38d15b075956ecd (diff)
parent28fee5ea2a5f032871b989acd23e6c4ac26287e4 (diff)
merge of '0f1b9dcedb4d611ce7ce7ca8935b934dbc44061c'
and '8dadec7d9f47d3e60f4729a152204227dce39c49'
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; \
+"