This commit was manufactured by cvs2svn to create tag
[opensuse:hwinfo.git] / src / ids / cdb_x11
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
9 use DBI;
10 use strict;
11 use IO::Handle;
12
13 # MySQL-Host / MySQL-User
14 my $hostname     = "Jackson.suse.de";
15 my $mysql_user   = "cdbclient";
16 my $mysql_passwd = "cdb";
17 my $target       = "cdb";
18
19 my $driver       = DBI->install_driver('mysql');
20 my $dbh          = DBI->connect('DBI:mysql:'.$target.':'.$hostname,$mysql_user,$mysql_passwd)
21   or die "Can't connect to the MySQL Database, table $target";
22
23 ### Log-Handle und STDOUT-Handle auf ungepufferte Ausgabe setzten (schlechtere Performance ;-)
24 STDOUT->autoflush();
25
26
27 my $dist_name = "Stable";
28 #my $PATH      = '/suse/dhess/Export/';
29 my $PATH      = $ENV{HOME}."/";
30 my $date      = localtime();
31
32 my (@query,$x,$result,$arch_name,@arch_names,$filename,$count);
33 my ($product_id,$product_name,$product_class,$vendor_name,$vendor_class,$bus_name,$subclass_name);
34 my ($subproduct_id,$subproduct_class,$subvendor_class,$subproduct_name,$subvendor_name);
35 my (%tooltopics,$tooltopic_name,$vario_name,$charvalue);
36 my (@raw,$raw);
37
38 # convert to new id format
39 sub new_id
40 {
41   my ($old_id, $id_class, $tag, $id);
42
43   ($old_id, $id_class) = @_;
44
45   if($old_id =~ /^([us]?)(\S{4})$/) {
46     $tag = $1;
47     $id = $2;
48   }
49   else {
50     die "invalid id format: \"$old_id\"\n";
51   }
52
53   if($tag eq "" && $id_class && $id_class =~ /^([us]?)(\S{4})$/) {
54     $tag = $1;
55   }
56
57   if($tag eq "s") {
58     $tag = "special ";
59   }
60   elsif($tag eq "u") {
61     $tag = "usb ";
62   }
63   elsif($tag eq "") {
64     $tag = "pci ";
65   }
66   else {
67     die "invalid id format: \"$old_id\"\n";
68   }
69
70   return "${tag}0x$id";
71 }
72
73
74 print "\n\nGenerating x11.hwinfo-files, one for each architecture.\n";
75 =head1
76 print "\nStoring files under $PATH [Y|n]? ";
77 $result = <STDIN>;
78 chop($result);
79 if (($result eq "n") || ($result eq "N")) {
80   print "\n\nPlease enter directory for storing the generated files (e.g. ~/Test): ";
81   $result = <STDIN>;
82   chop($result);
83   if (!($result =~ /\/$/)) {
84     $result .= "/";
85   }
86   if ($result =~ /^\~/) {
87     $PATH =~ s/\/$//;
88     $result =~ s/\~/$PATH/;
89   }
90   $PATH = $result;
91 }
92 =cut
93 $PATH = "tmp/";
94 mkdir $PATH, 0755;
95
96 print "\nStoring files under $PATH\n\n";
97
98 $query[0] = $dbh->prepare("SELECT name FROM arch WHERE valid=1")
99   or die "Can\'t select table arch";
100 $query[0]->execute or die "Can\'t select table arch";
101 while ($result = $query[0]->fetchrow_array) {
102   push(@arch_names,$result);
103 }
104
105 # Für jede Architektur wird eine eigene Datei geschrieben
106 foreach $arch_name (@arch_names) {
107   $filename = $PATH.'x11.hwinfo.'.$arch_name;
108   open(FH,"> $filename") or die "Can\'t open $filename";
109   print FH "#\n";
110   print FH "# x11.hwinfo-file for architecture $arch_name\n";
111   print FH "#\n";
112   print FH "# generated at: $date\n";
113   print FH "# data source:  CDB\n";
114   print FH "# distribution: $dist_name\n";
115   print FH "#\n\n\n";
116
117   $query[0] = $dbh->prepare("SELECT product.id,product.name,product.deviceclass,
118                                     vendor.longname,vendorclass.class,
119                                     bus.name,subclass.name FROM product
120                                LEFT JOIN product_area ON product.id=product_area.product_id
121                                LEFT JOIN groups ON product_area.group_id=groups.id
122                                LEFT JOIN vendor ON product.vendor_id=vendor.id
123                                LEFT JOIN vendorclass ON product.vendorclass_id=vendorclass.id
124                                LEFT JOIN bus ON product.bus_id=bus.id
125                                LEFT JOIN subclass ON product.subclass_id=subclass.id
126                                 WHERE groups.name='graphic-developer'
127                                   AND product_area.valid=1
128                                   AND product.valid=1")
129     or die "Can\'t select table product";
130   $query[0]->execute or die "Can\'t select table product";
131   while ( ($product_id,$product_name,$product_class,
132            $vendor_name,$vendor_class,
133              $bus_name,$subclass_name) = ($query[0]->fetchrow_array) ) {
134     $subproduct_class = $subvendor_class = "";
135     $query[1] = $dbh->prepare("SELECT product_id FROM product_subproduct 
136                                  WHERE subproduct_id=$product_id
137                                    AND valid=1")
138       or die "Can\'t select table product_subproduct";
139     $query[1]->execute or die "Can\'t select table product_subproduct";
140     if ( ($subproduct_id = $query[1]->fetchrow_array)) {
141       $query[2] = $dbh->prepare("SELECT product.deviceclass,vendorclass.class,product.name,vendor.longname FROM product
142                                    LEFT JOIN vendorclass ON product.vendorclass_id=vendorclass.id
143                                    LEFT JOIN vendor ON product.vendor_id=vendor.id
144                                    WHERE product.id=$subproduct_id
145                                      AND product.valid=1
146                                      AND vendorclass.valid=1")
147         or die "Can\'t select table product";
148       $query[2]->execute or die "Can\'t select table product";
149       ($subproduct_class,$subvendor_class,$subproduct_name,$subvendor_name) = ($query[2]->fetchrow_array);
150       if (($subproduct_class eq "") || ($subvendor_class eq "")) {
151         $subproduct_class = '????' if $subproduct_class eq "";
152         $subvendor_class = '????' if $subvendor_class eq "";
153         print "\n\n!!No valid vendor and/or deviceID for maindevice:\n";
154         print "\nMaindevice: $subvendor_class $subproduct_class $subvendor_name $subproduct_name (primary index = $subproduct_id)\n";
155         die "Subdevice: $vendor_class $product_class $vendor_name $product_name (primary index = $product_id)\n\n";
156       }
157     }
158
159     # Step 1: Erzeuge Zeilen für XFree 3 ohne 3D
160     $vario_name = 'XFree3';
161     $tooltopics{driver} = "";
162     $tooltopics{package} = "";
163     $tooltopics{extension} = "";
164     $tooltopics{option} = "";
165     $tooltopics{resol} = "";
166     $tooltopics{installscript} = "";
167     $tooltopics{raw} = "";
168
169     # Product supported=full?
170     $query[2] = $dbh->prepare("SELECT toolproperty.charvalue FROM toolproperty
171                                    LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
172                                    LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
173                                    LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
174                                    LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
175                                    LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
176                                    WHERE toolproperty.product_id=$product_id
177                                      AND tooltopic.name='supported'
178                                      AND arch.name='$arch_name'
179                                      AND distribution.name='$dist_name'
180                                      AND vario.name='$vario_name'
181                                      AND toolproperty.valid=1
182                                      AND tooltopic.valid=1
183                                      AND arch_dist_l_vario.valid=1")
184       or die "Can\'t select table toolproperty";
185     $query[2]->execute or die "Can\'t select table toolproperty";
186     undef $result;
187     $count = 0;
188     while ($x = $query[2]->fetchrow_array) {
189       $result = $x if defined $x;
190       multiple_supportedtopics($dbh,$product_id,$product_name,$arch_name,$dist_name,$vario_name) if $count > 0;
191       $count++;
192     }
193     $result = "" if not defined $result;
194     
195     if ($result eq "full") {
196       $query[2] = $dbh->prepare("SELECT tooltopic.name,toolproperty.charvalue FROM toolproperty
197                                    LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
198                                    LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
199                                    LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
200                                    LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
201                                    LEFT JOIN language ON arch_dist_l_vario.lang_id=language.id
202                                    LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
203                                      WHERE arch.name='$arch_name'
204                                        AND distribution.name='$dist_name'
205                                        AND vario.name='$vario_name'
206                                        AND toolproperty.product_id=$product_id
207                                        AND tooltopic.name != 'supported'
208                                        AND toolproperty.valid=1
209                                        AND tooltopic.valid=1
210                                        AND arch_dist_l_vario.valid=1")
211         or die "Can\'t select table toolproperty";
212         $query[2]->execute or die "Can\'t select table toolproperty"; 
213       while ( ($tooltopic_name,$charvalue) = ($query[2]->fetchrow_array) ) {
214         if (($charvalue eq "none") || ($charvalue eq "None")){
215           $charvalue = "";
216         }
217         next if $charvalue eq "";
218         if ($tooltopics{"$tooltopic_name"} eq "") {
219           $tooltopics{"$tooltopic_name"} = $charvalue;
220           } else {
221             $tooltopics{"$tooltopic_name"} .= ",".$charvalue;
222           }
223       }
224       if ( ($vendor_class ne "") && ($product_class ne "") ) {
225           print FH "\n vendor.id\t\t${\new_id $vendor_class}\n";
226           print FH "+vendor.name\t\t$vendor_name\n";
227           if ( ($subvendor_class ne "") && ($subproduct_class ne "") ) {
228             print FH "\n vendor.id\t\t${\new_id $subvendor_class, $vendor_class}\n";
229             print FH "&device.id\t\t${\new_id $subproduct_class, $vendor_class}\n";
230             print FH "&subvendor.id\t\t${\new_id $vendor_class}\n";
231             print FH "&subdevice.id\t\t${\new_id $product_class, $vendor_class}\n";
232             print FH "+subdevice.name\t\t$product_name\n";
233           } else {
234             print FH "\n vendor.id\t\t${\new_id $vendor_class}\n";
235             print FH "&device.id\t\t${\new_id $product_class, $vendor_class}\n";
236             print FH "+device.name\t\t$product_name\n";
237           }
238         if ($tooltopics{resol} ne "") {
239           $tooltopics{resol} =~ s/bpp//g;
240           }
241         
242         # Teste ob mehr als ein driver- oder installscript-topic vorhanden ist:
243         if (($tooltopics{driver} =~ /,/) || ($tooltopics{installscript} =~ /,/)) {
244           
245           die "\nMore than one driver- or installscript-topic. Product-id=$product_id. Vario=$vario_name. Arch=$arch_name.\n";
246         }
247         
248         print FH "+driver.xfree\t\t3|$tooltopics{driver}||$tooltopics{package}|$tooltopics{extension}|$tooltopics{option}|$tooltopics{resol}||$tooltopics{installscript}|\n";
249         if ($tooltopics{raw} ne "") {
250           @raw = (split(',',$tooltopics{raw}));
251           foreach $raw (@raw) {
252             print FH "+driver.xfree.config\t$raw\n";
253           }
254         }
255         
256       }
257     } # Ende XFree3 ohne 3D
258 # ----------------------------------------------------------------------------------------------------------------------------
259     # Step 2: Erzeuge Zeilen für XFree 3 mit 3D
260     $vario_name = 'XFree3 with 3D';
261     $tooltopics{driver} = "";
262     $tooltopics{package} = "";
263     $tooltopics{extension} = "";
264     $tooltopics{option} = "";
265     $tooltopics{resol} = "";
266     $tooltopics{installscript} = "";
267     $tooltopics{raw} = "";
268
269     # Product supported=full?
270     $query[2] = $dbh->prepare("SELECT toolproperty.charvalue FROM toolproperty
271                                    LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
272                                    LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
273                                    LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
274                                    LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
275                                    LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
276                                    WHERE toolproperty.product_id=$product_id
277                                      AND tooltopic.name='supported'
278                                      AND arch.name='$arch_name'
279                                      AND distribution.name='$dist_name'
280                                      AND vario.name='$vario_name'
281                                      AND toolproperty.valid=1
282                                      AND tooltopic.valid=1
283                                      AND arch_dist_l_vario.valid=1")
284       or die "Can\'t select table toolproperty";
285     $query[2]->execute or die "Can\'t select table toolproperty";
286     undef $result;
287     $count = 0;
288     while ($x = $query[2]->fetchrow_array) {
289       $result = $x if defined $x;
290       multiple_supportedtopics($dbh,$product_id,$product_name,$arch_name,$dist_name,$vario_name) if $count > 0;
291         $count++;
292     }
293     $result = "" if not defined $result;
294     
295     if ($result eq "full") {
296       $query[2] = $dbh->prepare("SELECT tooltopic.name,toolproperty.charvalue FROM toolproperty
297                                    LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
298                                    LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
299                                    LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
300                                    LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
301                                    LEFT JOIN language ON arch_dist_l_vario.lang_id=language.id
302                                    LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
303                                      WHERE arch.name='$arch_name'
304                                        AND distribution.name='$dist_name'
305                                        AND vario.name='$vario_name'
306                                        AND toolproperty.product_id=$product_id
307                                        AND tooltopic.name != 'supported'
308                                        AND toolproperty.valid=1
309                                        AND tooltopic.valid=1
310                                        AND arch_dist_l_vario.valid=1")
311         or die "Can\'t select table toolproperty";
312       $query[2]->execute or die "Can\'t select table toolproperty"; 
313       while ( ($tooltopic_name,$charvalue) = ($query[2]->fetchrow_array) ) {
314         if (($charvalue eq "none") || ($charvalue eq "None")){
315             $charvalue = "";
316           }
317         next if $charvalue eq "";
318         if ($tooltopics{"$tooltopic_name"} eq "") {
319           $tooltopics{"$tooltopic_name"} = $charvalue;
320         } else {
321           $tooltopics{"$tooltopic_name"} .= ",".$charvalue;
322         }
323       }
324       if ( ($vendor_class ne "") && ($product_class ne "") ) {
325           print FH "\n vendor.id\t\t${\new_id $vendor_class}\n";
326           print FH "+vendor.name\t\t$vendor_name\n";
327           if ( ($subvendor_class ne "") && ($subproduct_class ne "") ) {
328             print FH "\n vendor.id\t\t${\new_id $subvendor_class, $vendor_class}\n";
329             print FH "&device.id\t\t${\new_id $subproduct_class, $vendor_class}\n";
330             print FH "&subvendor.id\t\t${\new_id $vendor_class}\n";
331             print FH "&subdevice.id\t\t${\new_id $product_class, $vendor_class}\n";
332             print FH "+subdevice.name\t\t$product_name\n";
333           } else {
334             print FH "\n vendor.id\t\t${\new_id $vendor_class}\n";
335             print FH "&device.id\t\t${\new_id $product_class, $vendor_class}\n";
336             print FH "+device.name\t\t$product_name\n";
337           }
338           if ($tooltopics{resol} ne "") {
339             $tooltopics{resol} =~ s/bpp//g;
340           }
341
342           # Teste ob mehr als ein driver- oder installscript-topic vorhanden ist:
343           if (($tooltopics{driver} =~ /,/) || ($tooltopics{installscript} =~ /,/)) {
344             die "\nMore than one driver- or installscript-topic. Product-id=$product_id. Vario=$vario_name. Arch=$arch_name.\n";
345           }
346           
347           print FH "+driver.xfree\t\t3|$tooltopics{driver}|3d|$tooltopics{package}|$tooltopics{extension}|$tooltopics{option}|$tooltopics{resol}||$tooltopics{installscript}|\n";
348           if ($tooltopics{raw} ne "") {
349             @raw = (split(',',$tooltopics{raw}));
350             foreach $raw (@raw) {
351               print FH "+driver.xfree.config\t$raw\n";
352             }
353           }
354         }
355     } # Ende XFree3 + 3D
356 # ----------------------------------------------------------------------------------------------------------------------------
357     # Step 2: Erzeuge Zeilen für XFree 4 ohne 3D
358     $vario_name = 'XFree4';
359     $tooltopics{driver} = "";
360     $tooltopics{package} = "";
361     $tooltopics{extension} = "";
362     $tooltopics{option} = "";
363     $tooltopics{resol} = "";
364     $tooltopics{installscript} = "";
365     $tooltopics{raw} = "";
366     
367     # Product supported=full?
368       $query[2] = $dbh->prepare("SELECT toolproperty.charvalue FROM toolproperty
369                                    LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
370                                    LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
371                                    LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
372                                    LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
373                                    LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
374                                    WHERE toolproperty.product_id=$product_id
375                                      AND tooltopic.name='supported'
376                                      AND arch.name='$arch_name'
377                                      AND distribution.name='$dist_name'
378                                      AND vario.name='$vario_name'
379                                      AND toolproperty.valid=1
380                                      AND tooltopic.valid=1
381                                      AND arch_dist_l_vario.valid=1")
382         or die "Can\'t select table toolproperty";
383     $query[2]->execute or die "Can\'t select table toolproperty";
384     undef $result;
385     $count = 0;
386     while ($x = $query[2]->fetchrow_array) {
387       $result = $x if defined $x;
388       multiple_supportedtopics($dbh,$product_id,$product_name,$arch_name,$dist_name,$vario_name) if $count > 0;
389       $count++;
390     }
391     $result = "" if not defined $result;
392     
393     if ($result eq "full") {
394       $query[2] = $dbh->prepare("SELECT tooltopic.name,toolproperty.charvalue FROM toolproperty
395                                    LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
396                                    LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
397                                    LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
398                                    LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
399                                    LEFT JOIN language ON arch_dist_l_vario.lang_id=language.id
400                                    LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
401                                      WHERE arch.name='$arch_name'
402                                        AND distribution.name='$dist_name'
403                                        AND vario.name='$vario_name'
404                                        AND toolproperty.product_id=$product_id
405                                        AND tooltopic.name != 'supported'
406                                        AND toolproperty.valid=1
407                                        AND tooltopic.valid=1
408                                        AND arch_dist_l_vario.valid=1")
409         or die "Can\'t select table toolproperty";
410       $query[2]->execute or die "Can\'t select table toolproperty"; 
411       while ( ($tooltopic_name,$charvalue) = ($query[2]->fetchrow_array) ) {
412         if (($charvalue eq "none") || ($charvalue eq "None")){
413           $charvalue = "";
414         }
415         next if $charvalue eq "";
416         if ($tooltopics{"$tooltopic_name"} eq "") {
417           $tooltopics{"$tooltopic_name"} = $charvalue;
418         } else {
419           $tooltopics{"$tooltopic_name"} .= ",".$charvalue;
420         }
421         }
422       if ( ($vendor_class ne "") && ($product_class ne "") ) {
423         print FH "\n vendor.id\t\t${\new_id $vendor_class}\n";
424         print FH "+vendor.name\t\t$vendor_name\n";
425         if ( ($subvendor_class ne "") && ($subproduct_class ne "") ) {
426           print FH "\n vendor.id\t\t${\new_id $subvendor_class, $vendor_class}\n";
427           print FH "&device.id\t\t${\new_id $subproduct_class, $vendor_class}\n";
428           print FH "&subvendor.id\t\t${\new_id $vendor_class}\n";
429           print FH "&subdevice.id\t\t${\new_id $product_class, $vendor_class}\n";
430           print FH "+subdevice.name\t\t$product_name\n";
431         } else {
432           print FH "\n vendor.id\t\t${\new_id $vendor_class}\n";
433           print FH "&device.id\t\t${\new_id $product_class, $vendor_class}\n";
434           print FH "+device.name\t\t$product_name\n";
435         }
436         if ($tooltopics{resol} ne "") {
437           $tooltopics{resol} =~ s/bpp//g;
438         }
439         
440         # Teste ob mehr als ein driver- oder installscript-topic vorhanden ist:
441         if (($tooltopics{driver} =~ /,/) || ($tooltopics{installscript} =~ /,/)) {
442             die "\nMore than one driver- or installscript-topic. Product-id=$product_id. Vario=$vario_name. Arch=$arch_name.\n";
443           }
444         
445         print FH "+driver.xfree\t\t4|$tooltopics{driver}||$tooltopics{package}|$tooltopics{extension}|$tooltopics{option}|$tooltopics{resol}||$tooltopics{installscript}|\n";
446         if ($tooltopics{raw} ne "") {
447           @raw = (split(',',$tooltopics{raw}));
448           foreach $raw (@raw) {
449             print FH "+driver.xfree.config\t$raw\n";
450           }
451         }
452       }
453     } # Ende XFree4 ohne 3D
454 # ----------------------------------------------------------------------------------------------------------------------------
455     # Step 2: Erzeuge Zeilen für XFree 4 mit 3D
456     $vario_name = 'XFree4 with 3D';
457     $tooltopics{driver} = "";
458     $tooltopics{package} = "";
459     $tooltopics{extension} = "";
460     $tooltopics{option} = "";
461     $tooltopics{resol} = "";
462     $tooltopics{installscript} = "";
463     $tooltopics{raw} = "";
464     
465     # Product supported=full?
466     $query[2] = $dbh->prepare("SELECT toolproperty.charvalue FROM toolproperty
467                                    LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
468                                    LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
469                                    LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
470                                    LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
471                                    LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
472                                    WHERE toolproperty.product_id=$product_id
473                                      AND tooltopic.name='supported'
474                                      AND arch.name='$arch_name'
475                                      AND distribution.name='$dist_name'
476                                      AND vario.name='$vario_name'
477                                      AND toolproperty.valid=1
478                                      AND tooltopic.valid=1
479                                      AND arch_dist_l_vario.valid=1")
480       or die "Can\'t select table toolproperty";
481     $query[2]->execute or die "Can\'t select table toolproperty";
482     undef $result;
483     $count = 0;
484     while ($x = $query[2]->fetchrow_array) {
485       $result = $x if defined $x;
486       multiple_supportedtopics($dbh,$product_id,$product_name,$arch_name,$dist_name,$vario_name) if $count > 0;
487       $count++;
488     }
489       $result = "" if not defined $result;
490     
491     if ($result eq "full") {
492       $query[2] = $dbh->prepare("SELECT tooltopic.name,toolproperty.charvalue FROM toolproperty
493                                    LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
494                                    LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
495                                    LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
496                                    LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
497                                    LEFT JOIN language ON arch_dist_l_vario.lang_id=language.id
498                                    LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
499                                      WHERE arch.name='$arch_name'
500                                        AND distribution.name='$dist_name'
501                                        AND vario.name='$vario_name'
502                                        AND toolproperty.product_id=$product_id
503                                        AND tooltopic.name != 'supported'
504                                        AND toolproperty.valid=1
505                                        AND tooltopic.valid=1
506                                        AND arch_dist_l_vario.valid=1")
507         or die "Can\'t select table toolproperty";
508       $query[2]->execute or die "Can\'t select table toolproperty"; 
509       while ( ($tooltopic_name,$charvalue) = ($query[2]->fetchrow_array) ) {
510         if (($charvalue eq "none") || ($charvalue eq "None")){
511           $charvalue = "";
512         }
513         next if $charvalue eq "";
514         if ($tooltopics{"$tooltopic_name"} eq "") {
515           $tooltopics{"$tooltopic_name"} = $charvalue;
516         } else {
517           $tooltopics{"$tooltopic_name"} .= ",".$charvalue;
518           }
519       }
520       if ( ($vendor_class ne "") && ($product_class ne "") ) {
521         print FH "\n vendor.id\t\t${\new_id $vendor_class}\n";
522         print FH "+vendor.name\t\t$vendor_name\n";
523         if ( ($subvendor_class ne "") && ($subproduct_class ne "") ) {
524           print FH "\n vendor.id\t\t${\new_id $subvendor_class, $vendor_class}\n";
525           print FH "&device.id\t\t${\new_id $subproduct_class, $vendor_class}\n";
526           print FH "&subvendor.id\t\t${\new_id $vendor_class}\n";
527           print FH "&subdevice.id\t\t${\new_id $product_class, $vendor_class}\n";
528           print FH "+subdevice.name\t\t$product_name\n";
529         } else {
530           print FH "\n vendor.id\t\t${\new_id $vendor_class}\n";
531           print FH "&device.id\t\t${\new_id $product_class, $vendor_class}\n";
532           print FH "+device.name\t\t$product_name\n";
533         }
534         if ($tooltopics{resol} ne "") {
535           $tooltopics{resol} =~ s/bpp//g;
536         }
537         
538         # Teste ob mehr als ein driver- oder installscript-topic vorhanden ist:
539           if (($tooltopics{driver} =~ /,/) || ($tooltopics{installscript} =~ /,/)) {
540             die "\nMore than one driver- or installscript-topic. Product-id=$product_id. Vario=$vario_name. Arch=$arch_name.\n";
541           }
542         
543         print FH "+driver.xfree\t\t4|$tooltopics{driver}|3d|$tooltopics{package}|$tooltopics{extension}|$tooltopics{option}|$tooltopics{resol}||$tooltopics{installscript}|\n";
544         if ($tooltopics{raw} ne "") {
545           @raw = (split(',',$tooltopics{raw}));
546           foreach $raw (@raw) {
547             print FH "+driver.xfree.config\t$raw\n";
548           }
549         }
550       }
551     } # Ende XFree4 + 3D
552   } # Ende der Produktschleife
553   close(FH);
554 } # Ende der Arch-Schleife
555
556
557
558
559 sub multiple_supportedtopics {
560   my $handle = shift;
561   my $product_id = shift;
562   my $product_name = shift;
563   my $arch_name = shift;
564   my $dist_name = shift;
565   my $vario_name = shift;
566   my ($query,$id,$value,$name,$time,$htime,%topic,$key,$answer,%key);
567
568   my $min_key = "0";
569   undef %key;
570
571   print "\n    *********** Unconsistency registered *******************";
572   print "\nMultiple supported-topics:";
573   print "\nProduct_name: $product_name  ID=$product_id";
574   print "\nArch=$arch_name Dist=$dist_name Vario=$vario_name";
575   print "\n";
576   
577     $query = $handle->prepare("SELECT toolproperty.id,tooltopic.name,
578                                    toolproperty.charvalue,toolproperty.createtime
579                              FROM toolproperty
580                               LEFT JOIN tooltopic ON toolproperty.tooltopic_id=tooltopic.id
581                               LEFT JOIN arch_dist_l_vario ON toolproperty.arch_dist_l_vario_id=arch_dist_l_vario.id
582                               LEFT JOIN arch ON arch_dist_l_vario.arch_id=arch.id
583                               LEFT JOIN distribution ON arch_dist_l_vario.distribution_id=distribution.id
584                               LEFT JOIN vario ON arch_dist_l_vario.vario_id=vario.id
585                               WHERE toolproperty.product_id=$product_id
586                                 AND tooltopic.name='supported'
587                                 AND toolproperty.valid=1
588                                 AND arch.name='$arch_name'
589                                 AND distribution.name='$dist_name'
590                                 AND vario.name='$vario_name'")
591       or die "Can\'t select table toolproperty";
592     $query->execute or die "Can\'t select table toolproperty";
593   while (($id,$name,$value,$time) = ($query->fetchrow_array)) {
594     $htime = localtime($time);
595     $topic{$id} = $htime."  ".$value;
596     $min_key = $id;
597   }
598   foreach $key (sort keys %topic) {
599     $min_key = $key if $key<$min_key;
600   }
601   foreach $key (sort keys %topic) {
602     print "\nD toolproperty-ID $key: $topic{$key}" if $key != $min_key;
603   }
604   print "\n* toolproperty-ID $min_key:$topic{$min_key}";
605   print "\n\nDeleting doublettes marked with D (* will be left the valid one) [N|y] ?";
606   $answer = <STDIN>;
607   chop($answer);
608   if ( ($answer eq "y") || ($answer eq "Y") ) {
609     print "\n\nDeleting supported-doublettes.... done\n";
610     foreach $key (keys %topic) {
611       if ($key != $min_key) {
612         $query = $handle->prepare("DELETE FROM toolproperty
613                                 WHERE id=$key")
614           or die "Can\'t delete from toolproperty";
615         $query->execute or die "Can\'t delete from toolproperty";
616       }
617     }
618   }
619   return;
620 }
621