Search Linux Wireless

[PATCH] compat: Install udev rules and scripts needed for compat_firmware_class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If you are a distribution maintainer and your distribution has
lsb_release and if you disagree with the way we handle the
uknown case just go ahead and add a case for yourself in
scripts/compat_firmware_install along with a directory and
your own files.

Signed-off-by: Luis R. Rodriguez <lrodriguez@xxxxxxxxxxx>
---

FYI -- I just merged this into compat.git. Please send me a patch
if your distribution needs some other special cases.

 Makefile                             |    1 +
 scripts/compat_firmware_install      |   19 ++++++++++++++++++
 udev/50-compat_firmware.rules        |    4 +++
 udev/compat_firmware.sh              |   35 ++++++++++++++++++++++++++++++++++
 udev/ubuntu/50-compat_firmware.rules |    4 +++
 udev/ubuntu/compat_firmware.sh       |   29 ++++++++++++++++++++++++++++
 6 files changed, 92 insertions(+), 0 deletions(-)
 create mode 100755 scripts/compat_firmware_install
 create mode 100644 udev/50-compat_firmware.rules
 create mode 100755 udev/compat_firmware.sh
 create mode 100644 udev/ubuntu/50-compat_firmware.rules
 create mode 100755 udev/ubuntu/compat_firmware.sh

diff --git a/Makefile b/Makefile
index be2fdc5..3692f96 100644
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,7 @@ install: modules
 	$(MAKE) -C $(KLIB_BUILD) M=$(PWD) $(KMODDIR_ARG) $(KMODPATH_ARG) \
 		modules_install
 	depmod -a
+	@./scripts/compat_firmware_install
 clean:
 	$(MAKE) -C $(KLIB_BUILD) M=$(PWD) clean
 all: modules
diff --git a/scripts/compat_firmware_install b/scripts/compat_firmware_install
new file mode 100755
index 0000000..d92961a
--- /dev/null
+++ b/scripts/compat_firmware_install
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+if [ -f /usr/bin/lsb_release ]; then
+	LSB_RED_ID=$(/usr/bin/lsb_release -i -s)
+else
+	LSB_RED_ID="Unknown"
+fi
+
+case $LSB_RED_ID in
+"Ubuntu")
+	cp udev/ubuntu/compat_firmware.sh /lib/udev/
+	cp udev/ubuntu/50-compat_firmware.rules /lib/udev/rules.d/
+        ;;
+*)
+	cp udev/compat_firmware.sh /lib/udev/
+	cp udev/50-compat_firmware.rules /lib/udev/rules.d/
+        ;;
+esac
+
diff --git a/udev/50-compat_firmware.rules b/udev/50-compat_firmware.rules
new file mode 100644
index 0000000..6473788
--- /dev/null
+++ b/udev/50-compat_firmware.rules
@@ -0,0 +1,4 @@
+# do not edit this file, it will be overwritten on update
+
+# compat_firmware-class requests, copies files into the kernel
+SUBSYSTEM=="compat_firmware", ACTION=="add", RUN+="compat_firmware.sh"
diff --git a/udev/compat_firmware.sh b/udev/compat_firmware.sh
new file mode 100755
index 0000000..ef609e7
--- /dev/null
+++ b/udev/compat_firmware.sh
@@ -0,0 +1,35 @@
+#!/bin/sh -e
+
+# This is ported from Ubuntu but ubuntu uses these directories which
+# other distributions don't care about:
+# FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \
+#               /lib/firmware/$(uname -r) /lib/firmware"
+# If your distribution looks for firmware in other directories
+# feel free to extend this and add your own directory here.
+#
+FIRMWARE_DIRS="/lib/firmware"
+
+err() {
+	echo "$@" >&2
+	logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true
+}
+
+if [ ! -e /sys$DEVPATH/loading ]; then
+	err "udev firmware loader misses sysfs directory"
+	exit 1
+fi
+
+for DIR in $FIRMWARE_DIRS; do
+	[ -e "$DIR/$FIRMWARE" ] || continue
+	echo 1 > /sys$DEVPATH/loading
+	cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
+	echo 0 > /sys$DEVPATH/loading
+	exit 0
+done
+
+echo -1 > /sys$DEVPATH/loading
+err "Cannot find  firmware file '$FIRMWARE'"
+mkdir -p /dev/.udev/firmware-missing
+file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g')
+ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file
+exit 1
diff --git a/udev/ubuntu/50-compat_firmware.rules b/udev/ubuntu/50-compat_firmware.rules
new file mode 100644
index 0000000..6473788
--- /dev/null
+++ b/udev/ubuntu/50-compat_firmware.rules
@@ -0,0 +1,4 @@
+# do not edit this file, it will be overwritten on update
+
+# compat_firmware-class requests, copies files into the kernel
+SUBSYSTEM=="compat_firmware", ACTION=="add", RUN+="compat_firmware.sh"
diff --git a/udev/ubuntu/compat_firmware.sh b/udev/ubuntu/compat_firmware.sh
new file mode 100755
index 0000000..9d4659a
--- /dev/null
+++ b/udev/ubuntu/compat_firmware.sh
@@ -0,0 +1,29 @@
+#!/bin/sh -e
+
+FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \
+               /lib/firmware/$(uname -r) /lib/firmware"
+
+err() {
+	echo "$@" >&2
+	logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true
+}
+
+if [ ! -e /sys$DEVPATH/loading ]; then
+	err "udev firmware loader misses sysfs directory"
+	exit 1
+fi
+
+for DIR in $FIRMWARE_DIRS; do
+	[ -e "$DIR/$FIRMWARE" ] || continue
+	echo 1 > /sys$DEVPATH/loading
+	cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
+	echo 0 > /sys$DEVPATH/loading
+	exit 0
+done
+
+echo -1 > /sys$DEVPATH/loading
+err "Cannot find  firmware file '$FIRMWARE'"
+mkdir -p /dev/.udev/firmware-missing
+file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g')
+ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file
+exit 1
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux