2
# Copyright (c) 1996 SuSE GmbH Nuernberg, Germany. All rights reserved.
4
# Author: Dirk Hessing <dhess@suse.de>, 08/2001
6
# Exporting hw-data for x11 from developer-CDB
14
# MySQL-Host / MySQL-User
15
my $hostname = "cdbintern.suse.de";
16
my $mysql_user = "cdbclient";
17
my $mysql_passwd = "cdb";
20
my $driver = DBI->install_driver('mysql');
21
my $dbh = DBI->connect('DBI:mysql:'.$target.':'.$hostname,$mysql_user,$mysql_passwd)
22
or die "Can't connect to the MySQL Database, table $target";
24
### Log-Handle und STDOUT-Handle auf ungepufferte Ausgabe setzten (schlechtere Performance ;-)
28
my $dist_name = "Stable";
29
my $date = localtime();
31
my (@query,$x,$result,$arch_name,@arch_names,$filename,$count);
32
my ($product_id,$product_name,$vendor_name,$bus_name,$subclass_name);
33
my ($vId,$dId,$sdId,$svId);
34
my (%tooltopics,$tooltopic_name,$vario_name,$charvalue);
39
# convert to new id format
42
my ($old_id, $id_class, $tag, $id);
44
($old_id, $id_class) = @_;
46
if($old_id =~ /^([us]?)(\S{4})$/) {
51
die "invalid id format: \"$old_id\"\n";
54
if($tag eq "" && $id_class && $id_class =~ /^([us]?)(\S{4})$/) {
68
die "invalid id format: \"$old_id\"\n";
78
my ($arch, $xfree, $has3d, $vId, $dId, $svId, $sdId, $vName, $dName, $tt, $raw, @raw);
80
($arch, $xfree, $has3d, $vId, $dId, $svId, $sdId, $vName, $dName, $tt) = @_;
82
return unless $vId ne "" && $dId ne "";
84
# print FH "\n# vId = $vId, dId = $dId, svId = $svId, sdId = $sdId, vName = \"$vName\", dName = \"$dName\"\n";
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";
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";
97
print FH "\n vendor.id\t\t${\new_id $vId}\n";
98
print FH "+vendor.name\t\t$vName\n";
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";
105
if($$tt{resol} ne "") {
106
$$tt{resol} =~ s/bpp//g;
109
# Teste ob mehr als ein driver- oder installscript-topic vorhanden ist:
110
if(($$tt{driver} =~ /,/) || ($$tt{installscript} =~ /,/)) {
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";
119
"+driver.xfree\t\t$xfree|$$tt{driver}|" .
120
($has3d ? "3d" : "") .
121
"|$$tt{package}|$$tt{extension}|$$tt{option}|$$tt{resol}||$$tt{installscript}|\n";
123
if ($$tt{raw} ne "") {
125
$raw =~ s/(,)/$' =~ tr#"## & 1 ? $1 : "\n"/eg;
126
@raw = split "\n", $raw;
127
foreach $raw (@raw) {
128
print FH "+driver.xfree.config\t$raw\n";
134
# get product info and write everything to FH
137
my ($arch_name, $xfree, $has3d);
139
($arch_name, $vario_name) = @_;
141
$xfree = $vario_name =~ /XFree3/ ? 3 : 4;
142
$has3d = $vario_name =~ /3D/ ? 1 : 0;
144
$tooltopics{driver} = "";
145
$tooltopics{package} = "";
146
$tooltopics{extension} = "";
147
$tooltopics{option} = "";
148
$tooltopics{resol} = "";
149
$tooltopics{installscript} = "";
150
$tooltopics{raw} = "";
152
# Product supported=full?
153
$query[2] = $dbh->prepare("SELECT toolproperty.charvalue FROM toolproperty
154
LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
155
LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
156
LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
157
LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
158
LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
159
WHERE toolproperty.product_id=$product_id
160
AND tooltopic.name='supported'
161
AND arch.name='$arch_name'
162
AND distribution.name='$dist_name'
163
AND vario.name='$vario_name'
164
AND toolproperty.valid=1
165
AND tooltopic.valid=1
166
AND arch_dist_l_vario.valid=1")
167
or die "Can\'t select table toolproperty";
168
$query[2]->execute or die "Can\'t select table toolproperty";
172
while ($x = $query[2]->fetchrow_array) {
173
$result = $x if defined $x;
174
multiple_supportedtopics($dbh,$product_id,$product_name,$arch_name,$dist_name,$vario_name) if $count > 0;
177
$result = "" if not defined $result;
179
if ($result eq "full") {
180
$query[2] = $dbh->prepare("SELECT tooltopic.name,toolproperty.charvalue FROM toolproperty
181
LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
182
LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
183
LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
184
LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
185
LEFT JOIN language ON arch_dist_l_vario.lang_id=language.id
186
LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
187
WHERE arch.name='$arch_name'
188
AND distribution.name='$dist_name'
189
AND vario.name='$vario_name'
190
AND toolproperty.product_id=$product_id
191
AND tooltopic.name != 'supported'
192
AND toolproperty.valid=1
193
AND tooltopic.valid=1
194
AND arch_dist_l_vario.valid=1")
195
or die "Can\'t select table toolproperty";
196
$query[2]->execute or die "Can\'t select table toolproperty";
198
while ( ($tooltopic_name,$charvalue) = ($query[2]->fetchrow_array) ) {
199
if (($charvalue eq "none") || ($charvalue eq "None")) {
202
next if $charvalue eq "";
203
if (!$tooltopics{"$tooltopic_name"}) {
204
$tooltopics{"$tooltopic_name"} = $charvalue;
206
$tooltopics{"$tooltopic_name"} .= ",".$charvalue;
210
write_info $arch_name, $xfree, $has3d, $vId, $dId, $svId, $sdId, $vendor_name, $product_name, \%tooltopics;
220
print "\n\nGenerating x11.hwinfo-files, one for each architecture.\n";
221
mkdir($opt_dir, 0755) || die "\nmkdir: $opt_dir: $!\n" unless -d $opt_dir;
223
print "\nStoring files in \"$opt_dir\"\n\n";
225
$query[0] = $dbh->prepare("SELECT name FROM arch WHERE valid=1")
226
or die "Can\'t select table arch";
227
$query[0]->execute or die "Can\'t select table arch";
228
while ($result = $query[0]->fetchrow_array) {
229
push(@arch_names,$result);
232
# Für jede Architektur wird eine eigene Datei geschrieben
233
foreach $arch_name (@arch_names) {
234
$filename = "$opt_dir/x11.hwinfo.$arch_name";
235
open(FH,"> $filename") or die "Can\'t open $filename";
237
print FH "# x11.hwinfo-file for architecture $arch_name\n";
239
print FH "# generated at: $date\n";
240
print FH "# data source: CDB\n";
241
print FH "# distribution: $dist_name\n";
244
$query[0] = $dbh->prepare("SELECT product.id,product.name,
245
product.vId,product.dId,product.svId,product.sdId,
246
vendor.longname,product.vId,
247
bus.name,subclass.name FROM product
248
LEFT JOIN product_area ON product.id=product_area.product_id
249
LEFT JOIN groups ON product_area.group_id=groups.id
250
LEFT JOIN vendor ON product.vendor_id=vendor.id
251
LEFT JOIN bus ON product.bus_id=bus.id
252
LEFT JOIN subclass ON product.subclass_id=subclass.id
253
WHERE groups.name='graphic-developer'
254
AND product_area.valid=1
255
AND product.valid=1")
256
or die "Can\'t select table product";
257
$query[0]->execute or die "Can\'t select table product";
258
while ( ($product_id,$product_name,$vId,$dId,$svId,$sdId,$vendor_name,$vId,$bus_name,$subclass_name) = ($query[0]->fetchrow_array) ) {
259
# Postinitialisierung, falls undefinierte Werte
260
$vId = "----" if !defined($vId);
261
$dId = "----" if !defined($dId);
262
$svId = "----" if !defined($svId);
263
$sdId = "----" if !defined($sdId);
265
$vId = "" if $vId eq "----";
266
$dId = "" if $dId eq "----";
267
$svId = "" if $svId eq "----";
268
$sdId = "" if $sdId eq "----";
270
# Step 1: Erzeuge Zeilen für XFree 3 ohne 3D
271
# get_info $arch_name, "XFree3";
273
# Step 2: Erzeuge Zeilen für XFree 3 mit 3D
274
# get_info $arch_name, "XFree3 with 3D";
276
# Step 2: Erzeuge Zeilen für XFree 4 ohne 3D
277
get_info $arch_name, "Xorg";
279
# Step 2: Erzeuge Zeilen für XFree 4 mit 3D
280
get_info $arch_name, "Xorg with 3D";
282
} # Ende der Produktschleife
284
} # Ende der Arch-Schleife
289
sub multiple_supportedtopics {
291
my $product_id = shift;
292
my $product_name = shift;
293
my $arch_name = shift;
294
my $dist_name = shift;
295
my $vario_name = shift;
296
my ($query,$id,$value,$name,$time,$htime,%topic,$key,$answer,%key);
301
print "\n *********** Unconsistency registered *******************";
302
print "\nMultiple supported-topics:";
303
print "\nProduct_name: $product_name ID=$product_id";
304
print "\nArch=$arch_name Dist=$dist_name Vario=$vario_name";
307
$query = $handle->prepare("SELECT toolproperty.id,tooltopic.name,
308
toolproperty.charvalue,toolproperty.createtime
310
LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
311
LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
312
LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
313
LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
314
LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
315
WHERE toolproperty.product_id=$product_id
316
AND tooltopic.name='supported'
317
AND toolproperty.valid=1
318
AND arch.name='$arch_name'
319
AND distribution.name='$dist_name'
320
AND vario.name='$vario_name'")
321
or die "Can\'t select table toolproperty";
322
$query->execute or die "Can\'t select table toolproperty";
323
while (($id,$name,$value,$time) = ($query->fetchrow_array)) {
324
$htime = localtime($time);
325
$topic{$id} = $htime." ".$value;
328
foreach $key (sort keys %topic) {
329
$min_key = $key if $key<$min_key;
331
foreach $key (sort keys %topic) {
332
print "\nD toolproperty-ID $key: $topic{$key}" if $key != $min_key;
334
print "\n* toolproperty-ID $min_key:$topic{$min_key}";
335
print "\n\nDeleting doublettes marked with D (* will be left the valid one) [N|y] ?";
338
if ( ($answer eq "y") || ($answer eq "Y") ) {
339
print "\n\nDeleting supported-doublettes.... done\n";
340
foreach $key (keys %topic) {
341
if ($key != $min_key) {
342
$query = $handle->prepare("DELETE FROM toolproperty
344
or die "Can\'t delete from toolproperty";
345
$query->execute or die "Can\'t delete from toolproperty";