x86: use qemu-image command from image-commands.mk
authorPaul Spooren <[email protected]>
Fri, 20 Mar 2020 10:10:57 +0000 (00:10 -1000)
committerDaniel Golle <[email protected]>
Sat, 21 Mar 2020 10:36:00 +0000 (10:36 +0000)
The `qemu-image` command converts images to the specified type and
reduces redundant code.

Adaption from Alexander Couzens <[email protected]> work[0].

[0]: https://git.openwrt.org/?p=openwrt/staging/lynxis.git;a=blob;f=target/linux/x86/image/Makefile;h=83b8140b7aefbe708fd09c9c61827e7e39bda8b4;hb=416cccf398e9589e3de386e05b61b1c46cace20d#l51

Signed-off-by: Paul Spooren <[email protected]>
include/image-commands.mk
target/linux/x86/image/Makefile

index 37cb083bbfbca2c6c62305f20d3840ddc476eb1f..2ec1922044d206e45aaed2beb19ffdbb83bddd6d 100644 (file)
@@ -414,3 +414,10 @@ define Build/kernel2minor
        kernel2minor -k $@ -r [email protected] $(1)
        mv [email protected] $@
 endef
+
+# Convert a raw image into a $1 type image.
+# E.g. | qemu-image vdi
+define Build/qemu-image
+       qemu-img convert -f raw -O $1 $@ [email protected]
+       @mv [email protected] $@
+endef
index 494a190b8664459655c0d4b7aad307278e46de9a..dfa1742d5a23c198828870f329a9b535391b6ba1 100644 (file)
@@ -92,23 +92,13 @@ define Build/iso
                -o $@ [email protected] $(TARGET_DIR)
 endef
 
-define Build/vdi
-       qemu-img convert -f raw -O vdi $@ [email protected]
-       @mv [email protected] $@
-endef
-
-define Build/vmdk
-       qemu-img convert -f raw -O vmdk $@ [email protected]
-       @mv [email protected] $@
-endef
-
 DEVICE_VARS += GRUB2_VARIANT
 define Device/Default
   ARTIFACT/image.iso := grub-config iso | iso
   IMAGES := combined.img.gz
   IMAGE/combined.img.gz := append-rootfs | pad-extra 128k | grub-config pc | combined | grub-install | gzip
-  IMAGE/combined.vdi := append-rootfs | pad-extra 128k | grub-config pc | combined | grub-install | vdi
-  IMAGE/combined.vmdk := append-rootfs | pad-extra 128k | grub-config pc | combined | grub-install | vmdk
+  IMAGE/combined.vdi := append-rootfs | pad-extra 128k | grub-config pc | combined | grub-install | qemu-image vdi
+  IMAGE/combined.vmdk := append-rootfs | pad-extra 128k | grub-config pc | combined | grub-install | qemu-image vmdk
   KERNEL := kernel-bin
   KERNEL_INSTALL := 1
   KERNEL_NAME := bzImage