On Fri, Sep 09, 2011 at 12:04:24AM +0200, Philippe Corbes wrote:
> Author: Philippe Corbes <[email protected]>
> Date:   Wed Sep 7 23:38:56 2011 +0200
> 
>     Add VirtualBox disk image build script
> 
>     Signed-off-by: Philippe Corbes <[email protected]>
> 
> 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/image_hd_vdi.make b/rules/post/image_hd_vdi.make
> new file mode 100644
> index 0000000..66227bb
> --- /dev/null
> +++ b/rules/post/image_hd_vdi.make
> @@ -0,0 +1,22 @@
> +# -*-makefile-*-
> +#
> +# Copyright (C) 2011 by the Philippe Corbes <[email protected]>
> +#
> +# 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
> +
> +$(IMAGEDIR)/hd.vdi: $(IMAGEDIR)/hd.img
> +    @$(call targetinfo)
> +    @echo "Creating hd.vdi from hd.vdi";                        \
> +    PATH=$(PTXCONF_SYSROOT_HOST)/bin:$$PATH
> $(PTXDIST_TOPDIR)/scripts/genhdvdi    \

your email client is adden line-breaks.

> +    -i $(IMAGEDIR)/hd.img    \
> +    -o $(IMAGEDIR)/hd.vdi
> +    @echo "done."
> +    @$(call touch, $@)

we prefer a different style now. Something like:

$(IMAGEDIR)/hd.vdi: $(IMAGEDIR)/hd.img
        $(call image/env) \
        image_hd="$<" \
        image_vdi="$@" \
        ptxd_make_image_vdi

and the rest in the script.

> +
> +# vim: syntax=make
> diff --git a/scripts/genhdvdi b/scripts/genhdvdi

put it in scripts/lib/ptxd_make_image_vdi.sh

ptxd_make_image_vdi() {
...
}
export -f ptxd_make_image_vdi

Michael

> new file mode 100755
> index 0000000..3677f10
> --- /dev/null
> +++ b/scripts/genhdvdi
> @@ -0,0 +1,60 @@
> +#!/bin/bash
> +
> +# Tool to create/update a VirtualBox disk image from an .img file
> +#
> +# Copyright (C) 2011 by Philippe Corbes <[email protected]>
> +#
> +
> +
> +Usage() {
> +cat <<-EOF
> +
> +Usage: `basename "$0"` OPTIONS
> +
> +    -h               this help
> +    -i <input file>  the .img hd image file name
> +    -o <output file> the .vdi hd image file name
> +EOF
> +}
> +
> +
> +while getopts "hi:o:" OPT
> +do
> +    case "$OPT" in
> +        h)  Usage
> +        exit 1
> +            ;;
> +    i)  IMGFILE="$OPTARG"
> +        ;;
> +    o)  VDIFILE="$OPTARG"
> +        ;;
> +    esac
> +done
> +
> +if [ -z "$IMGFILE" ]; then
> +    echo "no input image file given"
> +    exit 1
> +fi
> +
> +if [ -z "$VDIFILE" ]; then
> +    echo "no output image file given"
> +    exit 1
> +fi
> +
> +VBOXMANAGE=`whereis VBoxManage|sed -e "s/.* //"`
> +if [ ! -x `expr ${VBOXMANAGE}` ]; then
> +    echo "Virtualbox not installed!"
> +    exit 1
> +fi
> +
> +if [ -f "${VDIFILE}" ]; then
> +    # Update the existing vdi file
> +    UUID=$(${VBOXMANAGE} showhdinfo ${VDIFILE}|grep -e "UUID:"|grep -v
> "(UUID"|sed -e "s/.* //")
> +    rm -f ${VDIFILE}
> +    ${VBOXMANAGE} convertdd ${IMGFILE} ${VDIFILE} 2>&1
> +    ${VBOXMANAGE} internalcommands sethduuid ${VDIFILE} ${UUID}
> +else
> +    # First time then create the vdi file
> +    ${VBOXMANAGE} convertdd ${IMGFILE} ${VDIFILE} 2>&1
> +fi
> +

> -- 
> ptxdist mailing list
> [email protected]


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

-- 
ptxdist mailing list
[email protected]

Reply via email to