tar: Switch to INC_PR and fix native builds.
[openembedded.git] / classes / bootimg.bbclass
blob35b0d76b4e031097a163e09dc27dc380ddc39fa9
1 # bootimg.oeclass
2 # Copyright (C) 2004, Advanced Micro Devices, Inc.  All Rights Reserved
3 # Released under the MIT license (see packages/COPYING)
5 # This creates a bootable image using syslinux, your kernel and an optional
6 # initrd
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 
15 do_bootimg[depends] += "dosfstools-native:do_populate_sysroot \
16                         syslinux-native:do_populate_sysroot \
17                         mtools-native:do_populate_sysroot \
18                         cdrtools-native:do_populate_sysroot"
20 PACKAGES = " "
22 HDDDIR = "${S}/hdd/boot"
23 ISODIR = "${S}/cd/isolinux"
25 BOOTIMG_VOLUME_ID   ?= "oe"
26 BOOTIMG_EXTRA_SPACE ?= "64"
28 # Get the build_syslinux_cfg() function from the syslinux class
30 SYSLINUXCFG  = "${HDDDIR}/syslinux.cfg"
31 SYSLINUXMENU = "${HDDDIR}/menu"
33 inherit syslinux
35 IMAGE_POSTPROCESS_COMMAND ?= ""
36                 
37 build_boot_bin() {
38         install -d ${HDDDIR}
39         install -m 0644 ${STAGING_DIR}/${MACHINE}${HOST_VENDOR}-${HOST_OS}/kernel/bzImage \
40         ${HDDDIR}/vmlinuz
42         if [ -n "${INITRD}" ] && [ -s "${INITRD}" ]; then 
43                 install -m 0644 ${INITRD} ${HDDDIR}/initrd
44         fi
46         install -m 444 ${STAGING_DATADIR_NATIVE}/syslinux/ldlinux.sys \
47         ${HDDDIR}/ldlinux.sys
49         # Do a little math, bash style
50         #BLOCKS=`du -s ${HDDDIR} | cut -f 1`
51         BLOCKS=`du -bks ${HDDDIR} | cut -f 1`
52         SIZE=`expr $BLOCKS + ${BOOTIMG_EXTRA_SPACE}`    
54         install -d ${DEPLOY_DIR_IMAGE}
56         mkdosfs -F 12 -n ${BOOTIMG_VOLUME_ID} -d ${HDDDIR} \
57         -C ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg $SIZE 
59         syslinux ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
60         chmod 644 ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
62         # Create an ISO if we have an INITRD
63         if [ -n "${INITRD}" ] && [ -s "${INITRD}" ] && [ "${NOISO}" != "1" ] ; then
64                 install -d ${ISODIR}
66                 # Install the kernel
68                 install -m 0644 ${STAGING_DIR}/${MACHINE}${HOST_VENDOR}-${HOST_OS}/kernel/bzImage \
69                         ${ISODIR}/vmlinuz
71                 # Install the configuration files
73                 cp ${HDDDIR}/syslinux.cfg ${ISODIR}/isolinux.cfg
75                 if [ -f ${SYSLINUXMENU} ]; then
76                         cp ${SYSLINUXMENU} ${ISODIR}
77                 fi
79                 install -m 0644 ${INITRD} ${ISODIR}/initrd
81                 # And install the syslinux stuff 
82                 cp ${STAGING_DATADIR_NATIVE}/syslinux/isolinux.bin \
83                 ${ISODIR}
85                 ${IMAGE_POSTPROCESS_COMMAND}
87                 mkisofs -V ${BOOTIMG_VOLUME_ID} \
88                 -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.iso \
89                 -b isolinux/isolinux.bin -c isolinux/boot.cat -r \
90                 -no-emul-boot -boot-load-size 4 -boot-info-table \
91                 ${S}/cd/
92         fi
93
95 python do_bootimg() {
96         bb.build.exec_func('build_syslinux_cfg', d)
97         bb.build.exec_func('build_boot_bin', d)
100 # We need to run after bootsplash if it exists, so thats why this line
101 # is such.  Don't worry, if you don't do bootsplash, nobody will notice
103 addtask bootimg before do_build after do_bootsplash