diff options
| -rw-r--r-- | meta/classes/image-live.bbclass | 60 | ||||
| -rw-r--r-- | meta/classes/image-vm.bbclass | 53 | ||||
| -rw-r--r-- | meta/classes/image.bbclass | 12 | ||||
| -rw-r--r-- | meta/classes/live-vm-common.bbclass | 58 |
4 files changed, 71 insertions, 112 deletions
diff --git a/meta/classes/image-live.bbclass b/meta/classes/image-live.bbclass index a08715cd83..c837fbfc92 100644 --- a/meta/classes/image-live.bbclass +++ b/meta/classes/image-live.bbclass | |||
| @@ -25,6 +25,8 @@ | |||
| 25 | # ${HDDIMG_ID} - FAT image volume-id | 25 | # ${HDDIMG_ID} - FAT image volume-id |
| 26 | # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional) | 26 | # ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional) |
| 27 | 27 | ||
| 28 | inherit live-vm-common | ||
| 29 | |||
| 28 | do_bootimg[depends] += "dosfstools-native:do_populate_sysroot \ | 30 | do_bootimg[depends] += "dosfstools-native:do_populate_sysroot \ |
| 29 | mtools-native:do_populate_sysroot \ | 31 | mtools-native:do_populate_sysroot \ |
| 30 | cdrtools-native:do_populate_sysroot \ | 32 | cdrtools-native:do_populate_sysroot \ |
| @@ -71,52 +73,11 @@ MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table" | |||
| 71 | BOOTIMG_VOLUME_ID ?= "boot" | 73 | BOOTIMG_VOLUME_ID ?= "boot" |
| 72 | BOOTIMG_EXTRA_SPACE ?= "512" | 74 | BOOTIMG_EXTRA_SPACE ?= "512" |
| 73 | 75 | ||
| 74 | EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}" | 76 | populate_live() { |
| 75 | EFI_PROVIDER ?= "grub-efi" | 77 | populate_kernel $1 |
| 76 | EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}" | 78 | if [ -s "${ROOTFS}" ]; then |
| 77 | 79 | install -m 0644 ${ROOTFS} $1/rootfs.img | |
| 78 | KERNEL_IMAGETYPE ??= "bzImage" | ||
| 79 | |||
| 80 | # Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not | ||
| 81 | # contain "efi". This way legacy is supported by default if neither is | ||
| 82 | # specified, maintaining the original behavior. | ||
| 83 | def pcbios(d): | ||
| 84 | pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d) | ||
| 85 | if pcbios == "0": | ||
| 86 | pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d) | ||
| 87 | return pcbios | ||
| 88 | |||
| 89 | PCBIOS = "${@pcbios(d)}" | ||
| 90 | PCBIOS_CLASS = "${@['','syslinux'][d.getVar('PCBIOS', True) == '1']}" | ||
| 91 | |||
| 92 | inherit ${EFI_CLASS} | ||
| 93 | inherit ${PCBIOS_CLASS} | ||
| 94 | |||
| 95 | populate() { | ||
| 96 | DEST=$1 | ||
| 97 | install -d ${DEST} | ||
| 98 | |||
| 99 | # Install kernel, initrd, and rootfs.img in DEST for all loaders to use. | ||
| 100 | install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} ${DEST}/vmlinuz | ||
| 101 | |||
| 102 | # initrd is made of concatenation of multiple filesystem images | ||
| 103 | if [ -n "${INITRD}" ]; then | ||
| 104 | rm -f ${DEST}/initrd | ||
| 105 | for fs in ${INITRD} | ||
| 106 | do | ||
| 107 | if [ -s "${fs}" ]; then | ||
| 108 | cat ${fs} >> ${DEST}/initrd | ||
| 109 | else | ||
| 110 | bbfatal "${fs} is invalid. initrd image creation failed." | ||
| 111 | fi | ||
| 112 | done | ||
| 113 | chmod 0644 ${DEST}/initrd | ||
| 114 | fi | ||
| 115 | |||
| 116 | if [ -n "${ROOTFS}" ] && [ -s "${ROOTFS}" ]; then | ||
| 117 | install -m 0644 ${ROOTFS} ${DEST}/rootfs.img | ||
| 118 | fi | 80 | fi |
| 119 | |||
| 120 | } | 81 | } |
| 121 | 82 | ||
| 122 | build_iso() { | 83 | build_iso() { |
| @@ -128,14 +89,13 @@ build_iso() { | |||
| 128 | # ${INITRD} is a list of multiple filesystem images | 89 | # ${INITRD} is a list of multiple filesystem images |
| 129 | for fs in ${INITRD} | 90 | for fs in ${INITRD} |
| 130 | do | 91 | do |
| 131 | if [ ! -s "${fs}" ]; then | 92 | if [ ! -s "$fs" ]; then |
| 132 | bbnote "ISO image will not be created. ${fs} is invalid." | 93 | bbnote "ISO image will not be created. $fs is invalid." |
| 133 | return | 94 | return |
| 134 | fi | 95 | fi |
| 135 | done | 96 | done |
| 136 | 97 | ||
| 137 | 98 | populate_live ${ISODIR} | |
| 138 | populate ${ISODIR} | ||
| 139 | 99 | ||
| 140 | if [ "${PCBIOS}" = "1" ]; then | 100 | if [ "${PCBIOS}" = "1" ]; then |
| 141 | syslinux_iso_populate ${ISODIR} | 101 | syslinux_iso_populate ${ISODIR} |
| @@ -275,7 +235,7 @@ build_fat_img() { | |||
| 275 | build_hddimg() { | 235 | build_hddimg() { |
| 276 | # Create an HDD image | 236 | # Create an HDD image |
| 277 | if [ "${NOHDD}" != "1" ] ; then | 237 | if [ "${NOHDD}" != "1" ] ; then |
| 278 | populate ${HDDDIR} | 238 | populate_live ${HDDDIR} |
| 279 | 239 | ||
| 280 | if [ "${PCBIOS}" = "1" ]; then | 240 | if [ "${PCBIOS}" = "1" ]; then |
| 281 | syslinux_hddimg_populate ${HDDDIR} | 241 | syslinux_hddimg_populate ${HDDDIR} |
diff --git a/meta/classes/image-vm.bbclass b/meta/classes/image-vm.bbclass index ced8eac4d9..66712a62ff 100644 --- a/meta/classes/image-vm.bbclass +++ b/meta/classes/image-vm.bbclass | |||
| @@ -15,6 +15,8 @@ | |||
| 15 | # We have to push the msdos parition table size > 16MB so fat 16 is used as parted | 15 | # We have to push the msdos parition table size > 16MB so fat 16 is used as parted |
| 16 | # won't touch fat12 partitions. | 16 | # won't touch fat12 partitions. |
| 17 | 17 | ||
| 18 | inherit live-vm-common | ||
| 19 | |||
| 18 | do_bootdirectdisk[depends] += "dosfstools-native:do_populate_sysroot \ | 20 | do_bootdirectdisk[depends] += "dosfstools-native:do_populate_sysroot \ |
| 19 | virtual/kernel:do_deploy \ | 21 | virtual/kernel:do_deploy \ |
| 20 | syslinux:do_populate_sysroot \ | 22 | syslinux:do_populate_sysroot \ |
| @@ -43,63 +45,14 @@ do_bootdirectdisk[depends] += "${@'${INITRD_IMAGE_VM}:do_image_complete' if '${I | |||
| 43 | BOOTDD_VOLUME_ID ?= "boot" | 45 | BOOTDD_VOLUME_ID ?= "boot" |
| 44 | BOOTDD_EXTRA_SPACE ?= "16384" | 46 | BOOTDD_EXTRA_SPACE ?= "16384" |
| 45 | 47 | ||
| 46 | EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}" | ||
| 47 | EFI_PROVIDER ?= "grub-efi" | ||
| 48 | EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}" | ||
| 49 | |||
| 50 | # Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not | ||
| 51 | # contain "efi". This way legacy is supported by default if neither is | ||
| 52 | # specified, maintaining the original behavior. | ||
| 53 | def pcbios(d): | ||
| 54 | pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d) | ||
| 55 | if pcbios == "0": | ||
| 56 | pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d) | ||
| 57 | return pcbios | ||
| 58 | |||
| 59 | def pcbios_class(d): | ||
| 60 | if d.getVar("PCBIOS", True) == "1": | ||
| 61 | return "syslinux" | ||
| 62 | return "" | ||
| 63 | |||
| 64 | PCBIOS = "${@pcbios(d)}" | ||
| 65 | PCBIOS_CLASS = "${@pcbios_class(d)}" | ||
| 66 | |||
| 67 | # Get the build_syslinux_cfg() function from the syslinux class | ||
| 68 | inherit ${PCBIOS_CLASS} | ||
| 69 | inherit ${EFI_CLASS} | ||
| 70 | |||
| 71 | DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}" | 48 | DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}" |
| 72 | 49 | ||
| 73 | boot_direct_populate() { | ||
| 74 | dest=$1 | ||
| 75 | install -d $dest | ||
| 76 | |||
| 77 | # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use. | ||
| 78 | if [ -e ${DEPLOY_DIR_IMAGE}/bzImage ]; then | ||
| 79 | install -m 0644 ${DEPLOY_DIR_IMAGE}/bzImage $dest/vmlinuz | ||
| 80 | fi | ||
| 81 | |||
| 82 | # initrd is made of concatenation of multiple filesystem images | ||
| 83 | if [ -n "${INITRD}" ]; then | ||
| 84 | rm -f $dest/initrd | ||
| 85 | for fs in ${INITRD} | ||
| 86 | do | ||
| 87 | if [ -s "${fs}" ]; then | ||
| 88 | cat ${fs} >> $dest/initrd | ||
| 89 | else | ||
| 90 | bbfatal "${fs} is invalid. initrd image creation failed." | ||
| 91 | fi | ||
| 92 | done | ||
| 93 | chmod 0644 $dest/initrd | ||
| 94 | fi | ||
| 95 | } | ||
| 96 | |||
| 97 | build_boot_dd() { | 50 | build_boot_dd() { |
| 98 | HDDDIR="${S}/hdd/boot" | 51 | HDDDIR="${S}/hdd/boot" |
| 99 | HDDIMG="${S}/hdd.image" | 52 | HDDIMG="${S}/hdd.image" |
| 100 | IMAGE=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect | 53 | IMAGE=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect |
| 101 | 54 | ||
| 102 | boot_direct_populate $HDDDIR | 55 | populate_kernel $HDDDIR |
| 103 | 56 | ||
| 104 | if [ "${PCBIOS}" = "1" ]; then | 57 | if [ "${PCBIOS}" = "1" ]; then |
| 105 | syslinux_hddimg_populate $HDDDIR | 58 | syslinux_hddimg_populate $HDDDIR |
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 894ff993cc..d9c16106c2 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass | |||
| @@ -544,15 +544,3 @@ do_bundle_initramfs () { | |||
| 544 | } | 544 | } |
| 545 | addtask bundle_initramfs after do_image_complete | 545 | addtask bundle_initramfs after do_image_complete |
| 546 | 546 | ||
| 547 | # Some of the vars for vm and live image are conflicted, this function | ||
| 548 | # is used for fixing the problem. | ||
| 549 | def set_live_vm_vars(d, suffix): | ||
| 550 | vars = ['GRUB_CFG', 'SYSLINUX_CFG', 'ROOT', 'LABELS', 'INITRD'] | ||
| 551 | for var in vars: | ||
| 552 | var_with_suffix = var + '_' + suffix | ||
| 553 | if d.getVar(var, True): | ||
| 554 | bb.warn('Found potential conflicted var %s, please use %s rather than %s' % \ | ||
| 555 | (var, var_with_suffix, var)) | ||
| 556 | elif d.getVar(var_with_suffix, True): | ||
| 557 | d.setVar(var, d.getVar(var_with_suffix, True)) | ||
| 558 | |||
diff --git a/meta/classes/live-vm-common.bbclass b/meta/classes/live-vm-common.bbclass new file mode 100644 index 0000000000..c751385e7d --- /dev/null +++ b/meta/classes/live-vm-common.bbclass | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | # Some of the vars for vm and live image are conflicted, this function | ||
| 2 | # is used for fixing the problem. | ||
| 3 | def set_live_vm_vars(d, suffix): | ||
| 4 | vars = ['GRUB_CFG', 'SYSLINUX_CFG', 'ROOT', 'LABELS', 'INITRD'] | ||
| 5 | for var in vars: | ||
| 6 | var_with_suffix = var + '_' + suffix | ||
| 7 | if d.getVar(var, True): | ||
| 8 | bb.warn('Found potential conflicted var %s, please use %s rather than %s' % \ | ||
| 9 | (var, var_with_suffix, var)) | ||
| 10 | elif d.getVar(var_with_suffix, True): | ||
| 11 | d.setVar(var, d.getVar(var_with_suffix, True)) | ||
| 12 | |||
| 13 | |||
| 14 | EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}" | ||
| 15 | EFI_PROVIDER ?= "grub-efi" | ||
| 16 | EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}" | ||
| 17 | |||
| 18 | # Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not | ||
| 19 | # contain "efi". This way legacy is supported by default if neither is | ||
| 20 | # specified, maintaining the original behavior. | ||
| 21 | def pcbios(d): | ||
| 22 | pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d) | ||
| 23 | if pcbios == "0": | ||
| 24 | pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d) | ||
| 25 | return pcbios | ||
| 26 | |||
| 27 | PCBIOS = "${@pcbios(d)}" | ||
| 28 | PCBIOS_CLASS = "${@['','syslinux'][d.getVar('PCBIOS', True) == '1']}" | ||
| 29 | |||
| 30 | inherit ${EFI_CLASS} | ||
| 31 | inherit ${PCBIOS_CLASS} | ||
| 32 | |||
| 33 | KERNEL_IMAGETYPE ??= "bzImage" | ||
| 34 | |||
| 35 | populate_kernel() { | ||
| 36 | dest=$1 | ||
| 37 | install -d $dest | ||
| 38 | |||
| 39 | # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use. | ||
| 40 | if [ -e ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} ]; then | ||
| 41 | install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} $dest/vmlinuz | ||
| 42 | fi | ||
| 43 | |||
| 44 | # initrd is made of concatenation of multiple filesystem images | ||
| 45 | if [ -n "${INITRD}" ]; then | ||
| 46 | rm -f $dest/initrd | ||
| 47 | for fs in ${INITRD} | ||
| 48 | do | ||
| 49 | if [ -s "$fs" ]; then | ||
| 50 | cat $fs >> $dest/initrd | ||
| 51 | else | ||
| 52 | bbfatal "$fs is invalid. initrd image creation failed." | ||
| 53 | fi | ||
| 54 | done | ||
| 55 | chmod 0644 $dest/initrd | ||
| 56 | fi | ||
| 57 | } | ||
| 58 | |||
