
install_64bit_plugins() {
	echo -e "\n\n----- install 64bit plugins -----\n"
	rpm -Uvh --force --nodeps ./64bit/connectivity/wlandrv-plugin-tizen*.rpm
}

install_32bit_plugins() {
	echo -e "\n\n----- install 32bit plugins -----\n"

	local arch_name=`rpm -q --queryformat="%{ARCH}" glibc`

	echo -e "\n\n----- install $arch_name plugins -----\n"

	if [ "$arch_name" = "armv7hl" ]; then
		rpm -Uvh --force --nodeps ./32bit/connectivity/wlandrv-plugin-tizen*.armv7hl.rpm
	elif [ "$arch_name" = "armv7l" ]; then
		rpm -Uvh --force --nodeps ./32bit/connectivity/wlandrv-plugin-tizen*.armv7l.rpm
	else
		echo "Unknown Arch : $arch_name"
		echo "Failed to install plugins \n\n"
		exit 1
	fi
}

############ Start Here
#set -x

mount -o remount,rw /
sleep 1
mount -o remount,rw /hal

cp -p ./noarch/connectivity/wifi-mesh/* /usr/lib/firmware/
chsmack -a "_" /usr/lib/firmware/*

arch_ver=`uname -m`
echo "arch : $arch_ver"

rpm -e --nodeps wlandrv-plugin-tizen

if [ "$arch_ver" = "aarch64" ]; then
	install_64bit_plugins
elif [ "$arch_ver" = "armv7l" ]; then
	install_32bit_plugins
else
	echo -e "Unknown Arch : $arch_ver"
	echo -e "Failed to install plugins \n\n"
	exit 1
fi

echo -e "\n\n----- Sync & Reboot -----\n"
sync
reboot
