* Re: [ptxdist] Add VirtualBox disk image build script
2011-09-17 19:09 ` [ptxdist] Add VirtualBox disk image build script Robert Schwebel
@ 2011-09-21 20:44 ` Philippe Corbes
0 siblings, 0 replies; 2+ messages in thread
From: Philippe Corbes @ 2011-09-21 20:44 UTC (permalink / raw)
To: ptxdist
commit e541451a11e4b39bf9c0ce62b223dfee830b9999
Author: Philippe Corbes <philippe.corbes@gmail.com>
Date: Wed Sep 21 22:39:35 2011 +0200
Add VirtualBox disk image build script
Signed-off-by: Philippe Corbes <philippe.corbes@gmail.com>
diff --git a/platforms/image_hd_vdi.in b/platforms/image_hd_vdi.in
new file mode 100644
index 0000000..7280e13
--- /dev/null
+++ b/platforms/image_hd_vdi.in
@@ -0,0 +1,13 @@
+## SECTION=image
+
+config IMAGE_VDI
+ bool
+ select IMAGE_HD
+ select IMAGE_EXT2
+ select HOST_GENPART
+ prompt "Generate images/hd.vdi"
+ help
+ Build a VirtualBox's disk image file.
+ Check "Generate images/hd.img" to define the hd geometry.
+ This option is available only if VirtualBox is installed on this machine.
+
diff --git a/rules/post/ptxd_make_image_vdi.make
b/rules/post/ptxd_make_image_vdi.make
new file mode 100644
index 0000000..3ce48bc
--- /dev/null
+++ b/rules/post/ptxd_make_image_vdi.make
@@ -0,0 +1,32 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2011 by the Philippe Corbes <philippe.corbes@gmail.com>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+SEL_ROOTFS-$(PTXCONF_IMAGE_VDI) += $(IMAGEDIR)/hd.vdi
+
+#
+# image/vdi
+#
+# - $1 the .img image file name
+# - $2 the .vdi image file name
+#
+image/vdi = \
+ $(call image/env) \
+ image_vdi_img="$(1)" \
+ image_vdi_vdi="$(2)" \
+ ptxd_make_image_vdi
+
+$(IMAGEDIR)/%.vdi: $(IMAGEDIR)/%.img
+ @$(call targetinfo)
+ @echo "Creating `basename $@` from `basename $<`";
+ $(call image/vdi,$<,$@)
+ @echo "done."
+ @$(call touch, $@)
+
+# vim: syntax=make
diff --git a/scripts/lib/ptxd_make_image_vdi.sh
b/scripts/lib/ptxd_make_image_vdi.sh
new file mode 100644
index 0000000..69f95c7
--- /dev/null
+++ b/scripts/lib/ptxd_make_image_vdi.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# Copyright (C) 2011 by Philippe Corbes <philippe.corbes@gmail.com>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# create or update a vdi image from an img file.
+#
+# in:
+# - $image_vdi_img the source file name
+# - $image_vdi_vdi the destination file name
+#
+ptxd_make_image_vdi() {
+ local vboxmanage=`whereis VBoxManage|sed -e "s/.* //"`
+ if [ ! -x `expr ${vboxmanage}` ]; then
+ echo "Virtualbox not installed!"
+ exit 1
+ fi
+
+ if [ -f "${image_vdi_vdi}" ]; then
+ # Update the existing vdi file
+ local uuid=$(${vboxmanage} showhdinfo ${image_vdi_vdi}|grep -e
"UUID:"|grep -v "(UUID"|sed -e "s/.* //")
+ rm -f ${image_vdi_vdi}
+ ${vboxmanage} convertdd ${image_vdi_img} ${image_vdi_vdi} 2>&1
+ ${vboxmanage} internalcommands sethduuid ${image_vdi_vdi} ${uuid}
+ else
+ # First time then create the vdi file
+ ${vboxmanage} convertdd ${image_vdi_img} ${image_vdi_vdi} 2>&1
+ fi
+}
+export -f ptxd_make_image_vdi
+
--
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 2+ messages in thread