$ git diff --patch-with-stat --summary 701819e93b8e6693b4652fb3d5e386b0dc61b629..bf80a182fbafced49c121bd458d4723c7d26d72f
.abf.yml | 2 +-
85-regulatory.rules | 5 ++++
setregdomain | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++
setregdomain.1 | 36 ++++++++++++++++++++++++++++
wireless-regdb.spec | 59 ++++++++++++++++++++++++++++++---------------
5 files changed, 151 insertions(+), 20 deletions(-)
create mode 100644 85-regulatory.rules
create mode 100644 setregdomain
create mode 100644 setregdomain.1
diff --git a/.abf.yml b/.abf.yml
index e29fdbc..98794fc 100644
--- a/.abf.yml
+++ b/.abf.yml
@@ -1,2 +1,2 @@
sources:
- wireless-regdb-2019.03.01.tar.xz: 60e8c2c900ac5cc1fa29b0c665125b77b95ba278
+ wireless-regdb-2019.06.03.tar.xz: 22520576da73b6282d6cd28fe469913258aecd3f
diff --git a/85-regulatory.rules b/85-regulatory.rules
new file mode 100644
index 0000000..705e765
--- /dev/null
+++ b/85-regulatory.rules
@@ -0,0 +1,5 @@
+# Set wireless regulatory domain at device creation
+# For more information:
+# man setregdomain
+
+SUBSYSTEM=="ieee80211", ACTION=="add", RUN+="/usr/sbin/setregdomain"
diff --git a/setregdomain b/setregdomain
new file mode 100644
index 0000000..74d885a
--- /dev/null
+++ b/setregdomain
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# Copyright 2009-2014 Red Hat, Inc. All rights reserved.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+REGDOMAIN=/etc/sysconfig/regdomain
+LOCALTIME=/etc/localtime
+
+LOGGER="/usr/bin/logger -t wireless"
+
+getcountry() {
+ while read c a z r
+ do
+ if [ "$z" = "$ZONE" ]
+ then
+ echo $c
+ break
+ fi
+ done < /usr/share/zoneinfo/zone.tab
+}
+
+if [ -f $REGDOMAIN ]
+then
+ # This should set COUNTRY
+ . $REGDOMAIN
+ if [ -n "$COUNTRY" ]
+ then
+ /usr/sbin/iw reg set $COUNTRY
+ exit
+ fi
+fi
+
+if [ -f "$LOCALTIME" ]
+then
+ ZONE=$(readlink -f $LOCALTIME)
+ ZONE=${ZONE#/usr/share/zoneinfo/}
+else
+ $LOGGER -s "Timezone information not found! Unable to set regulatory domain."
+ exit 1
+fi
+
+if [ -z "$ZONE" -o "$ZONE" = "$LOCALTIME" ]
+then
+ $LOGGER -s "Could not determine timezone! Unable to set regulatory domain."
+ exit 1
+fi
+
+COUNTRY=$(getcountry)
+
+if [ -z "$COUNTRY" ]
+then
+ $LOGGER -s "Could not determine country! Unable to set regulatory domain."
+ exit 1
+fi
+
+$LOGGER "setting regulatory domain to $COUNTRY based on timezone ($ZONE)"
+/usr/sbin/iw reg set $COUNTRY
diff --git a/setregdomain.1 b/setregdomain.1
new file mode 100644
index 0000000..e246275
--- /dev/null
+++ b/setregdomain.1
@@ -0,0 +1,36 @@
+.\" Copyright 2009 Red Hat, Inc.
+.TH segregdomain 1 2014-11-19 "CRDA" "User Commands"
+.SH NAME
+setregdomain \- set regulatory domain based on country code
+.SH SYNOPSIS
+.B setregdomain
+.SH DESCRIPTION
+setregdomain sets the regulatory domain for your system; it takes no
+arguments and is normally called via system script (eg, udev) rather
+than manually by an administrator.
+
+The regulatory domain is represented by an ISO / IEC 3166-1 alpha2
+country code. By default, setregdomain attempts to determine
+the appropriate country code by examining the target of the
+.IR /etc/localtime
+symbolic link. That information is used to look-up the matching
+country code in the
+.IR /usr/share/zoneinfo/zone.tab
+file.
+
+The country code look-up may fail. This could be due to faulty
+or incomplete information in the
+.IR /usr/share/zoneinfo/zone.tab
+file, or the use of an actual file rather than a symlink for
+.IR /etc/localtime
+, among other possibilities. In those cases the system
+administrator should define a COUNTRY environment variable in the
+.IR /etc/sysconfig/regdomain
+file. This value will be used as the country code and the country
+code look-up will be skipped.
+.SH "FILES"
+.BR /etc/sysconfig/regdomain
+.BR /etc/localtime
+.BR /usr/share/zoneinfo/zone.tab
+.SH "SEE ALSO"
+.BR iw (1)
diff --git a/wireless-regdb.spec b/wireless-regdb.spec
index 0f2ddd7..3ffb0b3 100644
--- a/wireless-regdb.spec
+++ b/wireless-regdb.spec
@@ -1,33 +1,54 @@
-%define _verdate 2019.03.01
-%define _version %(echo %_verdate | sed 's/\\.//g')
+%global _firmwarepath /lib/firmware
+%define oldver %(echo %version | sed 's/\\.//g')
+Summary: Regulatory database for 802.11 wireless networking
Name: wireless-regdb
-Version: %{_version}
-Release: 1
-Summary: The wireless regulatory database
+Version: 2019.06.03
+Release: 6
License: ISC
-Group: System/Configuration/Hardware
-URL: http://linuxwireless.org/en/developers/Regulatory#Theregulatorydatabase
-Source0: http://wireless.kernel.org/download/wireless-regdb/wireless-regdb-%{_verdate}.tar.xz
+URL: https://wireless.wiki.kernel.org/en/developers/regulatory/wireless-regdb
+Source0: http://www.kernel.org/pub/software/network/wireless-regdb/wireless-regdb-%{version}.tar.xz
+Source1: setregdomain
+Source2: setregdomain.1
+Source3: 85-regulatory.rules
BuildArch: noarch
+BuildRequires: systemd-macros
+Requires: iw
+Requires: systemd
+Provides: crda = 3.18-7
+Obsoletes: crda < 3.18-7
+Obsoletes: wireless-regdb < 20190301-2
+Provides: wireless-regdb = 20190301-2
+Provides: wireless-regdb = %{oldver}-%{release}
+Obsoletes: wireless-regdb < %{oldver}-%{release}
%description
-Database with wireless regulatory information, used by crda or which can
-be used by another user space helpers to communicate wireless regulatory
-data to linux kernel.
+The wireless-regdb package provides the regulatory rules database
+used by the kernels 802.11 networking stack in order to comply
+with radio frequency regulatory rules around the world.
%prep
-%autosetup -n %{name}-%{_verdate} -p1
+%autosetup -p1
%build
+# Package installs a firmware-like, prebuilt binary from upstream...
%install
-%make_install
+%make_install DESTDIR=%{buildroot} MANDIR=%{_mandir} FIRMWARE_PATH=%{_firmwarepath}
+
+install -D -pm 0755 %{SOURCE1} %{buildroot}%{_sbindir}/setregdomain
+install -D -pm 0644 %{SOURCE2} %{buildroot}%{_mandir}/man1/setregdomain.1
+install -D -pm 0644 %{SOURCE3} %{buildroot}%{_udevrulesdir}/85-regulatory.rules
+
+rm -rf %{buildroot}/usr/lib/crda
%files
-%defattr(0644,root,root,0755)
-%doc LICENSE
-%{_mandir}/man5/regulatory.*.5*
-%{_prefix}/lib/crda/regulatory.bin
-%{_prefix}/lib/crda/pubkeys/*.key.pub.pem
-/lib/firmware/regulatory.db*
+%license LICENSE
+%doc README
+%{_sbindir}/setregdomain
+%{_udevrulesdir}/85-regulatory.rules
+%{_firmwarepath}/regulatory.db
+%{_firmwarepath}/regulatory.db.p7s
+%{_mandir}/man1/setregdomain.1*
+%{_mandir}/man5/regulatory.db.5*
+%{_mandir}/man5/regulatory.bin.5*