merge of '0413bc22cd84e097b31969ed4179c1b5ff152b99'
[vuplus_openembedded] / classes / bootimg.bbclass
1 # bootimg.oeclass
2 # Copyright (C) 2004, Advanced Micro Devices, Inc.  All Rights Reserved
3 # Released under the MIT license (see packages/COPYING)
4
5 # This creates a bootable image using syslinux, your kernel and an optional
6 # initrd
7
8 # External variables needed
9 # ${INITRD} - indicates a filesystem image to use as an initrd (optional)
10 # ${AUTO_SYSLINUXCFG} - set this to 1 to enable creating an automatic config
11 # ${LABELS} - a list of targets for the automatic config
12 # ${APPEND} - an override list of append strings for each label
13 # ${SYSLINUX_OPTS} - additional options to add to the syslinux file ';' delimited 
14
15 do_bootimg[depends] += "dosfstools-native:do_populate_staging \
16                        syslinux-native:do_populate_staging \
17                        mtools-native:do_populate_staging \
18                        cdrtools-native:do_populate_staging"
19
20 PACKAGES = " "
21
22 HDDDIR = "${S}/hdd/boot"
23 ISODIR = "${S}/cd/isolinux"
24
25 BOOTIMG_VOLUME_ID   ?= "oe"
26 BOOTIMG_EXTRA_SPACE ?= "64"
27
28 # Get the build_syslinux_cfg() function from the syslinux class
29
30 SYSLINUXCFG  = "${HDDDIR}/syslinux.cfg"
31 SYSLINUXMENU = "${HDDDIR}/menu"
32
33 inherit syslinux
34                 
35 build_boot_bin() {
36         install -d ${HDDDIR}
37         install -m 0644 ${STAGING_DIR}/${MACHINE}${HOST_VENDOR}-${HOST_OS}/kernel/bzImage \
38         ${HDDDIR}/vmlinuz
39
40         if [ -n "${INITRD}" ] && [ -s "${INITRD}" ]; then 
41                 install -m 0644 ${INITRD} ${HDDDIR}/initrd
42         fi
43
44         install -m 444 ${STAGING_DATADIR_NATIVE}/syslinux/ldlinux.sys \
45         ${HDDDIR}/ldlinux.sys
46
47         # Do a little math, bash style
48         #BLOCKS=`du -s ${HDDDIR} | cut -f 1`
49         BLOCKS=`du -bks ${HDDDIR} | cut -f 1`
50         SIZE=`expr $BLOCKS + ${BOOTIMG_EXTRA_SPACE}`    
51
52         mkdosfs -F 12 -n ${BOOTIMG_VOLUME_ID} -d ${HDDDIR} \
53         -C ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg $SIZE 
54
55         syslinux ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
56         chmod 644 ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
57
58         #Create an ISO if we have an INITRD
59         if [ -n "${INITRD}" ] && [ -s "${INITRD}" ] && [ "${NOISO}" != "1" ] ; then
60                 install -d ${ISODIR}
61
62                 # Install the kernel
63
64                 install -m 0644 ${STAGING_DIR}/${MACHINE}${HOST_VENDOR}-${HOST_OS}/kernel/bzImage \
65                         ${ISODIR}/vmlinuz
66
67                 # Install the configuration files
68
69                 cp ${HDDDIR}/syslinux.cfg ${ISODIR}/isolinux.cfg
70
71                 if [ -f ${SYSLINUXMENU} ]; then
72                         cp ${SYSLINUXMENU} ${ISODIR}
73                 fi
74
75                 install -m 0644 ${INITRD} ${ISODIR}/initrd
76
77                 # And install the syslinux stuff 
78                 cp ${STAGING_DATADIR_NATIVE}/syslinux/isolinux.bin \
79                 ${ISODIR}
80
81                 mkisofs -V ${BOOTIMG_VOLUME_ID} \
82                 -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.iso \
83                 -b isolinux/isolinux.bin -c isolinux/boot.cat -r \
84                 -no-emul-boot -boot-load-size 4 -boot-info-table \
85                 ${S}/cd/
86         fi
87
88
89 python do_bootimg() {
90         bb.build.exec_func('build_syslinux_cfg', d)
91         bb.build.exec_func('build_boot_bin', d)
92 }
93
94 # We need to run after bootsplash if it exists, so thats why this line
95 # is such.  Don't worry, if you don't do bootsplash, nobody will notice
96
97 addtask bootimg before do_build after do_bootsplash