diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b68397 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/wireless-regdb-2018.05.31.tar.xz 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/README.md b/README.md deleted file mode 100644 index 25826f4..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# wireless-regdb - -The wireless-regdb package \ No newline at end of file diff --git a/setregdomain b/setregdomain new file mode 100755 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/sources b/sources new file mode 100644 index 0000000..0000e1f --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (wireless-regdb-2018.05.31.tar.xz) = fda18edd619b294b125a5c1e04e758c04332c6d1d99ed44574321753294c159bd6c6f0c592ebfd91e99d301467e8ee8b97d1ad595cd56b3902bd5f85acd95b8d diff --git a/wireless-regdb-install_db.patch b/wireless-regdb-install_db.patch new file mode 100644 index 0000000..f89ae92 --- /dev/null +++ b/wireless-regdb-install_db.patch @@ -0,0 +1,38 @@ +diff -up wireless-regdb-2018.05.31/Makefile.install_db wireless-regdb-2018.05.31/Makefile +--- wireless-regdb-2018.05.31/Makefile.install_db 2018-07-05 15:17:03.698486949 -0400 ++++ wireless-regdb-2018.05.31/Makefile 2018-07-05 15:20:33.537313703 -0400 +@@ -41,7 +41,8 @@ REGDB_CHANGED = $(shell $(SHA1SUM) -c -- + echo maintainer-clean $(REGDB_PUBKEY) $(REGDB_PUBCERT); \ + fi) + +-.PHONY: all clean mrproper install maintainer-clean install-distro-key ++.PHONY: all clean mrproper install maintainer-clean install-distro-key \ ++ install_db install_bin + + all: $(REGDB_CHANGED) regulatory.bin sha1sum.txt regulatory.db.p7s + +@@ -115,15 +116,21 @@ install-distro-key: maintainer-clean $(D + # make maintainer-clean + # make + # sudo make install +-install: regulatory.bin.5.gz regulatory.db.5.gz ++install_bin: regulatory.bin.5.gz + install -m 755 -d $(DESTDIR)/$(CRDA_PATH) + install -m 755 -d $(DESTDIR)/$(CRDA_KEY_PATH) +- install -m 755 -d $(DESTDIR)/$(FIRMWARE_PATH) + if [ -f .custom ]; then \ + install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(shell cat .custom); \ + fi + install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(REGDB_UPSTREAM_PUBKEY) + install -m 644 -t $(DESTDIR)/$(CRDA_PATH)/ regulatory.bin ++ install -m 755 -d $(DESTDIR)/$(MANDIR)/man5/ ++ install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.bin.5.gz ++ ++install_db: regulatory.db.5.gz ++ install -m 755 -d $(DESTDIR)/$(FIRMWARE_PATH) + install -m 644 -t $(DESTDIR)/$(FIRMWARE_PATH) regulatory.db regulatory.db.p7s + install -m 755 -d $(DESTDIR)/$(MANDIR)/man5/ +- install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.bin.5.gz regulatory.db.5.gz ++ install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.db.5.gz ++ ++install: install_bin install_db diff --git a/wireless-regdb.spec b/wireless-regdb.spec new file mode 100644 index 0000000..e99a306 --- /dev/null +++ b/wireless-regdb.spec @@ -0,0 +1,68 @@ +%global _firmwarepath /usr/lib/firmware + +Name: wireless-regdb +Version: 2018.05.31 +Release: 1%{?dist} +Summary: Regulatory database for 802.11 wireless networking + +Group: System Environment/Base +License: ISC +URL: https://wireless.wiki.kernel.org/en/developers/regulatory/wireless-regdb +BuildArch: noarch + +Requires: udev, iw +Requires: systemd >= 190 +Requires: kernel >= 4.15 + +# Temporarily disable Provides so as to prevent unintended upgrades +#Provides: crda = 3.18_2018.05.31-3 +Obsoletes: crda <= 3.18_2018.05.31-2 + +Source0: http://www.kernel.org/pub/software/network/wireless-regdb/wireless-regdb-%{version}.tar.xz +Source1: setregdomain +Source2: setregdomain.1 +Source3: 85-regulatory.rules + +# Split existing install rule into separate install_bin and install_db rules +Patch0: wireless-regdb-install_db.patch + + +%description +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 +%setup -q + +%patch0 -p1 -b .install_db + + +%build +: # Package installs a firmware-like, prebuilt binary from upstream... + + +%install +make install_db 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 + + +%files +%{_sbindir}/setregdomain +%{_udevrulesdir}/85-regulatory.rules +%{_firmwarepath}/regulatory.db +%{_firmwarepath}/regulatory.db.p7s +%{_mandir}/man1/setregdomain.1* +%{_mandir}/man5/regulatory.db.5* +%license LICENSE +%doc README + + +%changelog +* Fri Jul 06 2018 John W. Linville - 2018.05.31-1 +- Initial build