image_types_nfi: rename to ubi-nfi, don't modify files in IMAGE_ROOTFS
[opendreambox.git] / meta-dreambox / classes / image_types_nfi.bbclass
1 inherit image_types
2
3 UBINFI_BOOT = "${WORKDIR}/ubi-nfi/boot"
4 UBINFI_ROOT = "${WORKDIR}/ubi-nfi/rootfs"
5
6 IMAGE_CMD_ubi-nfi = " \
7         rm -rf ${WORKDIR}/ubi-nfi; \
8         mkdir -p ${UBINFI_ROOT}; \
9         tar --xattrs --xattrs-include='*' -cf - -C ${IMAGE_ROOTFS} --exclude=./boot/* -p . | tar --xattrs --xattrs-include='*' -xf - -C ${UBINFI_ROOT}; \
10         mkdir -p ${UBINFI_BOOT}; \
11         tar --xattrs --xattrs-include='*' -cf - -C ${IMAGE_ROOTFS}/boot -p . | tar --xattrs --xattrs-include='*' -xf - -C ${UBINFI_BOOT}; \
12         mkfs.jffs2 \
13                 --root=${UBINFI_BOOT} \
14                 --disable-compressor=lzo \
15                 --compression-mode=size \
16                 --output=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.boot.jffs2 \
17                 ${EXTRA_IMAGECMD}; \
18         printf '/dev/mtdblock2\t/boot\t\tjffs2\tro\t\t\t\t0 0\n' >> ${UBINFI_ROOT}/etc/fstab; \
19         echo \[root\] > ubinize.cfg; \
20         echo mode=ubi >> ubinize.cfg; \
21         echo image=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs >> ubinize.cfg; \
22         echo vol_id=0 >> ubinize.cfg; \
23         echo vol_name=${UBI_VOLNAME} >> ubinize.cfg; \
24         echo vol_type=dynamic >> ubinize.cfg; \
25         if [ ${UBINIZE_VOLSIZE} = "0" ]; then \
26                 echo vol_flags=autoresize >> ubinize.cfg; \
27         else \
28                 echo vol_size=${UBINIZE_VOLSIZE} >> ubinize.cfg; \
29                 if [ ${UBINIZE_DATAVOLSIZE} != "0" ]; then \
30                         echo \[data\] >> ubinize.cfg; \
31                         echo mode=ubi >> ubinize.cfg; \
32                         echo vol_id=1 >> ubinize.cfg; \
33                         echo vol_type=dynamic >> ubinize.cfg; \
34                         echo vol_name=data >> ubinize.cfg; \
35                         echo vol_size=${UBINIZE_DATAVOLSIZE} >> ubinize.cfg; \
36                         echo vol_flags=autoresize >> ubinize.cfg; \
37                         printf '/dev/ubi0_1\t/data\t\tubifs\trw,nofail\t\t\t\t0 0\n' >> ${UBINFI_ROOT}/etc/fstab; \
38                         install -d ${UBINFI_ROOT}/data; \
39                 fi; \
40         fi; \
41         mkfs.ubifs \
42                 -r ${UBINFI_ROOT} \
43                 -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs \
44                 ${MKUBIFS_ARGS}; \
45         ubinize -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubi ${UBINIZE_ARGS} ubinize.cfg; \
46         ${DREAMBOX_BUILDIMAGE} \
47                 --boot-partition ${DREAMBOX_PART0_SIZE}:${STAGING_DATADIR}/dreambox-secondstage/secondstage.bin \
48                 --data-partition ${DREAMBOX_PART1_SIZE}:${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.boot.jffs2 \
49                 --data-partition ${DREAMBOX_PART2_SIZE}:${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubi \
50                 > ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.nfi; \
51 "
52
53 EXTRA_IMAGECMD_ubi-nfi ?= "-e ${DREAMBOX_ERASE_BLOCK_SIZE} -n -l"
54
55 IMAGE_DEPENDS_ubi-nfi = "${IMAGE_DEPENDS_ubi} ${IMAGE_DEPENDS_ubifs} dreambox-buildimage-native"
56
57 IMAGE_TYPES += "ubi-nfi"
58
59 runimagecmd_append() {
60     if [ -n "${IMAGE_LINK_NAME}" ]; then
61         if [ -e ${IMAGE_NAME}.nfi ]; then
62             ln -s ${IMAGE_NAME}.nfi ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.nfi
63         fi
64     fi
65 }