summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2016-03-30 00:23:11 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-31 23:01:37 +0100
commit4d1df2cfe84fe4ad061cee01cddea4e7ae627fe4 (patch)
treecc38dc059d7d54425d10127316e5d961f5d26c92
parentd6d75260fa0a9874a62acd3251b7405ed59f0cfa (diff)
downloadpoky-4d1df2cfe84fe4ad061cee01cddea4e7ae627fe4.tar.gz
image-live.bbclass/image-vm.bbclass: remove duplicated code
Move the common code to live_vm_common.bbclass and remove duplicated ones. (From OE-Core rev: 4a70cc59a0350f06d4cc48c12c3053a39191ba07) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/image-live.bbclass60
-rw-r--r--meta/classes/image-vm.bbclass53
-rw-r--r--meta/classes/image.bbclass12
-rw-r--r--meta/classes/live-vm-common.bbclass58
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
28inherit live-vm-common
29
28do_bootimg[depends] += "dosfstools-native:do_populate_sysroot \ 30do_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"
71BOOTIMG_VOLUME_ID ?= "boot" 73BOOTIMG_VOLUME_ID ?= "boot"
72BOOTIMG_EXTRA_SPACE ?= "512" 74BOOTIMG_EXTRA_SPACE ?= "512"
73 75
74EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}" 76populate_live() {
75EFI_PROVIDER ?= "grub-efi" 77 populate_kernel $1
76EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}" 78 if [ -s "${ROOTFS}" ]; then
77 79 install -m 0644 ${ROOTFS} $1/rootfs.img
78KERNEL_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.
83def 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
89PCBIOS = "${@pcbios(d)}"
90PCBIOS_CLASS = "${@['','syslinux'][d.getVar('PCBIOS', True) == '1']}"
91
92inherit ${EFI_CLASS}
93inherit ${PCBIOS_CLASS}
94
95populate() {
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
122build_iso() { 83build_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() {
275build_hddimg() { 235build_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
18inherit live-vm-common
19
18do_bootdirectdisk[depends] += "dosfstools-native:do_populate_sysroot \ 20do_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
43BOOTDD_VOLUME_ID ?= "boot" 45BOOTDD_VOLUME_ID ?= "boot"
44BOOTDD_EXTRA_SPACE ?= "16384" 46BOOTDD_EXTRA_SPACE ?= "16384"
45 47
46EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
47EFI_PROVIDER ?= "grub-efi"
48EFI_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.
53def 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
59def pcbios_class(d):
60 if d.getVar("PCBIOS", True) == "1":
61 return "syslinux"
62 return ""
63
64PCBIOS = "${@pcbios(d)}"
65PCBIOS_CLASS = "${@pcbios_class(d)}"
66
67# Get the build_syslinux_cfg() function from the syslinux class
68inherit ${PCBIOS_CLASS}
69inherit ${EFI_CLASS}
70
71DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}" 48DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}"
72 49
73boot_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
97build_boot_dd() { 50build_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}
545addtask bundle_initramfs after do_image_complete 545addtask 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.
549def 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.
3def 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
14EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
15EFI_PROVIDER ?= "grub-efi"
16EFI_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.
21def 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
27PCBIOS = "${@pcbios(d)}"
28PCBIOS_CLASS = "${@['','syslinux'][d.getVar('PCBIOS', True) == '1']}"
29
30inherit ${EFI_CLASS}
31inherit ${PCBIOS_CLASS}
32
33KERNEL_IMAGETYPE ??= "bzImage"
34
35populate_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