aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/image-convert/tar2ext2
diff options
context:
space:
mode:
authorPaul Sokolovsky <pmiscml@gmail.com>2008-02-06 16:36:16 +0000
committerPaul Sokolovsky <pmiscml@gmail.com>2008-02-06 16:36:16 +0000
commitc4b9bd13292f10884ad96854b79b1d22251bd1e7 (patch)
tree25eca358bf73c213f132526e1b0e36cb1a684b93 /contrib/image-convert/tar2ext2
parent6b9c2ffba4d6d8dc85d3667c76af92a8cf53eacf (diff)
downloadopenembedded-c4b9bd13292f10884ad96854b79b1d22251bd1e7.tar.gz
openembedded-c4b9bd13292f10884ad96854b79b1d22251bd1e7.tar.bz2
openembedded-c4b9bd13292f10884ad96854b79b1d22251bd1e7.zip
contrib/image-convert: Add scripts to convert FS images to different formats.
* Per RFC on the list.
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; \
+"