diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2011-12-12 14:15:58 +0100 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2011-12-15 11:16:19 +0100 |
commit | f35d9439733c85dc8a9961b9e4c2c5f8ccdb0b2b (patch) | |
tree | 71c666e52daa1adf4563f5478c93dab288ea9d11 /scripts/lib/ptxd_make_image_vdi.sh | |
parent | 03b488abc3c537e448f9c7f5cf50388efbd9f2d9 (diff) | |
download | ptxdist-f35d9439733c85dc8a9961b9e4c2c5f8ccdb0b2b.tar.gz ptxdist-f35d9439733c85dc8a9961b9e4c2c5f8ccdb0b2b.tar.xz |
Add VirtualBox disk image build script
Based on a patch from Philippe Corbes <philippe.corbes@gmail.com>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts/lib/ptxd_make_image_vdi.sh')
-rw-r--r-- | scripts/lib/ptxd_make_image_vdi.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/lib/ptxd_make_image_vdi.sh b/scripts/lib/ptxd_make_image_vdi.sh new file mode 100644 index 000000000..53351d05d --- /dev/null +++ b/scripts/lib/ptxd_make_image_vdi.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# Copyright (C) 2011 by Philippe Corbes <philippe.corbes@gmail.com> +# (C) 2011 by Michael Olbrich <m.olbrich@pengutronix.de> +# +# 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 uuid + + if ! which vboxmanage > /dev/null; then + ptxd_bailout "Virtualbox not installed!" + fi + + # remember UUID if the image already exists. + if [ -f "${image_vdi_vdi}" ]; then + uuid="$(vboxmanage showhdinfo "${image_vdi_vdi}" | awk '/^UUID:/ { print $2 }')" && + rm -f "${image_vdi_vdi}" + fi && + + vboxmanage convertdd "${image_vdi_img}" "${image_vdi_vdi}" 2>&1 && + + if [ -n "${uuid}" ]; then + vboxmanage internalcommands sethduuid "${image_vdi_vdi}" "${uuid}" + fi +} +export -f ptxd_make_image_vdi |