From cbad9ebe19734201141b78c8eaf65bcb90117670 Mon Sep 17 00:00:00 2001
From: Frank Hunleth <fhunleth@troodon-software.com>
Date: Mon, 9 May 2016 13:21:56 -0400
Subject: [PATCH] kernel-wireless-regdb: install regdb in kernel

This kernel extension makes the CONFIG_CFG80211_INTERNAL_REGDB kernel
option work by installing a wireless regulatory database into
net/wireless/db.txt.
---
 linux/Config.ext.in                                      |  8 ++++++++
 linux/linux-ext-kernel-wireless-regdb.mk                 | 12 ++++++++++++
 package/Config.in                                        |  1 +
 package/kernel-wireless-regdb/Config.in                  |  9 +++++++++
 package/kernel-wireless-regdb/kernel-wireless-regdb.hash |  2 ++
 package/kernel-wireless-regdb/kernel-wireless-regdb.mk   | 13 +++++++++++++
 6 files changed, 45 insertions(+)
 create mode 100644 linux/linux-ext-kernel-wireless-regdb.mk
 create mode 100644 package/kernel-wireless-regdb/Config.in
 create mode 100644 package/kernel-wireless-regdb/kernel-wireless-regdb.hash
 create mode 100644 package/kernel-wireless-regdb/kernel-wireless-regdb.mk

diff --git a/linux/Config.ext.in b/linux/Config.ext.in
index 8024d73..d12beef 100644
--- a/linux/Config.ext.in
+++ b/linux/Config.ext.in
@@ -79,4 +79,12 @@ config BR2_LINUX_KERNEL_EXT_EV3DEV
 	help
 	  ev3dev drivers for LEGO MINDSTORMS EV3, etc.
 
+# kernel-wireless-regdb
+config BR2_LINUX_KERNEL_EXT_KERNEL_WIRELESS_REGDB
+	bool "Wireless regulatory database"
+	select BR2_PACKAGE_KERNEL_WIRELESS_REGDB
+	help
+	  Install the wireless regulatory database into the kernel
+	  to support the CONFIG_CFG80211_INTERNAL_REGDB option.
+
 endmenu
diff --git a/linux/linux-ext-kernel-wireless-regdb.mk b/linux/linux-ext-kernel-wireless-regdb.mk
new file mode 100644
index 0000000..3cec0cd
--- /dev/null
+++ b/linux/linux-ext-kernel-wireless-regdb.mk
@@ -0,0 +1,12 @@
+################################################################################
+# Linux wireless-regdb extension
+#
+# Patch the linux kernel with the latest wireless-regdb database.
+# This enables the CONFIG_CFG80211_INTERNAL_REGDB kernel option.
+################################################################################
+
+LINUX_EXTENSIONS += kernel-wireless-regdb
+
+define KERNEL_WIRELESS_REGDB_PREPARE_KERNEL
+	cp -pf $(KERNEL_WIRELESS_REGDB_DIR)/db.txt $(LINUX_DIR)/net/wireless/db.txt
+endef
diff --git a/package/Config.in b/package/Config.in
index 4e7be32..a7d0473 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1484,6 +1484,7 @@ menu "Networking applications"
 	source "package/irssi/Config.in"
 	source "package/iw/Config.in"
 	source "package/janus-gateway/Config.in"
+	source "package/kernel-wireless-regdb/Config.in"
 	source "package/kismet/Config.in"
 	source "package/knock/Config.in"
 	source "package/leafnode2/Config.in"
diff --git a/package/kernel-wireless-regdb/Config.in b/package/kernel-wireless-regdb/Config.in
new file mode 100644
index 0000000..8a54a21
--- /dev/null
+++ b/package/kernel-wireless-regdb/Config.in
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_KERNEL_WIRELESS_REGDB
+	bool "kernel-wireless-regdb"
+	help
+	  Wireless regulatory database.
+
+	  Wireless regulatory database for the kernel. The database
+	  lists allowed radio frequencies for each local jurisdiction.
+
+	  http://linuxwireless.org/en/developers/Regulatory
diff --git a/package/kernel-wireless-regdb/kernel-wireless-regdb.hash b/package/kernel-wireless-regdb/kernel-wireless-regdb.hash
new file mode 100644
index 0000000..b8ca2e7
--- /dev/null
+++ b/package/kernel-wireless-regdb/kernel-wireless-regdb.hash
@@ -0,0 +1,2 @@
+# From https://www.kernel.org/pub/software/network/wireless-regdb/sha256sums.asc
+sha256	cfedf1c3521b3c8f32602f25ed796e96e687c3441a00e7c050fedf7fd4f1b8b7	wireless-regdb-2016.06.10.tar.xz
diff --git a/package/kernel-wireless-regdb/kernel-wireless-regdb.mk b/package/kernel-wireless-regdb/kernel-wireless-regdb.mk
new file mode 100644
index 0000000..d39a76c
--- /dev/null
+++ b/package/kernel-wireless-regdb/kernel-wireless-regdb.mk
@@ -0,0 +1,13 @@
+################################################################################
+#
+# kernel-wireless-regdb
+#
+################################################################################
+
+KERNEL_WIRELESS_REGDB_VERSION = 2016.06.10
+KERNEL_WIRELESS_REGDB_SOURCE = wireless-regdb-$(WIRELESS_REGDB_VERSION).tar.xz
+KERNEL_WIRELESS_REGDB_SITE = http://kernel.org/pub/software/network/wireless-regdb
+KERNEL_WIRELESS_REGDB_LICENSE = ISC
+KERNEL_WIRELESS_REGDB_LICENSE_FILES = LICENSE
+
+$(eval $(generic-package))
-- 
2.7.4

