[debian-edu-commits] r78737 - trunk/src/hw-support-handler

pere at alioth.debian.org pere at alioth.debian.org
Mon Jan 14 20:36:20 UTC 2013


Author: pere
Date: 2013-01-14 20:36:20 +0000 (Mon, 14 Jan 2013)
New Revision: 78737

Modified:
   trunk/src/hw-support-handler/hw-support-lookup
Log:
Speed up the script by trimming lines earlier.  Fetch Debian info from the archive too.

Modified: trunk/src/hw-support-handler/hw-support-lookup
===================================================================
--- trunk/src/hw-support-handler/hw-support-lookup	2013-01-14 19:51:26 UTC (rev 78736)
+++ trunk/src/hw-support-handler/hw-support-lookup	2013-01-14 20:36:20 UTC (rev 78737)
@@ -18,6 +18,13 @@
 }
 
 debian_lists() {
+    ubmirror=http://ftp.uninett.no/debian
+    suite=sid
+    arch=i386
+    for section in main contrib non-free
+    do
+	GET $ubmirror/dists/$suite/$section/binary-$arch/Packages.bz2 | bunzip2
+    done
     if [ -r modaliases ] ; then cat modaliases; fi
     if [ -r /usr/share/hw-support-handler/modaliases ] ; then
 	cat /usr/share/hw-support-handler/modaliases
@@ -25,6 +32,19 @@
     GET 'http://anonscm.debian.org/viewvc/debian-edu/trunk/src/hw-support-handler/modaliases?view=co'
 }
 
+trim_packages() {
+    grep -E '^Package: |^Modaliases: |^$' \
+    | tr "\n" "#" \
+    | sed "s/##/\n/g" \
+    | grep -E 'Modaliases: ' \
+    | tr "\n" "%" | sed "s/%/\n\n/g" \
+    | tr "#" "\n"
+}
+
+# To generate a list of packages
+#debian_lists | trim_packages
+#exit 0
+
 get_lists() {
     #ubuntu_lists
     debian_lists
@@ -38,7 +58,7 @@
 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
+	    if ls "$alias" >/dev/null 2>&1 ; then
 		echo $package
 	    fi
 	done
@@ -53,7 +73,7 @@
 if [ "$1" ] ; then
     touch "$*"
 else
-    for id in $(cat $(find /sys -name modalias) |egrep '^(usb|pci|acpi|dmi):' | sort -u | escape ); do
+    for id in $(cat $(find /sys -name modalias) | egrep '^(usb|pci|acpi|dmi):' | sort -u | escape ); do
 	touch "$id"
     done
 fi
@@ -65,6 +85,7 @@
     | tr "\n" "#" \
     | sed "s/##/\n/g" \
     | tr "#" " " \
+    | grep Modaliases: \
     | sed -e 's/^Package: //' -e 's/ Modaliases: / /g' \
     | pkglookup
 




More information about the debian-edu-commits mailing list