summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/image-vm.bbclass171
-rw-r--r--meta/classes/image.bbclass3
-rw-r--r--meta/classes/image_types.bbclass12
-rw-r--r--meta/lib/oeqa/selftest/cases/runqemu.py8
-rw-r--r--meta/recipes-core/images/build-appliance-image_15.0.0.bb6
5 files changed, 14 insertions, 186 deletions
diff --git a/meta/classes/image-vm.bbclass b/meta/classes/image-vm.bbclass
deleted file mode 100644
index b52df9fbf5..0000000000
--- a/meta/classes/image-vm.bbclass
+++ /dev/null
@@ -1,171 +0,0 @@
1# image-vm.bbclass
2# (loosly based off image-live.bbclass Copyright (C) 2004, Advanced Micro Devices, Inc.)
3#
4# Create an image which can be placed directly onto a harddisk using dd and then
5# booted.
6#
7# This uses syslinux. extlinux would have been nice but required the ext2/3
8# partition to be mounted. grub requires to run itself as part of the install
9# process.
10#
11# The end result is a 512 boot sector populated with an MBR and partition table
12# followed by an msdos fat16 partition containing syslinux and a linux kernel
13# completed by the ext2/3 rootfs.
14#
15# We have to push the msdos parition table size > 16MB so fat 16 is used as parted
16# won't touch fat12 partitions.
17
18inherit live-vm-common
19
20do_bootdirectdisk[depends] += "dosfstools-native:do_populate_sysroot \
21 virtual/kernel:do_deploy \
22 syslinux:do_populate_sysroot \
23 syslinux-native:do_populate_sysroot \
24 parted-native:do_populate_sysroot \
25 mtools-native:do_populate_sysroot \
26 ${PN}:do_image_${VM_ROOTFS_TYPE} \
27 "
28
29IMAGE_TYPEDEP_vmdk = "${VM_ROOTFS_TYPE}"
30IMAGE_TYPEDEP_vdi = "${VM_ROOTFS_TYPE}"
31IMAGE_TYPEDEP_qcow2 = "${VM_ROOTFS_TYPE}"
32IMAGE_TYPEDEP_hdddirect = "${VM_ROOTFS_TYPE}"
33IMAGE_TYPES_MASKED += "vmdk vdi qcow2 hdddirect"
34
35VM_ROOTFS_TYPE ?= "ext4"
36ROOTFS ?= "${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${VM_ROOTFS_TYPE}"
37
38# Used by bootloader
39LABELS_VM ?= "boot"
40ROOT_VM ?= "root=/dev/sda2"
41# Using an initramfs is optional. Enable it by setting INITRD_IMAGE_VM.
42INITRD_IMAGE_VM ?= ""
43INITRD_VM ?= "${@'${IMGDEPLOYDIR}/${INITRD_IMAGE_VM}-${MACHINE}.cpio.gz' if '${INITRD_IMAGE_VM}' else ''}"
44do_bootdirectdisk[depends] += "${@'${INITRD_IMAGE_VM}:do_image_complete' if '${INITRD_IMAGE_VM}' else ''}"
45
46BOOTDD_VOLUME_ID ?= "boot"
47BOOTDD_EXTRA_SPACE ?= "16384"
48
49DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}"
50DISK_SIGNATURE[vardepsexclude] = "DISK_SIGNATURE_GENERATED"
51
52build_boot_dd() {
53 HDDDIR="${S}/hdd/boot"
54 HDDIMG="${S}/hdd.image"
55 IMAGE=${IMGDEPLOYDIR}/${IMAGE_NAME}.hdddirect
56
57 populate_kernel $HDDDIR
58
59 if [ "${PCBIOS}" = "1" ]; then
60 syslinux_hddimg_populate $HDDDIR
61 fi
62 if [ "${EFI}" = "1" ]; then
63 efi_hddimg_populate $HDDDIR
64 fi
65
66 BLOCKS=`du -bks $HDDDIR | cut -f 1`
67 BLOCKS=`expr $BLOCKS + ${BOOTDD_EXTRA_SPACE}`
68
69 # Remove it since mkdosfs would fail when it exists
70 rm -f $HDDIMG
71 mkdosfs -n ${BOOTDD_VOLUME_ID} ${MKDOSFS_EXTRAOPTS} -C $HDDIMG $BLOCKS
72 mcopy -i $HDDIMG -s $HDDDIR/* ::/
73
74 if [ "${PCBIOS}" = "1" ]; then
75 syslinux_hdddirect_install $HDDIMG
76 fi
77 chmod 644 $HDDIMG
78
79 ROOTFSBLOCKS=`du -Lbks ${ROOTFS} | cut -f 1`
80 TOTALSIZE=`expr $BLOCKS + $ROOTFSBLOCKS`
81 END1=`expr $BLOCKS \* 1024`
82 END2=`expr $END1 + 512`
83 END3=`expr \( $ROOTFSBLOCKS \* 1024 \) + $END1`
84
85 echo $ROOTFSBLOCKS $TOTALSIZE $END1 $END2 $END3
86 rm -rf $IMAGE
87 dd if=/dev/zero of=$IMAGE bs=1024 seek=$TOTALSIZE count=1
88
89 parted $IMAGE mklabel msdos
90 parted $IMAGE mkpart primary fat16 0 ${END1}B
91 parted $IMAGE unit B mkpart primary ext2 ${END2}B ${END3}B
92 parted $IMAGE set 1 boot on
93
94 parted $IMAGE print
95
96 awk "BEGIN { printf \"$(echo ${DISK_SIGNATURE} | sed 's/\(..\)\(..\)\(..\)\(..\)/\\x\4\\x\3\\x\2\\x\1/')\" }" | \
97 dd of=$IMAGE bs=1 seek=440 conv=notrunc
98
99 OFFSET=`expr $END2 / 512`
100 if [ "${PCBIOS}" = "1" ]; then
101 dd if=${STAGING_DATADIR}/syslinux/mbr.bin of=$IMAGE conv=notrunc
102 fi
103
104 dd if=$HDDIMG of=$IMAGE conv=notrunc seek=1 bs=512
105 dd if=${ROOTFS} of=$IMAGE conv=notrunc seek=$OFFSET bs=512
106
107 cd ${IMGDEPLOYDIR}
108
109 ln -sf ${IMAGE_NAME}.hdddirect ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.hdddirect
110}
111
112python do_bootdirectdisk() {
113 validate_disk_signature(d)
114 set_live_vm_vars(d, 'VM')
115 if d.getVar("PCBIOS") == "1":
116 bb.build.exec_func('build_syslinux_cfg', d)
117 if d.getVar("EFI") == "1":
118 bb.build.exec_func('build_efi_cfg', d)
119 bb.build.exec_func('build_boot_dd', d)
120}
121
122def generate_disk_signature():
123 import uuid
124
125 signature = str(uuid.uuid4())[:8]
126
127 if signature != '00000000':
128 return signature
129 else:
130 return 'ffffffff'
131
132def validate_disk_signature(d):
133 import re
134
135 disk_signature = d.getVar("DISK_SIGNATURE")
136
137 if not re.match(r'^[0-9a-fA-F]{8}$', disk_signature):
138 bb.fatal("DISK_SIGNATURE '%s' must be an 8 digit hex string" % disk_signature)
139
140DISK_SIGNATURE_GENERATED := "${@generate_disk_signature()}"
141
142run_qemu_img (){
143 type="$1"
144 qemu-img convert -O $type ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.hdddirect ${IMGDEPLOYDIR}/${IMAGE_NAME}.$type
145
146 ln -sf ${IMAGE_NAME}.$type ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type
147}
148create_vmdk_image () {
149 run_qemu_img vmdk
150}
151
152create_vdi_image () {
153 run_qemu_img vdi
154}
155
156create_qcow2_image () {
157 run_qemu_img qcow2
158}
159
160python do_vmimg() {
161 if 'vmdk' in d.getVar('IMAGE_FSTYPES'):
162 bb.build.exec_func('create_vmdk_image', d)
163 if 'vdi' in d.getVar('IMAGE_FSTYPES'):
164 bb.build.exec_func('create_vdi_image', d)
165 if 'qcow2' in d.getVar('IMAGE_FSTYPES'):
166 bb.build.exec_func('create_qcow2_image', d)
167}
168
169addtask bootdirectdisk before do_vmimg
170addtask vmimg after do_bootdirectdisk before do_image_complete
171do_vmimg[depends] += "qemu-native:do_populate_sysroot"
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index dee17ae9f9..40bd61480e 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -138,9 +138,6 @@ def build_live(d):
138IMAGE_TYPE_live = "${@build_live(d)}" 138IMAGE_TYPE_live = "${@build_live(d)}"
139inherit ${IMAGE_TYPE_live} 139inherit ${IMAGE_TYPE_live}
140 140
141IMAGE_TYPE_vm = '${@bb.utils.contains_any("IMAGE_FSTYPES", ["vmdk", "vdi", "qcow2", "hdddirect"], "image-vm", "", d)}'
142inherit ${IMAGE_TYPE_vm}
143
144IMAGE_TYPE_container = '${@bb.utils.contains("IMAGE_FSTYPES", "container", "image-container", "", d)}' 141IMAGE_TYPE_container = '${@bb.utils.contains("IMAGE_FSTYPES", "container", "image-container", "", d)}'
145inherit ${IMAGE_TYPE_container} 142inherit ${IMAGE_TYPE_container}
146 143
diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
index ae4ed4fae4..e0368c7e3a 100644
--- a/meta/classes/image_types.bbclass
+++ b/meta/classes/image_types.bbclass
@@ -255,10 +255,6 @@ IMAGE_TYPES = " \
255 ubi ubifs multiubi \ 255 ubi ubifs multiubi \
256 tar tar.gz tar.bz2 tar.xz tar.lz4 \ 256 tar tar.gz tar.bz2 tar.xz tar.lz4 \
257 cpio cpio.gz cpio.xz cpio.lzma cpio.lz4 \ 257 cpio cpio.gz cpio.xz cpio.lzma cpio.lz4 \
258 vmdk \
259 vdi \
260 qcow2 \
261 hdddirect \
262 elf \ 258 elf \
263 wic wic.gz wic.bz2 wic.lzma \ 259 wic wic.gz wic.bz2 wic.lzma \
264 container \ 260 container \
@@ -270,7 +266,7 @@ IMAGE_TYPES = " \
270# CONVERSION_CMD/DEPENDS. 266# CONVERSION_CMD/DEPENDS.
271COMPRESSIONTYPES ?= "" 267COMPRESSIONTYPES ?= ""
272 268
273CONVERSIONTYPES = "gz bz2 lzma xz lz4 lzo zip sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum bmap u-boot ${COMPRESSIONTYPES}" 269CONVERSIONTYPES = "gz bz2 lzma xz lz4 lzo zip sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum bmap u-boot vmdk vdi qcow2 ${COMPRESSIONTYPES}"
274CONVERSION_CMD_lzma = "lzma -k -f -7 ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}" 270CONVERSION_CMD_lzma = "lzma -k -f -7 ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"
275CONVERSION_CMD_gz = "gzip -f -9 -c ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} > ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.gz" 271CONVERSION_CMD_gz = "gzip -f -9 -c ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} > ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.gz"
276CONVERSION_CMD_bz2 = "pbzip2 -f -k ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}" 272CONVERSION_CMD_bz2 = "pbzip2 -f -k ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"
@@ -288,6 +284,9 @@ CONVERSION_CMD_sha384sum = "sha384sum ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}
288CONVERSION_CMD_sha512sum = "sha512sum ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} > ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.sha512sum" 284CONVERSION_CMD_sha512sum = "sha512sum ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} > ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.sha512sum"
289CONVERSION_CMD_bmap = "bmaptool create ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} -o ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.bmap" 285CONVERSION_CMD_bmap = "bmaptool create ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} -o ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.bmap"
290CONVERSION_CMD_u-boot = "mkimage -A ${UBOOT_ARCH} -O linux -T ramdisk -C none -n ${IMAGE_NAME} -d ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.u-boot" 286CONVERSION_CMD_u-boot = "mkimage -A ${UBOOT_ARCH} -O linux -T ramdisk -C none -n ${IMAGE_NAME} -d ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.u-boot"
287CONVERSION_CMD_vmdk = "qemu-img convert -O vmdk ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.vmdk"
288CONVERSION_CMD_vdi = "qemu-img convert -O vdi ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.vdi"
289CONVERSION_CMD_qcow2 = "qemu-img convert -O qcow2 ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.qcow2"
291CONVERSION_DEPENDS_lzma = "xz-native" 290CONVERSION_DEPENDS_lzma = "xz-native"
292CONVERSION_DEPENDS_gz = "pigz-native" 291CONVERSION_DEPENDS_gz = "pigz-native"
293CONVERSION_DEPENDS_bz2 = "pbzip2-native" 292CONVERSION_DEPENDS_bz2 = "pbzip2-native"
@@ -298,6 +297,9 @@ CONVERSION_DEPENDS_zip = "zip-native"
298CONVERSION_DEPENDS_sum = "mtd-utils-native" 297CONVERSION_DEPENDS_sum = "mtd-utils-native"
299CONVERSION_DEPENDS_bmap = "bmap-tools-native" 298CONVERSION_DEPENDS_bmap = "bmap-tools-native"
300CONVERSION_DEPENDS_u-boot = "u-boot-mkimage-native" 299CONVERSION_DEPENDS_u-boot = "u-boot-mkimage-native"
300CONVERSION_DEPENDS_vmdk = "qemu-native"
301CONVERSION_DEPENDS_vdi = "qemu-native"
302CONVERSION_DEPENDS_qcow2 = "qemu-native"
301 303
302RUNNABLE_IMAGE_TYPES ?= "ext2 ext3 ext4" 304RUNNABLE_IMAGE_TYPES ?= "ext2 ext3 ext4"
303RUNNABLE_MACHINE_PATTERNS ?= "qemu" 305RUNNABLE_MACHINE_PATTERNS ?= "qemu"
diff --git a/meta/lib/oeqa/selftest/cases/runqemu.py b/meta/lib/oeqa/selftest/cases/runqemu.py
index 4050a4123b..8805a3837e 100644
--- a/meta/lib/oeqa/selftest/cases/runqemu.py
+++ b/meta/lib/oeqa/selftest/cases/runqemu.py
@@ -19,7 +19,7 @@ class RunqemuTests(OESelftestTestCase):
19 super(RunqemuTests, self).setUpLocal() 19 super(RunqemuTests, self).setUpLocal()
20 self.recipe = 'core-image-minimal' 20 self.recipe = 'core-image-minimal'
21 self.machine = 'qemux86-64' 21 self.machine = 'qemux86-64'
22 self.fstypes = "ext4 iso hddimg vmdk qcow2 vdi" 22 self.fstypes = "ext4 iso hddimg wic.vmdk wic.qcow2 wic.vdi"
23 self.cmd_common = "runqemu nographic" 23 self.cmd_common = "runqemu nographic"
24 24
25 # Avoid emit the same record multiple times. 25 # Avoid emit the same record multiple times.
@@ -74,7 +74,7 @@ SYSLINUX_TIMEOUT = "10"
74 @OETestID(2005) 74 @OETestID(2005)
75 def test_boot_recipe_image_vmdk(self): 75 def test_boot_recipe_image_vmdk(self):
76 """Test runqemu recipe-image vmdk""" 76 """Test runqemu recipe-image vmdk"""
77 cmd = "%s %s vmdk" % (self.cmd_common, self.recipe) 77 cmd = "%s %s wic.vmdk" % (self.cmd_common, self.recipe)
78 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: 78 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
79 with open(qemu.qemurunnerlog) as f: 79 with open(qemu.qemurunnerlog) as f:
80 self.assertTrue('format=vmdk' in f.read(), "Failed: %s" % cmd) 80 self.assertTrue('format=vmdk' in f.read(), "Failed: %s" % cmd)
@@ -82,7 +82,7 @@ SYSLINUX_TIMEOUT = "10"
82 @OETestID(2006) 82 @OETestID(2006)
83 def test_boot_recipe_image_vdi(self): 83 def test_boot_recipe_image_vdi(self):
84 """Test runqemu recipe-image vdi""" 84 """Test runqemu recipe-image vdi"""
85 cmd = "%s %s vdi" % (self.cmd_common, self.recipe) 85 cmd = "%s %s wic.vdi" % (self.cmd_common, self.recipe)
86 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: 86 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
87 with open(qemu.qemurunnerlog) as f: 87 with open(qemu.qemurunnerlog) as f:
88 self.assertTrue('format=vdi' in f.read(), "Failed: %s" % cmd) 88 self.assertTrue('format=vdi' in f.read(), "Failed: %s" % cmd)
@@ -113,7 +113,7 @@ SYSLINUX_TIMEOUT = "10"
113 @OETestID(2009) 113 @OETestID(2009)
114 def test_boot_machine_slirp_qcow2(self): 114 def test_boot_machine_slirp_qcow2(self):
115 """Test runqemu machine slirp qcow2""" 115 """Test runqemu machine slirp qcow2"""
116 cmd = "%s slirp qcow2 %s" % (self.cmd_common, self.machine) 116 cmd = "%s slirp wic.qcow2 %s" % (self.cmd_common, self.machine)
117 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu: 117 with runqemu(self.recipe, ssh=False, launch_cmd=cmd) as qemu:
118 with open(qemu.qemurunnerlog) as f: 118 with open(qemu.qemurunnerlog) as f:
119 self.assertTrue('format=qcow2' in f.read(), "Failed: %s" % cmd) 119 self.assertTrue('format=qcow2' in f.read(), "Failed: %s" % cmd)
diff --git a/meta/recipes-core/images/build-appliance-image_15.0.0.bb b/meta/recipes-core/images/build-appliance-image_15.0.0.bb
index f145b5e656..927a9310ac 100644
--- a/meta/recipes-core/images/build-appliance-image_15.0.0.bb
+++ b/meta/recipes-core/images/build-appliance-image_15.0.0.bb
@@ -19,7 +19,7 @@ IMAGE_ROOTFS_EXTRA_SPACE = "41943040"
19APPEND += "rootfstype=ext4 quiet" 19APPEND += "rootfstype=ext4 quiet"
20 20
21DEPENDS = "zip-native python3-pip-native" 21DEPENDS = "zip-native python3-pip-native"
22IMAGE_FSTYPES = "vmdk" 22IMAGE_FSTYPES = "wic.vmdk"
23 23
24inherit core-image module-base setuptools3 24inherit core-image module-base setuptools3
25 25
@@ -120,7 +120,7 @@ create_bundle_files () {
120 cd ${WORKDIR} 120 cd ${WORKDIR}
121 mkdir -p Yocto_Build_Appliance 121 mkdir -p Yocto_Build_Appliance
122 cp *.vmx* Yocto_Build_Appliance 122 cp *.vmx* Yocto_Build_Appliance
123 ln -sf ${IMGDEPLOYDIR}/${IMAGE_NAME}.vmdk Yocto_Build_Appliance/Yocto_Build_Appliance.vmdk 123 ln -sf ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.wic.vmdk Yocto_Build_Appliance/Yocto_Build_Appliance.vmdk
124 zip -r ${IMGDEPLOYDIR}/Yocto_Build_Appliance-${DATETIME}.zip Yocto_Build_Appliance 124 zip -r ${IMGDEPLOYDIR}/Yocto_Build_Appliance-${DATETIME}.zip Yocto_Build_Appliance
125 ln -sf Yocto_Build_Appliance-${DATETIME}.zip ${IMGDEPLOYDIR}/Yocto_Build_Appliance.zip 125 ln -sf Yocto_Build_Appliance-${DATETIME}.zip ${IMGDEPLOYDIR}/Yocto_Build_Appliance.zip
126} 126}
@@ -130,4 +130,4 @@ python do_bundle_files() {
130 bb.build.exec_func('create_bundle_files', d) 130 bb.build.exec_func('create_bundle_files', d)
131} 131}
132 132
133addtask bundle_files after do_vmimg before do_image_complete 133addtask bundle_files after do_image_wic before do_image_complete