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

pere at alioth.debian.org pere at alioth.debian.org
Fri Jan 11 22:24:02 UTC 2013


Author: pere
Date: 2013-01-11 22:24:02 +0000 (Fri, 11 Jan 2013)
New Revision: 78711

Added:
   trunk/src/hw-support-handler/discover-data2modaliases
Log:
Add script to convert discover-data info to Modaliases entries.

Added: trunk/src/hw-support-handler/discover-data2modaliases
===================================================================
--- trunk/src/hw-support-handler/discover-data2modaliases	                        (rev 0)
+++ trunk/src/hw-support-handler/discover-data2modaliases	2013-01-11 22:24:02 UTC (rev 78711)
@@ -0,0 +1,64 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use XML::Simple;
+use Data::Dumper;
+
+my %pkgmap;
+for my $bus ("pci", "usb") {
+    my $ref = XMLin("/lib/discover/$bus-device.xml");
+    for my $device (@{$ref->{'device'}}) {
+#        print Dumper($device);
+
+        if (exists $device->{'data'}) {
+            my $entries;
+            if ("ARRAY" eq ref $device->{'data'}) {
+                $entries = @{$device->{'data'}};
+            } else {
+                $entries = $device->{'data'};
+            }
+            for my $data ($entries) {
+                if ("HASH" eq ref $data && "package" eq $data->{'class'}) {
+#                    print Dumper($data);
+                    my $vendor = uc($device->{'vendor'});
+                    my $model = uc($device->{'model'});
+                    my @pkgentries;
+#                    print Dumper($data->{data}[0]->{'data'});
+                    if ("ARRAY" eq ref $data->{data}[0]->{'data'}) {
+                        @pkgentries = @{$data->{data}[0]->{'data'}};
+                    } else {
+                        @pkgentries = $data->{data}[0]->{'data'};
+                    }
+
+#                    print Dumper(@pkgentries);
+
+                    for my $pkgentry (@pkgentries) {
+                        my $pkglist = $pkgentry->{'content'};
+                        for my $pkg (split(/ /, $pkglist)) {
+                            my $modalias;
+                            if ("usb" eq $bus) {
+                                $modalias = "usb:v${vendor}p${model}d*";
+                            } elsif ("pci" eq $bus) {
+                                $modalias = "pci:v0000${vendor}d0000${model}sv*";
+                            } else {
+                            }
+                            if (exists $pkgmap{$pkg}) {
+                                push(@{$pkgmap{$pkg}}, $modalias);
+                            } else {
+                                $pkgmap{$pkg} = [$modalias];
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+for my $pkg (sort keys %pkgmap) {
+    print "Package: $pkg\n";
+    print "Modaliases: $pkg(".join(", ", sort @{$pkgmap{$pkg}}), ")\n";
+    print "\n";
+}


Property changes on: trunk/src/hw-support-handler/discover-data2modaliases
___________________________________________________________________
Added: svn:executable
   + *




More information about the debian-edu-commits mailing list