diff --git a/wireless-regdb-85-regulatory.rules b/wireless-regdb-85-regulatory.rules new file mode 100644 index 0000000..705e765 --- /dev/null +++ b/wireless-regdb-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/wireless-regdb-setregdomain b/wireless-regdb-setregdomain new file mode 100644 index 0000000..74d885a --- /dev/null +++ b/wireless-regdb-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/wireless-regdb-setregdomain.1 b/wireless-regdb-setregdomain.1 new file mode 100644 index 0000000..e246275 --- /dev/null +++ b/wireless-regdb-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 0d4091b..98241d6 100644 --- a/wireless-regdb.spec +++ b/wireless-regdb.spec @@ -1,6 +1,6 @@ Name: wireless-regdb Version: 2023.09.01 -Release: 1mamba +Release: 2mamba Summary: Wireless Central Regulatory Domain Database Group: System/Kernel and Hardware Vendor: openmamba @@ -8,9 +8,15 @@ Distribution: openmamba Packager: Silvan Calarco URL: https://wireless.wiki.kernel.org/en/developers/regulatory/wireless-regdb Source: https://www.kernel.org/pub/software/network/wireless-regdb/wireless-regdb-%{version}.tar.xz +Source1: wireless-regdb-setregdomain +Source2: wireless-regdb-85-regulatory.rules +Source3: wireless-regdb-setregdomain.1 License: BSD ## AUTOBUILDREQ-BEGIN ## AUTOBUILDREQ-END +Provides: crda +Obsoletes: crda <= 4.14-4mamba +Obsoletes: crda-devel <= 4.14-4mamba %description Wireless Central Regulatory Domain Database. @@ -22,22 +28,33 @@ Wireless Central Regulatory Domain Database. %install [ "%{buildroot}" != / ] && rm -rf "%{buildroot}" -%makeinstall +%makeinstall \ + FIRMWARE_PATH=%{_prefix}/lib/firmware + +install -D -pm 0755 %{SOURCE1} %{buildroot}%{_bindir}/setregdomain +install -D -pm 0644 %{SOURCE2} %{buildroot}%{_udevrulesdir}/85-regulatory.rules +install -D -pm 0644 %{SOURCE3} %{buildroot}%{_mandir}/man1/setregdomain.1 + +rm -rf %{buildroot}/usr/lib/crda %clean [ "%{buildroot}" != / ] && rm -rf "%{buildroot}" %files %defattr(-,root,root) -/lib/firmware/regulatory.db -/lib/firmware/regulatory.db.p7s -%{_prefix}/lib/crda/pubkeys/sforshee.key.pub.pem -%{_prefix}/lib/crda/regulatory.bin +%{_udevrulesdir}/85-regulatory.rules +%{_bindir}/setregdomain +%{_prefix}/lib/firmware/regulatory.db +%{_prefix}/lib/firmware/regulatory.db.p7s +%{_mandir}/man1/setregdomain.1* %{_mandir}/man5/regulatory.bin.5* %{_mandir}/man5/regulatory.db.5* %doc LICENSE README %changelog +* Mon Jan 15 2024 Silvan Calarco 2023.09.01-2mamba +- install setregdomain and udev rules (taken from Fedora), obsolete crda + * Sun Sep 03 2023 Automatic Build System 2023.09.01-1mamba - automatic version update by autodist