]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/hwinfo/src/ids/cdb_x11
Kleiner netter neuer Versuch.
[people/pmueller/ipfire-2.x.git] / src / hwinfo / src / ids / cdb_x11
CommitLineData
a6316ce4
MT
1#!/usr/bin/perl -w
2# Copyright (c) 1996 SuSE GmbH Nuernberg, Germany. All rights reserved.
3#
4# Author: Dirk Hessing <dhess@suse.de>, 08/2001
5#
6# Exporting hw-data for x11 from developer-CDB
7
8
9use DBI;
10use strict;
11use IO::Handle;
12use Getopt::Long;
13
14# MySQL-Host / MySQL-User
15my $hostname = "cdbintern.suse.de";
16my $mysql_user = "cdbclient";
17my $mysql_passwd = "cdb";
18my $target = "cdb";
19
20my $driver = DBI->install_driver('mysql');
21my $dbh = DBI->connect('DBI:mysql:'.$target.':'.$hostname,$mysql_user,$mysql_passwd)
22 or die "Can't connect to the MySQL Database, table $target";
23
24### Log-Handle und STDOUT-Handle auf ungepufferte Ausgabe setzten (schlechtere Performance ;-)
25STDOUT->autoflush();
26
27
28my $dist_name = "Stable";
29my $date = localtime();
30
31my (@query,$x,$result,$arch_name,@arch_names,$filename,$count);
32my ($product_id,$product_name,$vendor_name,$bus_name,$subclass_name);
33my ($vId,$dId,$sdId,$svId);
34my (%tooltopics,$tooltopic_name,$vario_name,$charvalue);
35
36my $opt_dir = "tmp";
37
38
39# convert to new id format
40sub new_id
41{
42 my ($old_id, $id_class, $tag, $id);
43
44 ($old_id, $id_class) = @_;
45
46 if($old_id =~ /^([us]?)(\S{4})$/) {
47 $tag = $1;
48 $id = $2;
49 }
50 else {
51 die "invalid id format: \"$old_id\"\n";
52 }
53
54 if($tag eq "" && $id_class && $id_class =~ /^([us]?)(\S{4})$/) {
55 $tag = $1;
56 }
57
58 if($tag eq "s") {
59 $tag = "special ";
60 }
61 elsif($tag eq "u") {
62 $tag = "usb ";
63 }
64 elsif($tag eq "") {
65 $tag = "pci ";
66 }
67 else {
68 die "invalid id format: \"$old_id\"\n";
69 }
70
71 return "${tag}0x$id";
72}
73
74
75# write data to FH
76sub write_info
77{
78 my ($arch, $xfree, $has3d, $vId, $dId, $svId, $sdId, $vName, $dName, $tt, $raw, @raw);
79
80 ($arch, $xfree, $has3d, $vId, $dId, $svId, $sdId, $vName, $dName, $tt) = @_;
81
82 return unless $vId ne "" && $dId ne "";
83
84 # print FH "\n# vId = $vId, dId = $dId, svId = $svId, sdId = $sdId, vName = \"$vName\", dName = \"$dName\"\n";
85
86 if($svId ne "" && $sdId ne "") {
87 print FH "\n vendor.id\t\t${\new_id $vId}\n";
88 print FH "+vendor.name\t\t$vName\n";
89
90 print FH "\n vendor.id\t\t${\new_id $vId}\n";
91 print FH "&device.id\t\t${\new_id $dId, $vId}\n";
92 print FH "&subvendor.id\t\t${\new_id $svId, $vId}\n";
93 print FH "&subdevice.id\t\t${\new_id $sdId, $vId}\n";
94 print FH "+subdevice.name\t\t$dName\n";
95 }
96 else {
97 print FH "\n vendor.id\t\t${\new_id $vId}\n";
98 print FH "+vendor.name\t\t$vName\n";
99
100 print FH "\n vendor.id\t\t${\new_id $vId}\n";
101 print FH "&device.id\t\t${\new_id $dId, $vId}\n";
102 print FH "+device.name\t\t$dName\n";
103 }
104
105 if($$tt{resol} ne "") {
106 $$tt{resol} =~ s/bpp//g;
107 }
108
109 # Teste ob mehr als ein driver- oder installscript-topic vorhanden ist:
110 if(($$tt{driver} =~ /,/) || ($$tt{installscript} =~ /,/)) {
111 warn
112 "\nMore than one driver- or installscript-topic.\n" .
113 " Product-id = $product_id, Vario = $vario_name, Arch = $arch\n" .
114 " Id = (${\new_id $vId}, ${\new_id $dId, $vId}), Name = $dName\n" .
115 " Driver = \"$$tt{driver}\", script = \"$$tt{installscript}\"\n";
116 }
117
118 print FH
119 "+driver.xfree\t\t$xfree|$$tt{driver}|" .
120 ($has3d ? "3d" : "") .
121 "|$$tt{package}|$$tt{extension}|$$tt{option}|$$tt{resol}||$$tt{installscript}|\n";
122
123 if ($$tt{raw} ne "") {
124 @raw = (split(',',$$tt{raw}));
125 foreach $raw (@raw) {
126 print FH "+driver.xfree.config\t$raw\n";
127 }
128 }
129}
130
131
132# get product info and write everything to FH
133sub get_info
134{
135 my ($arch_name, $xfree, $has3d);
136
137 ($arch_name, $vario_name) = @_;
138
139 $xfree = $vario_name =~ /XFree3/ ? 3 : 4;
140 $has3d = $vario_name =~ /3D/ ? 1 : 0;
141
142 $tooltopics{driver} = "";
143 $tooltopics{package} = "";
144 $tooltopics{extension} = "";
145 $tooltopics{option} = "";
146 $tooltopics{resol} = "";
147 $tooltopics{installscript} = "";
148 $tooltopics{raw} = "";
149
150 # Product supported=full?
151 $query[2] = $dbh->prepare("SELECT toolproperty.charvalue FROM toolproperty
152 LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
153 LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
154 LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
155 LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
156 LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
157 WHERE toolproperty.product_id=$product_id
158 AND tooltopic.name='supported'
159 AND arch.name='$arch_name'
160 AND distribution.name='$dist_name'
161 AND vario.name='$vario_name'
162 AND toolproperty.valid=1
163 AND tooltopic.valid=1
164 AND arch_dist_l_vario.valid=1")
165 or die "Can\'t select table toolproperty";
166 $query[2]->execute or die "Can\'t select table toolproperty";
167
168 undef $result;
169 $count = 0;
170 while ($x = $query[2]->fetchrow_array) {
171 $result = $x if defined $x;
172 multiple_supportedtopics($dbh,$product_id,$product_name,$arch_name,$dist_name,$vario_name) if $count > 0;
173 $count++;
174 }
175 $result = "" if not defined $result;
176
177 if ($result eq "full") {
178 $query[2] = $dbh->prepare("SELECT tooltopic.name,toolproperty.charvalue FROM toolproperty
179 LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
180 LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
181 LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
182 LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
183 LEFT JOIN language ON arch_dist_l_vario.lang_id=language.id
184 LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
185 WHERE arch.name='$arch_name'
186 AND distribution.name='$dist_name'
187 AND vario.name='$vario_name'
188 AND toolproperty.product_id=$product_id
189 AND tooltopic.name != 'supported'
190 AND toolproperty.valid=1
191 AND tooltopic.valid=1
192 AND arch_dist_l_vario.valid=1")
193 or die "Can\'t select table toolproperty";
194 $query[2]->execute or die "Can\'t select table toolproperty";
195
196 while ( ($tooltopic_name,$charvalue) = ($query[2]->fetchrow_array) ) {
197 if (($charvalue eq "none") || ($charvalue eq "None")) {
198 $charvalue = "";
199 }
200 next if $charvalue eq "";
201 if (!$tooltopics{"$tooltopic_name"}) {
202 $tooltopics{"$tooltopic_name"} = $charvalue;
203 } else {
204 $tooltopics{"$tooltopic_name"} .= ",".$charvalue;
205 }
206 }
207
208 write_info $arch_name, $xfree, $has3d, $vId, $dId, $svId, $sdId, $vendor_name, $product_name, \%tooltopics;
209 }
210}
211
212
213GetOptions(
214 'dir=s' => \$opt_dir
215) ;
216
217
218print "\n\nGenerating x11.hwinfo-files, one for each architecture.\n";
219mkdir($opt_dir, 0755) || die "\nmkdir: $opt_dir: $!\n" unless -d $opt_dir;
220
221print "\nStoring files in \"$opt_dir\"\n\n";
222
223$query[0] = $dbh->prepare("SELECT name FROM arch WHERE valid=1")
224 or die "Can\'t select table arch";
225$query[0]->execute or die "Can\'t select table arch";
226while ($result = $query[0]->fetchrow_array) {
227 push(@arch_names,$result);
228}
229
230