summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Brodkorb <mail@waldemar-brodkorb.de>2012-07-11 19:10:59 +0200
committerWaldemar Brodkorb <mail@waldemar-brodkorb.de>2012-07-11 19:10:59 +0200
commit2636f0ed7b5fe9ddbc1cb3f9c9348550c7eac099 (patch)
tree5ab11a145fe690aa91be5931cd56044cdba65722
parent2b19147fc3652939ca14a0b9b5b8f3a35381ae74 (diff)
use genext2fs on MacOS X to create qemu images
-rw-r--r--mk/rootfs.mk1
-rwxr-xr-xscripts/create-image.sh148
-rw-r--r--scripts/mbrbin0 -> 16384 bytes
-rw-r--r--target/config/Config.in9
-rw-r--r--target/x86/Makefile6
-rw-r--r--tools/Makefile2
-rw-r--r--tools/genext2fs/Makefile25
-rw-r--r--tools/rules.mk7
8 files changed, 140 insertions, 58 deletions
diff --git a/mk/rootfs.mk b/mk/rootfs.mk
index 5aba137da..283c87aa7 100644
--- a/mk/rootfs.mk
+++ b/mk/rootfs.mk
@@ -41,6 +41,7 @@ else
USB:= rootdelay=2
endif
+$(eval $(call rootfs_template,genext2fs,GENEXT2FS,$(ROOTFS)))
$(eval $(call rootfs_template,cf,CF,$(ROOTFS)))
$(eval $(call rootfs_template,mmc,MMC,$(ROOTFS)))
$(eval $(call rootfs_template,usb,USB,$(USB)))
diff --git a/scripts/create-image.sh b/scripts/create-image.sh
index 2b5b34bc9..8d3dc8216 100755
--- a/scripts/create-image.sh
+++ b/scripts/create-image.sh
@@ -1,4 +1,26 @@
#!/usr/bin/env bash
+#-
+# Copyright © 2010-2012
+# Waldemar Brodkorb <wbx@openadk.org>
+#
+# Provided that these terms and disclaimer and all copyright notices
+# are retained or reproduced in an accompanying document, permission
+# is granted to deal in this work without restriction, including un‐
+# limited rights to use, publicly perform, distribute, sell, modify,
+# merge, give away, or sublicence.
+#
+# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
+# the utmost extent permitted by applicable law, neither express nor
+# implied; without malicious intent or gross negligence. In no event
+# may a licensor, author or contributor be held liable for indirect,
+# direct, other damage, loss, or other issues arising in any way out
+# of dealing in the work, even if advised of the possibility of such
+# damage or existence of a defect, except proven that it results out
+# of said person’s immediate fault when using the work as intended.
+#
+# Alternatively, this work may be distributed under the terms of the
+# General Public License, any version, as published by the Free Soft-
+# ware Foundation.
filesystem=ext2
@@ -24,35 +46,32 @@ if [ $(id -u) -ne 0 ];then
exit 1
fi
-printf "Checking if mkfs is installed"
-mkfs=$(which mkfs.$filesystem)
-
-if [ ! -z $mkfs -a -x $mkfs ];then
- printf "...okay\n"
-else
- printf "...failed\n"
+tools='qemu-img'
+ostype=$(uname -s)
+
+case $ostype in
+(Darwin)
+ tools="$tools genext2fs"
+ ;;
+(Linux)
+ tools="$tools mke2fs parted"
+ ;;
+(*)
+ printf Sorry, not ported to the OS "'$ostype'" yet.\n
exit 1
-fi
-
-printf "Checking if parted is installed"
-parted=$(which parted)
-
-if [ ! -z $parted -a -x $parted ];then
- printf "...okay\n"
-else
- printf "...failed\n"
- exit 1
-fi
-
-printf "Checking if qemu-img is installed"
-qimg=$(which qemu-img)
-
-if [ ! -z $qimg -a -x $qimg ];then
- printf "...okay\n"
-else
- printf "...failed\n"
- exit 1
-fi
+ ;;
+esac
+
+for tool in $tools; do
+ printf "Checking if $tool is installed..."
+ if which $tool >/dev/null; then
+ printf " okay\n"
+ else
+ printf " failed\n"
+ f=1
+ fi
+done
+(( f )) && exit 1
if [ -z $1 ];then
printf "Please give the name of the image file\n"
@@ -71,44 +90,53 @@ else
fi
fi
-
printf "Generate qemu image (512 MB)\n"
-$qimg create -f raw $1 512M >/dev/null
-
-printf "Creating filesystem $filesystem\n"
+qemu-img create -f raw $1 512M >/dev/null
printf "Create partition and filesystem\n"
-$parted -s $1 mklabel msdos
-$parted -s $1 -- mkpart primary ext2 0 -0
-$parted -s $1 set 1 boot on
+case $ostype in
+(Darwin)
+ offset=16384
+ ;;
+(Linux)
+ parted -s $1 mklabel msdos
+ parted -s $1 -- mkpart primary ext2 0 -0
+ parted -s $1 set 1 boot on
+ offset=$(parted $1 unit b print | tail -2 | head -1 | cut -f 1 --delimit="B" | cut -c 9-)
+ ;;
+(*)
+ printf Sorry, not ported to the OS "'$ostype'" yet.\n
+ exit 1
+ ;;
+esac
-offset=$(parted $1 unit b print | tail -2 | head -1 | cut -f 1 --delimit="B" | cut -c 9-)
-dd if=$1 of=mbr bs=$offset count=1 2>/dev/null
-dd if=$1 skip=$offset of=$1.new 2>/dev/null
+printf "Creating filesystem $filesystem\n"
if [ "$filesystem" = "ext2" -o "$filesystem" = "ext3" -o "$filesystem" = "ext4" ];then
mkfsopts=-F
fi
-mkfs.$filesystem $mkfsopts ${1}.new >/dev/null
-
-if [ $? -eq 0 ];then
- printf "Successfully created partition\n"
- #$parted $1 print
-else
- printf "Partition creation failed, Exiting.\n"
- exit 1
-fi
-
-cat mbr ${1}.new > $1
-rm ${1}.new
-rm mbr
-
-tmp=$(mktemp -d)
-
-mount -o loop,offset=$offset -t $filesystem $1 $tmp
-
+case $ostype in
+(Darwin)
+ tmp=$(mktemp -d -t xxx)
+ tar -C $tmp -xzpf $2
+ printf "Fixing permissions\n"
+ chmod 1777 $tmp/tmp
+ chmod 4755 $tmp/bin/busybox
+ genext2fs -b 409600 -d $tmp ${1}.new
+ cat scripts/mbr ${1}.new > $1
+ rm ${1}.new
+ ;;
+(Linux)
+ dd if=$1 of=mbr bs=$offset count=1 2>/dev/null
+ dd if=$1 skip=$offset of=$1.new 2>/dev/null
+ mkfs.$filesystem $mkfsopts ${1}.new >/dev/null
+ cat mbr ${1}.new > $1
+ rm ${1}.new
+ rm mbr
+ tmp=$(mktemp -d)
+ mount -o loop,offset=$offset -t $filesystem $1 $tmp
if [ -z $initramfs ];then
printf "Extracting install archive\n"
tar -C $tmp -xzpf $2
@@ -121,8 +149,14 @@ else
cp $2-kernel $tmp/boot/kernel
cp $2-initramfs $tmp/boot/initramfs
fi
+ umount $tmp
+ ;;
+(*)
+ printf Sorry, not ported to the OS "'$ostype'" yet.\n
+ exit 1
+ ;;
+esac
-umount $tmp
printf "Successfully installed.\n"
printf "Be sure $1 is writable for the user which use qemu\n"
exit 0
diff --git a/scripts/mbr b/scripts/mbr
new file mode 100644
index 000000000..574f20540
--- /dev/null
+++ b/scripts/mbr
Binary files differ
diff --git a/target/config/Config.in b/target/config/Config.in
index be22d7b55..f960afffa 100644
--- a/target/config/Config.in
+++ b/target/config/Config.in
@@ -589,6 +589,15 @@ config ADK_TARGET_ROOTFS_CF
Use this option if you have a compact flash based system.
(ext2 filesystem is used.)
+config ADK_TARGET_ROOTFS_GENEXT2FS
+ bool "read-write filesystem for compact flash (genext2fs version)"
+ depends on ADK_TARGET_WITH_CF
+ select ADK_KERNEL_EXT2_FS
+ select ADK_KERNEL_SCSI
+ help
+ Use this option if you have a compact flash based system.
+ (ext2 filesystem is used.)
+
config ADK_TARGET_ROOTFS_MMC
bool "read-write filesystem for mmc/sdcard"
depends on ADK_TARGET_WITH_MMC
diff --git a/target/x86/Makefile b/target/x86/Makefile
index aa5bdc2d7..40fe4ded6 100644
--- a/target/x86/Makefile
+++ b/target/x86/Makefile
@@ -9,6 +9,12 @@ include $(TOPDIR)/mk/image.mk
KERNEL:=$(LINUX_DIR)/arch/x86/boot/bzImage
+ifeq ($(ADK_TARGET_FS),genext2fs)
+imageinstall: $(BIN_DIR)/$(ROOTFSTARBALL)
+ @echo "The RootFS tarball is: $(BIN_DIR)/$(ROOTFSTARBALL)"
+ @echo "To install everything to CompactFlash use scripts/genext2.sh"
+endif
+
ifeq ($(ADK_TARGET_FS),cf)
imageinstall: $(BIN_DIR)/$(ROOTFSTARBALL)
@echo "The RootFS tarball is: $(BIN_DIR)/$(ROOTFSTARBALL)"
diff --git a/tools/Makefile b/tools/Makefile
index e4e0b249b..ee096db61 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -3,7 +3,7 @@
include $(TOPDIR)/rules.mk
-TARGETS:=adk mkcrypt cpio mkimage
+TARGETS:=adk mkcrypt cpio mkimage genext2fs
TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
diff --git a/tools/genext2fs/Makefile b/tools/genext2fs/Makefile
new file mode 100644
index 000000000..6cb0ce436
--- /dev/null
+++ b/tools/genext2fs/Makefile
@@ -0,0 +1,25 @@
+# This file is part of the OpenADK project. OpenADK is copyrighted
+# material, please see the LICENCE file in the top-level directory.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:= genext2fs
+PKG_VERSION:= 1.4.1
+PKG_RELEASE:= 1
+PKG_MD5SUM:= b7b6361bcce2cedff1ae437fadafe53b
+PKG_SITES:= ${MASTER_SITE_SOURCEFORGE:=genext2fs/}
+
+include ../rules.mk
+
+install: ${TOOLS_DIR}/genext2fs
+
+$(WRKBUILD)/.compiled: ${WRKDIST}/.prepared
+ (cd ${WRKBUILD}; ./configure)
+ ${MAKE} -C ${WRKBUILD} CC='${CC_FOR_BUILD}'
+ touch $@
+
+${TOOLS_DIR}/genext2fs: $(WRKBUILD)/.compiled
+ $(INSTALL_BIN) $(WRKBUILD)/genext2fs \
+ ${TOOLS_DIR}
+
+include $(TOPDIR)/mk/tools.mk
diff --git a/tools/rules.mk b/tools/rules.mk
new file mode 100644
index 000000000..a6a3684ac
--- /dev/null
+++ b/tools/rules.mk
@@ -0,0 +1,7 @@
+# This file is part of the OpenADK project. OpenADK is copyrighted
+# material, please see the LICENCE file in the top-level directory.
+
+WRKDIR_BASE= ${TOOLS_BUILD_DIR}
+WRKDIR= ${WRKDIR_BASE}
+
+include ${TOPDIR}/mk/buildhlp.mk