[debian-edu-commits] r78736 - trunk/src/hw-support-handler
pere at alioth.debian.org
pere at alioth.debian.org
Mon Jan 14 19:51:27 UTC 2013
Author: pere
Date: 2013-01-14 19:51:26 +0000 (Mon, 14 Jan 2013)
New Revision: 78736
Added:
trunk/src/hw-support-handler/hw-support-lookup
Log:
Shell implementation.
Added: trunk/src/hw-support-handler/hw-support-lookup
===================================================================
--- trunk/src/hw-support-handler/hw-support-lookup (rev 0)
+++ trunk/src/hw-support-handler/hw-support-lookup 2013-01-14 19:51:26 UTC (rev 78736)
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# Look up modalias in package-modalias mapping file(s), and report the
+# matching packages.
+#
+# If no argument is given, look up all modalias entries found in /sys.
+# If an argument is given, look up the modalias given on th command
+# line.
+
+ubuntu_lists() {
+ ubmirror=http://ftp.uninett.no/ubuntu
+ suite=raring
+ arch=i386
+ for section in main restricted multiverse universe
+ do
+ GET $ubmirror/dists/$suite/$section/binary-$arch/Packages.bz2 | bunzip2
+ done
+}
+
+debian_lists() {
+ if [ -r modaliases ] ; then cat modaliases; fi
+ if [ -r /usr/share/hw-support-handler/modaliases ] ; then
+ cat /usr/share/hw-support-handler/modaliases
+ fi
+ GET 'http://anonscm.debian.org/viewvc/debian-edu/trunk/src/hw-support-handler/modaliases?view=co'
+}
+
+get_lists() {
+ #ubuntu_lists
+ debian_lists
+}
+
+# Make sure file names do not contain slash by mapping % -> %25 and / -> %2F
+escape() {
+ sed -e 's:%:%25:g' -e 's:/:%2F:g'
+}
+
+pkglookup() {
+ while read package modaliases ; do
+ for alias in $(echo $modaliases | tr ")" "\n" | cut -d"(" -f2 | sed "s/, /\n/g" | escape); do
+ if ls $alias >/dev/null 2>&1 ; then
+ echo $package
+ fi
+ done
+ done | sort -u
+}
+
+dir=$(mktemp -d)
+cd $dir
+
+# First, find all relevant modalias entries for the current machine,
+# and create a file with the alias name.
+if [ "$1" ] ; then
+ touch "$*"
+else
+ for id in $(cat $(find /sys -name modalias) |egrep '^(usb|pci|acpi|dmi):' | sort -u | escape ); do
+ touch "$id"
+ done
+fi
+
+# Next, extract package name and modalias glob list, and look up
+# packages using shell globbing to match the current systems hardware.
+get_lists \
+ | grep -E '^Package: |^Modaliases: |^$' \
+ | tr "\n" "#" \
+ | sed "s/##/\n/g" \
+ | tr "#" " " \
+ | sed -e 's/^Package: //' -e 's/ Modaliases: / /g' \
+ | pkglookup
+
+cd /
+rm -rf $dir
Property changes on: trunk/src/hw-support-handler/hw-support-lookup
___________________________________________________________________
Added: svn:executable
+ *
More information about the debian-edu-commits
mailing list