[[RDKB]Support eagle mp3, kite mp1, eagle mp4, kite mp2 in RDKB]

[Description]
Add script for preparing hostapd/wpa-supplicant patch.

[Release-log]

Change-Id: I16d1d60855cf5d5af23182e1a1bbb98dcfdaae80
diff --git a/mtk_scripts/sync_hostapd_patch.sh b/mtk_scripts/sync_hostapd_patch.sh
new file mode 100755
index 0000000..fa5a4ec
--- /dev/null
+++ b/mtk_scripts/sync_hostapd_patch.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+# prepare hostapd patch
+hostapd=0
+wpa_supplicant=0
+
+for arg in $*; do
+	case "$arg" in
+	"hostapd")
+		hostapd=1
+		;;
+	"wpa_supplicant")
+		wpa_supplicant=1
+		;;
+	*)
+	esac
+done
+
+[ "$hostapd" = "1" ] && {
+	SRC_DIR="../src/wifi/wlan_daemon/hostapd"
+	MAKE_DIR="../meta-filogic-logan/recipes-wifi/hostapd/files"
+
+	echo "prepare hostapd patch"
+	mkdir ${MAKE_DIR}/patches
+	cp -rf ${SRC_DIR}/mt7988/mt7990/files/package/network/services/hostapd/patches/ ${MAKE_DIR}/
+	cp -rf ${SRC_DIR}/mt7988/mt7990/files/package/network/services/hostapd/src/ ${MAKE_DIR}/
+	cp -rf ${SRC_DIR}/mt7988/mt7990/files/package/network/services/hostapd/files/hostapd-full.config ${MAKE_DIR}/
+	cp -rf ../meta-cmf-filogic/mtk_scripts/rdkb_inc_helper ${MAKE_DIR}/
+	ver=`grep "PKG_SOURCE_VERSION" ${SRC_DIR}/mt7988/mt7990/files/package/network/services/hostapd/Makefile | cut -c 21-`
+	sed -i 's/SRCREV ?=.*/SRCREV ?= "'$ver'"/g' ../meta-filogic-logan/recipes-wifi/hostapd/hostapd_2.10.bb
+	cd ${MAKE_DIR}
+	./rdkb_inc_helper patches
+	mv patches.inc patches/
+	rm rdkb_inc_helper
+	sed -i 's/#include "wpa_supplicant_i.h"/#include "..\/..\/wpa_supplicant\/wpa_supplicant_i.h"/g' patches/mtk-hostapd-12map-000-mtk-map.patch
+	cd -
+}
+
+[ "$wpa_supplicant" = "1" ] && {
+	SRC_DIR="../src/wifi/wlan_daemon/hostapd"
+	MAKE_DIR="../meta-filogic-logan/recipes-wifi/wpa-supplicant/files"
+
+	echo "prepare wpa_supplicant patch"
+	mkdir ${MAKE_DIR}/patches
+	cp -rf ${SRC_DIR}/mt7988/mt7990/files/package/network/services/hostapd/patches/ ${MAKE_DIR}/
+	cp -rf ${SRC_DIR}/mt7988/mt7990/files/package/network/services/hostapd/src/ ${MAKE_DIR}/
+	cp -rf ${SRC_DIR}/mt7988/mt7990/files/package/network/services/hostapd/files/wpa_supplicant-full.config ${MAKE_DIR}/
+	cp -rf ../meta-cmf-filogic/mtk_scripts/rdkb_inc_helper ${MAKE_DIR}/
+	ver=`grep "PKG_SOURCE_VERSION" ${SRC_DIR}/mt7988/mt7990/files/package/network/services/hostapd/Makefile | cut -c 21-`
+	sed -i 's/SRCREV ?=.*/SRCREV ?= "'$ver'"/g' ../meta-filogic-logan/recipes-wifi/wpa-supplicant/wpa-supplicant_2.10.bb
+	cd ${MAKE_DIR}
+	./rdkb_inc_helper patches
+	mv patches.inc patches/
+	rm rdkb_inc_helper
+	sed -i '/+OBJS += ..\/src\/ml\/ml_supplicant.o/ a +CFLAGS += -DHOSTAPD_PMKID_IN_DRIVER_SUPPORT\n+CFLAGS += -DCONFIG_MTK_PASSPOINT' patches/mtk-hostapd-0311be-000-mtk-mlo.patch
+	sed -i 's/@@ -377,6 +377,14 @@ NEED_MD5=y/@@ -377,6 +377,16 @@ NEED_MD5=y/' patches/mtk-hostapd-0311be-000-mtk-mlo.patch
+	cd -
+}
diff --git a/setup-environment b/setup-environment
index b881e8f..629e64c 100755
--- a/setup-environment
+++ b/setup-environment
@@ -55,6 +55,16 @@
 EOF
 fi
 
+if [[ ! -d  ../meta-filogic-logan/recipes-wifi/hostapd/files/patches ]]
+then
+	sh ../meta-cmf-filogic/mtk_scripts/sync_hostapd_patch.sh hostapd
+fi
+
+if [[ ! -d  ../meta-filogic-logan/recipes-wifi/wpa-supplicant/files/patches ]]
+then
+	sh ../meta-cmf-filogic/mtk_scripts/sync_hostapd_patch.sh wpa_supplicant
+fi
+
 # Add meta-rdk-opensync only if not already present.
 if [[ $(grep '^BBLAYERS' conf/bblayers.conf | grep -c 'meta-rdk-opensync') -eq 0 ]] && [[ -d  ../meta-rdk-opensync ]]
 then