blob: 74c7ba34fa176d392d5619ec819b9a559b6fbaf4 [file] [log] [blame]
developer15a43312022-04-12 11:23:23 +08001inherit rdk-image
2
3IMAGE_FEATURES_remove = "read-only-rootfs"
developerfeea77e2022-07-11 18:10:33 +08004IMAGE_FSTYPES_remove= "tar.gz"
developer15a43312022-04-12 11:23:23 +08005SYSTEMD_TOOLS = "systemd-analyze systemd-bootchart"
6# systemd-bootchart doesn't currently build with musl libc
7SYSTEMD_TOOLS_remove_libc-musl = "systemd-bootchart"
8
developer87776312022-12-02 10:29:28 +08009DEPENDS += "cryptsetup-native"
10
developerc27ead32023-01-03 16:32:58 +080011IMAGE_INSTALL += " \
developer15a43312022-04-12 11:23:23 +080012 ${SYSTEMD_TOOLS} \
developerb76f9f32022-10-31 14:09:44 +080013 ethtool \
14 ebtables \
15 regs \
16 mii-mgr \
17 mtd \
18 smp \
19 mtk-factory-rw \
20 ${@bb.utils.contains('DISTRO_FEATURES','switch_gsw_mode','switch','',d)} \
21 mtd-utils-ubifs \
22 u-boot-fw-utils \
23 fw-upgrade \
24 init-filogic \
25 mac-sec \
26 mtkhnat-util \
developer15a43312022-04-12 11:23:23 +080027 network-hotplug \
28 libmcrypt \
developer3d785cd2022-05-05 16:20:47 +080029 coreutils \
30 util-linux-readprofile \
31 iputils \
developer783a8a62024-01-17 12:34:31 +080032 bc \
33 ${@bb.utils.contains('DISTRO_FEATURES','kirkstone','','python-core',d)} \
developer3d785cd2022-05-05 16:20:47 +080034 dosfstools \
35 pptp-linux \
36 rp-pppoe \
developer08970cc2022-07-26 15:13:11 +080037 xl2tpd \
developera66c2012022-11-01 19:16:16 +080038 strongswan \
39 libpcap \
developer761278a2022-11-01 19:27:22 +080040 tcpdump \
41 perf \
developerc27ead32023-01-03 16:32:58 +080042 ${@bb.utils.contains('DISTRO_FEATURES','mt76','packagegroup-filogic-mt76','',d)} \
43 ${@bb.utils.contains('DISTRO_FEATURES','logan','packagegroup-filogic-logan','',d)} \
44 ${@bb.utils.contains('DISTRO_FEATURES','mtk_easymesh','packagegroup-filogic-mtk-easymesh','',d)} \
developercbfd34a2023-01-17 17:08:24 +080045 ${@bb.utils.contains('DISTRO_FEATURES','emmc','e2fsprogs f2fs-tools','',d)} \
developere8f1a742023-02-10 15:00:10 +080046 util-linux-blkid \
developer86930132023-02-13 17:52:00 +080047 util-linux-blockdev \
developer053257b2023-02-15 13:18:40 +080048 ${@bb.utils.contains('DISTRO_FEATURES','secure_boot','dmsetup','',d)} \
49 ${@bb.utils.contains('DISTRO_FEATURES','efuse_tools','mtk-efuse-nl-drv mtk-efuse-nl-tool','',d)} \
developerf1063ab2023-03-09 11:02:02 +080050 ${@bb.utils.contains('DISTRO_FEATURES','flow_offload','flowtable','',d)} \
51 ${@bb.utils.contains('DISTRO_FEATURES','samba','ksmbd ksmbd-tools','',d)} \
developer15a43312022-04-12 11:23:23 +080052 "
developer2bf53a92022-06-06 12:08:58 +080053#IMAGE_INSTALL += " opensync openvswitch mesh-agent e2fsprogs "
developer15a43312022-04-12 11:23:23 +080054
developer8118c822023-10-17 18:03:39 +080055IMAGE_INSTALL_append_mt7988 += " marvell-eth-firmware mediatek-eth-firmware "
developerec941592022-11-18 14:34:39 +080056
developer87776312022-12-02 10:29:28 +080057
developer15a43312022-04-12 11:23:23 +080058BB_HASH_IGNORE_MISMATCH = "1"
59IMAGE_NAME[vardepsexclude] = "DATETIME"
60
61#ESDK-CHANGES
62do_populate_sdk_ext_prepend() {
63 builddir = d.getVar('TOPDIR')
64 if os.path.exists(builddir + '/conf/templateconf.cfg'):
65 with open(builddir + '/conf/templateconf.cfg', 'w') as f:
66 f.write('meta/conf\n')
67}
68
69sdk_ext_postinst_append() {
70 echo "ln -s $target_sdk_dir/layers/openembedded-core/meta-rdk $target_sdk_dir/layers/openembedded-core/../meta-rdk \n" >> $env_setup_script
71}
72
73PRSERV_HOST = "localhost:0"
74INHERIT += "buildhistory"
75BUILDHISTORY_COMMIT = "1"
76
77
78
79require image-exclude-files.inc
80
81remove_unused_file() {
82 for i in ${REMOVED_FILE_LIST} ; do rm -rf ${IMAGE_ROOTFS}/$i ; done
83}
84
85ROOTFS_POSTPROCESS_COMMAND_append = "remove_unused_file; "
developer23de0032022-06-01 19:34:29 +080086
87do_filogic_gen_image(){
88 if ${@bb.utils.contains('DISTRO_FEATURES','kernel_in_ubi','true','false',d)}; then
developer23de0032022-06-01 19:34:29 +080089 # create sysupgrade image align to openwrt
90
91 rm -rf ${IMGDEPLOYDIR}/sysupgrade-${PN}-${MACHINE}
92 rm -rf ${IMGDEPLOYDIR}/${PN}-${MACHINE}-sysupgrade.bin
93
94 mkdir ${IMGDEPLOYDIR}/sysupgrade-${PN}-${MACHINE}
95
96 cp ${DEPLOY_DIR_IMAGE}/fitImage ${IMGDEPLOYDIR}/sysupgrade-${PN}-${MACHINE}/kernel
97 cp ${IMGDEPLOYDIR}/${PN}-${MACHINE}.squashfs-xz ${IMGDEPLOYDIR}/sysupgrade-${PN}-${MACHINE}/root
98
99 cd ${IMGDEPLOYDIR}
100 tar cvf ${PN}-${MACHINE}-sysupgrade.bin sysupgrade-${PN}-${MACHINE}
101 mv ${PN}-${MACHINE}-sysupgrade.bin ${DEPLOY_DIR_IMAGE}/
developer87776312022-12-02 10:29:28 +0800102
103 if ${@bb.utils.contains('DISTRO_FEATURES','secure_boot','true','false',d)}; then
developer23de0032022-06-01 19:34:29 +0800104
developer87776312022-12-02 10:29:28 +0800105 rm -rf ${IMGDEPLOYDIR}/sysupgrade-${PN}-${MACHINE}-sb
106 rm -rf ${IMGDEPLOYDIR}/${PN}-${MACHINE}-sb-sysupgrade.bin
developer23de0032022-06-01 19:34:29 +0800107
developer87776312022-12-02 10:29:28 +0800108 mkdir ${IMGDEPLOYDIR}/sysupgrade-${PN}-${MACHINE}-sb
developer23de0032022-06-01 19:34:29 +0800109
developer87776312022-12-02 10:29:28 +0800110 cp ${DEPLOY_DIR_IMAGE}/fitImage-sb ${IMGDEPLOYDIR}/sysupgrade-${PN}-${MACHINE}-sb/kernel
111 cp ${IMGDEPLOYDIR}/${PN}-${MACHINE}.squashfs-xz ${IMGDEPLOYDIR}/sysupgrade-${PN}-${MACHINE}-sb/root
developer23de0032022-06-01 19:34:29 +0800112
developer87776312022-12-02 10:29:28 +0800113 cd ${IMGDEPLOYDIR}
114 tar cvf ${PN}-${MACHINE}-sb-sysupgrade.bin sysupgrade-${PN}-${MACHINE}-sb
115 mv ${PN}-${MACHINE}-sb-sysupgrade.bin ${DEPLOY_DIR_IMAGE}/
116 fi
developer23de0032022-06-01 19:34:29 +0800117 fi
118
119}
120addtask filogic_gen_image after do_image_complete before do_populate_lic_deploy
developer87776312022-12-02 10:29:28 +0800121
122python do_hash_rootfs (){
123 deploy_path = d.getVar('IMGDEPLOYDIR', d, 1)
124 PN = d.getVar('PN', d, 1)
125 MACHINE = d.getVar('MACHINE', d, 1)
126 SQUASHFS_FILE_PATH="%s/%s-%s.squashfs-xz" %(deploy_path, PN, MACHINE)
127 DEPLOY_DIR_IMAGE = d.getVar('DEPLOY_DIR_IMAGE', d, 1)
128 SUMMARY_FILE="%s/hash-summary" %(DEPLOY_DIR_IMAGE)
129 FILE_SIZE = os.path.getsize(SQUASHFS_FILE_PATH)
130 BLOCK_SIZE= int(d.getVar('NAND_PAGE_SIZE', d, 1))
131 DATA_BLOCKS= FILE_SIZE / BLOCK_SIZE
132
133 if ((FILE_SIZE % BLOCK_SIZE) != 0):
134 DATA_BLOCKS = DATA_BLOCKS+1
135
136 HASH_OFFSET=DATA_BLOCKS * BLOCK_SIZE
137
138 import subprocess
139 subprocess.Popen("veritysetup format --data-blocks=%d --hash-offset=%d %s %s > %s" %(DATA_BLOCKS, HASH_OFFSET, SQUASHFS_FILE_PATH, SQUASHFS_FILE_PATH, SUMMARY_FILE), shell=True)
140}
141
142addtask hash_rootfs after do_image_complete before do_filogic_gen_image
143
144python __anonymous () {
145 d.appendVarFlag('do_filogic_gen_image', 'depends', ' linux-mediatek:do_deploy')
146}