From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-qw0-f42.google.com ([209.85.216.42]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1R6Tf7-0007Jy-E7 for ptxdist@pengutronix.de; Wed, 21 Sep 2011 22:44:59 +0200 Received: by qwm42 with SMTP id 42so3476382qwm.1 for ; Wed, 21 Sep 2011 13:44:50 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20110917190927.GF5139@pengutronix.de> References: <20110909101339.GO32665@pengutronix.de> <20110917190927.GF5139@pengutronix.de> Date: Wed, 21 Sep 2011 22:44:49 +0200 Message-ID: From: Philippe Corbes Subject: Re: [ptxdist] Add VirtualBox disk image build script Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de commit e541451a11e4b39bf9c0ce62b223dfee830b9999 Author: Philippe Corbes Date: Wed Sep 21 22:39:35 2011 +0200 Add VirtualBox disk image build script Signed-off-by: Philippe Corbes 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 +# +# 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 +# +# 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