[Add meta-cmf-filogic sdk cmf for rdkb development]

[Description]
Add meta-cmf-filogic sdk cmf for rdkb development
1. rdkb base on dunfell rdkb-next (> 2022q1)
2. cmf is mostly from meta-turris implementation
3. some 64bit support are port from rp4-64 cmf
4. arm64/arm 32bit bsp both can run on rdkb

[Release-log]
N/A

diff --git a/recipes-ccsp/ccsp/ccsp-common-library.bbappend b/recipes-ccsp/ccsp/ccsp-common-library.bbappend
new file mode 100644
index 0000000..a937b22
--- /dev/null
+++ b/recipes-ccsp/ccsp/ccsp-common-library.bbappend
@@ -0,0 +1,186 @@
+require ccsp_common_turris.inc
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:${THISDIR}/files:"
+
+DEPENDS_append_turris = " breakpad"
+CXXFLAGS_append_turris = " \
+                                -I${STAGING_INCDIR}/breakpad \
+                                -std=c++11 \
+                              "
+
+SRC_URI_append = " \
+    file://ccsp_vendor.h \
+    file://wifiinitialized.service \
+    file://checkturriswifisupport.service \
+    file://wifiinitialized.path \
+    file://turriswifiinitialized.path \
+    file://checkturriswifisupport.path \
+    file://wifi-initialized.target \
+    file://utopia.service \
+"
+
+SRC_URI_remove_dunfell = "file://0001-DBusLoop-SSL_state-TLS_ST_OK.patch"
+SRC_URI_remove_dunfell = "file://0001-SSLeay_add_all_algorithms-remove-in-openssl-1.1.patch"
+
+SRC_URI += "file://0003-add-dependency-to-pandm.patch;apply=no"
+SRC_URI += "file://0004-remove-psm-db-reference.patch;apply=no"
+SRC_URI_append_dunfell = " file://0001-DBusLoop-SSL_state-TLS_ST_OK.patch;apply=no"
+SRC_URI_append_dunfell = " file://0001-SSLeay_add_all_algorithms-remove-in-openssl-1.1.patch;apply=no"
+
+
+# we need to patch to code for Turris
+do_turris_patches() {
+    cd ${S}
+    if [ ! -e patch_applied ]; then
+        patch -p1 < ${WORKDIR}/0003-add-dependency-to-pandm.patch
+        patch -p1 < ${WORKDIR}/0004-remove-psm-db-reference.patch
+		 if [ "${@bb.utils.contains('DISTRO_CODENAME', 'dunfell', 'dunfell', '', d)}" = "dunfell" ] ; then
+			      patch -p1 < ${WORKDIR}/0001-DBusLoop-SSL_state-TLS_ST_OK.patch
+                              patch -p1 < ${WORKDIR}/0001-SSLeay_add_all_algorithms-remove-in-openssl-1.1.patch
+                 fi
+       touch patch_applied
+    fi
+}
+addtask turris_patches after do_unpack before do_compile
+
+do_install_append_class-target(){
+    # Config files and scripts
+    install -m 777 ${S}/scripts/cli_start_arm.sh ${D}/usr/ccsp/cli_start.sh
+    install -m 777 ${S}/scripts/cosa_start_arm.sh ${D}/usr/ccsp/cosa_start.sh
+
+    # we need unix socket path
+    echo "unix:path=/var/run/dbus/system_bus_socket" > ${S}/config/ccsp_msg.cfg
+    install -m 644 ${S}/config/ccsp_msg.cfg ${D}/usr/ccsp/ccsp_msg.cfg
+    install -m 644 ${S}/config/ccsp_msg.cfg ${D}/usr/ccsp/cm/ccsp_msg.cfg
+    install -m 644 ${S}/config/ccsp_msg.cfg ${D}/usr/ccsp/mta/ccsp_msg.cfg
+    install -m 644 ${S}/config/ccsp_msg.cfg ${D}/usr/ccsp/pam/ccsp_msg.cfg
+    install -m 644 ${S}/config/ccsp_msg.cfg ${D}/usr/ccsp/tr069pa/ccsp_msg.cfg
+
+    install -m 777 ${S}/systemd_units/scripts/ccspSysConfigEarly.sh ${D}/usr/ccsp/ccspSysConfigEarly.sh
+    install -m 777 ${S}/systemd_units/scripts/ccspSysConfigLate.sh ${D}/usr/ccsp/ccspSysConfigLate.sh
+    install -m 777 ${S}/systemd_units/scripts/utopiaInitCheck.sh ${D}/usr/ccsp/utopiaInitCheck.sh
+    install -m 777 ${S}/systemd_units/scripts/ccspPAMCPCheck.sh ${D}/usr/ccsp/ccspPAMCPCheck.sh
+
+    install -m 777 ${S}/systemd_units/scripts/ProcessResetCheck.sh ${D}/usr/ccsp/ProcessResetCheck.sh
+    sed -i -e "s/source \/rdklogger\/logfiles.sh;syncLogs_nvram2/#source \/rdklogger\/logfiles.sh;syncLogs_nvram2/g" ${D}/usr/ccsp/ProcessResetCheck.sh
+    # install systemd services
+    install -d ${D}${systemd_unitdir}/system
+    install -D -m 0644 ${S}/systemd_units/ccspwifiagent.service ${D}${systemd_unitdir}/system/ccspwifiagent.service
+    install -D -m 0644 ${S}/systemd_units/CcspCrSsp.service ${D}${systemd_unitdir}/system/CcspCrSsp.service
+    install -D -m 0644 ${S}/systemd_units/CcspPandMSsp.service ${D}${systemd_unitdir}/system/CcspPandMSsp.service
+    install -D -m 0644 ${S}/systemd_units/PsmSsp.service ${D}${systemd_unitdir}/system/PsmSsp.service
+    install -D -m 0644 ${S}/systemd_units/rdkbLogMonitor.service ${D}${systemd_unitdir}/system/rdkbLogMonitor.service
+    install -D -m 0644 ${S}/systemd_units/CcspTandDSsp.service ${D}${systemd_unitdir}/system/CcspTandDSsp.service
+    install -D -m 0644 ${S}/systemd_units/CcspLMLite.service ${D}${systemd_unitdir}/system/CcspLMLite.service
+    install -D -m 0644 ${S}/systemd_units/CcspTr069PaSsp.service ${D}${systemd_unitdir}/system/CcspTr069PaSsp.service
+    install -D -m 0644 ${S}/systemd_units/snmpSubAgent.service ${D}${systemd_unitdir}/system/snmpSubAgent.service
+    install -D -m 0644 ${S}/systemd_units/snmpSubAgent.service ${D}${systemd_unitdir}/system/snmpSubAgent.service
+    install -D -m 0644 ${S}/systemd_units/CcspEthAgent.service ${D}${systemd_unitdir}/system/CcspEthAgent.service
+
+    #rfc service file
+    install -D -m 0644 ${S}/systemd_units/rfc.service ${D}${systemd_unitdir}/system/rfc.service
+
+    install -D -m 0644 ${WORKDIR}/wifiinitialized.service ${D}${systemd_unitdir}/system/wifiinitialized.service
+    install -D -m 0644 ${WORKDIR}/checkturriswifisupport.service ${D}${systemd_unitdir}/system/checkturriswifisupport.service
+
+    install -D -m 0644 ${WORKDIR}/wifiinitialized.path ${D}${systemd_unitdir}/system/wifiinitialized.path
+    install -D -m 0644 ${WORKDIR}/turriswifiinitialized.path ${D}${systemd_unitdir}/system/turriswifiinitialized.path
+    install -D -m 0644 ${WORKDIR}/checkturriswifisupport.path ${D}${systemd_unitdir}/system/checkturriswifisupport.path
+
+    install -D -m 0644 ${WORKDIR}/wifi-initialized.target ${D}${systemd_unitdir}/system/wifi-initialized.target
+
+    install -D -m 0644 ${S}/systemd_units/ProcessResetDetect.service ${D}${systemd_unitdir}/system/ProcessResetDetect.service
+    install -D -m 0644 ${S}/systemd_units/ProcessResetDetect.path ${D}${systemd_unitdir}/system/ProcessResetDetect.path
+
+    # Install wrapper for breakpad (disabled to support External Source build)
+    #install -d ${D}${includedir}/ccsp
+    #install -m 644 ${S}/source/breakpad_wrapper/include/breakpad_wrapper.h ${D}${includedir}/ccsp
+
+    # Install "vendor information"
+    install -m 0644 ${WORKDIR}/ccsp_vendor.h ${D}${includedir}/ccsp
+
+    sed -i -- 's/NotifyAccess=.*/#NotifyAccess=main/g' ${D}${systemd_unitdir}/system/CcspCrSsp.service
+    sed -i -- 's/notify.*/forking/g' ${D}${systemd_unitdir}/system/CcspCrSsp.service
+   
+    #copy rfc.properties into nvram
+    sed -i '/ExecStartPre/ a\ExecStartPre=-/bin/cp /etc/rfc.properties /nvram/' ${D}${systemd_unitdir}/system/rfc.service
+    #reduce sleep time to 12 sconds
+    sed -i 's/300/12/g' ${D}${systemd_unitdir}/system/rfc.service
+   
+    #change for turris omnia
+    sed -i 's/PIDFile/#&/' ${D}${systemd_unitdir}/system/CcspPandMSsp.service 
+
+    #WanManager - RdkWanManager.service
+     DISTRO_WAN_ENABLED="${@bb.utils.contains('DISTRO_FEATURES','rdkb_wan_manager','true','false',d)}"
+     if [ $DISTRO_WAN_ENABLED = 'true' ]; then
+     install -D -m 0644 ${S}/systemd_units/RdkWanManager.service ${D}${systemd_unitdir}/system/RdkWanManager.service
+     sed -i "/WorkingDirectory/a ExecStartPre=/bin/sh /lib/rdk/run_rm_key.sh" ${D}${systemd_unitdir}/system/RdkWanManager.service
+     sed -i "s/After=CcspCrSsp.service/After=CcspCrSsp.service utopia.service/g" ${D}${systemd_unitdir}/system/RdkWanManager.service
+     sed -i "s/CcspPandMSsp.service/CcspCrSsp.service CcspPandMSsp.service/g" ${D}${systemd_unitdir}/system/CcspEthAgent.service
+     install -D -m 0644 ${WORKDIR}/utopia.service ${D}${systemd_unitdir}/system/utopia.service
+     install -D -m 0644 ${S}/systemd_units/RdkTelcoVoiceManager.service ${D}${systemd_unitdir}/system/RdkTelcoVoiceManager.service
+     install -D -m 0644 ${S}/systemd_units/RdkVlanManager.service ${D}${systemd_unitdir}/system/RdkVlanManager.service
+    fi
+
+    ##### erouter0 ip issue
+    sed -i '/Factory/a \
+IsErouterRunningStatus=\`ifconfig erouter0 | grep RUNNING | grep -v grep | wc -l\` \
+if [ \"\$IsErouterRunningStatus\" == 0 ]; then \
+ethtool -s erouter0 speed 1000 \
+fi' ${D}/usr/ccsp/ccspPAMCPCheck.sh
+
+}
+
+do_install_append_dunfell_class-target () {
+    #for yocto 3.1, Making psm to run after gwprovethwan
+    sed -i '/CcspCrSsp.service/c After=CcspCrSsp.service gwprovethwan.service' ${D}${systemd_unitdir}/system/PsmSsp.service
+}
+
+SYSTEMD_SERVICE_${PN} += "ccspwifiagent.service"
+SYSTEMD_SERVICE_${PN} += "CcspCrSsp.service"
+SYSTEMD_SERVICE_${PN} += "CcspPandMSsp.service"
+SYSTEMD_SERVICE_${PN} += "PsmSsp.service"
+SYSTEMD_SERVICE_${PN} += "rdkbLogMonitor.service"
+SYSTEMD_SERVICE_${PN} += "CcspTandDSsp.service"
+SYSTEMD_SERVICE_${PN} += "CcspLMLite.service"
+SYSTEMD_SERVICE_${PN} += "CcspTr069PaSsp.service"
+SYSTEMD_SERVICE_${PN} += "snmpSubAgent.service"
+SYSTEMD_SERVICE_${PN} += "CcspEthAgent.service"
+SYSTEMD_SERVICE_${PN} += "wifiinitialized.service"
+SYSTEMD_SERVICE_${PN} += "checkturriswifisupport.service"
+SYSTEMD_SERVICE_${PN} += "wifiinitialized.path"
+SYSTEMD_SERVICE_${PN} += "turriswifiinitialized.path"
+SYSTEMD_SERVICE_${PN} += "checkturriswifisupport.path"
+SYSTEMD_SERVICE_${PN} += "wifi-initialized.target"
+SYSTEMD_SERVICE_${PN} += "ProcessResetDetect.path"
+SYSTEMD_SERVICE_${PN} += "ProcessResetDetect.service"
+SYSTEMD_SERVICE_${PN} += "rfc.service"
+SYSTEMD_SERVICE_${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'rdkb_wan_manager', 'RdkWanManager.service utopia.service ', '', d)}"
+
+FILES_${PN}_append = " \
+    /usr/ccsp/ccspSysConfigEarly.sh \
+    /usr/ccsp/ccspSysConfigLate.sh \
+    /usr/ccsp/utopiaInitCheck.sh \
+    /usr/ccsp/ccspPAMCPCheck.sh \
+    /usr/ccsp/ProcessResetCheck.sh \
+    ${systemd_unitdir}/system/ccspwifiagent.service \
+    ${systemd_unitdir}/system/CcspCrSsp.service \
+    ${systemd_unitdir}/system/CcspPandMSsp.service \
+    ${systemd_unitdir}/system/PsmSsp.service \
+    ${systemd_unitdir}/system/rdkbLogMonitor.service \
+    ${systemd_unitdir}/system/CcspTandDSsp.service \
+    ${systemd_unitdir}/system/CcspLMLite.service \
+    ${systemd_unitdir}/system/CcspTr069PaSsp.service \
+    ${systemd_unitdir}/system/snmpSubAgent.service \
+    ${systemd_unitdir}/system/CcspEthAgent.service \
+    ${systemd_unitdir}/system/wifiinitialized.service \
+    ${systemd_unitdir}/system/checkturriswifisupport.service \
+    ${systemd_unitdir}/system/wifiinitialized.path \
+    ${systemd_unitdir}/system/turriswifiinitialized.path \
+    ${systemd_unitdir}/system/checkturriswifisupport.path \
+    ${systemd_unitdir}/system/wifi-initialized.target \
+    ${systemd_unitdir}/system/ProcessResetDetect.path \
+    ${systemd_unitdir}/system/ProcessResetDetect.service \
+    ${systemd_unitdir}/system/rfc.service \
+"
+FILES_${PN}_append = "${@bb.utils.contains('DISTRO_FEATURES', 'rdkb_wan_manager', ' ${systemd_unitdir}/system/RdkWanManager.service ${systemd_unitdir}/system/utopia.service ${systemd_unitdir}/system/RdkVlanManager.service ${systemd_unitdir}/system/RdkTelcoVoiceManager.service ', '', d)}"