~ubuntu-branches/ubuntu/wily/hwinfo/wily

« back to all changes in this revision

Viewing changes to src/ids/cdb_x11

  • Committer: Bazaar Package Importer
  • Author(s): James Vega
  • Date: 2006-11-03 07:28:15 UTC
  • mfrom: (1.2.1 upstream) (3.1.7 edgy)
  • Revision ID: james.westby@ubuntu.com-20061103072815-7g9d6kzk0xn54159
Add cpu.c-alpha_bogo patch, which fixes a FTBFS on alpha because of an
undefined variable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
use Getopt::Long;
 
13
 
 
14
# MySQL-Host / MySQL-User
 
15
my $hostname     = "cdbintern.suse.de";
 
16
my $mysql_user   = "cdbclient";
 
17
my $mysql_passwd = "cdb";
 
18
my $target       = "cdb";
 
19
 
 
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";
 
23
 
 
24
### Log-Handle und STDOUT-Handle auf ungepufferte Ausgabe setzten (schlechtere Performance ;-)
 
25
STDOUT->autoflush();
 
26
 
 
27
 
 
28
my $dist_name = "Stable";
 
29
my $date      = localtime();
 
30
 
 
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);
 
35
 
 
36
my $opt_dir = "tmp";
 
37
 
 
38
 
 
39
# convert to new id format
 
40
sub 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
 
76
sub 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 = $$tt{raw};
 
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";
 
129
    }
 
130
  }
 
131
}
 
132
 
 
133
 
 
134
# get product info and write everything to FH
 
135
sub get_info
 
136
{
 
137
  my ($arch_name, $xfree, $has3d);
 
138
 
 
139
  ($arch_name, $vario_name) = @_;
 
140
 
 
141
  $xfree = $vario_name =~ /XFree3/ ? 3 : 4;
 
142
  $has3d = $vario_name =~ /3D/ ? 1 : 0;
 
143
 
 
144
  $tooltopics{driver} = "";
 
145
  $tooltopics{package} = "";
 
146
  $tooltopics{extension} = "";
 
147
  $tooltopics{option} = "";
 
148
  $tooltopics{resol} = "";
 
149
  $tooltopics{installscript} = "";
 
150
  $tooltopics{raw} = "";
 
151
 
 
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";
 
169
 
 
170
  undef $result;
 
171
  $count = 0;
 
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;
 
175
    $count++;
 
176
  }
 
177
  $result = "" if not defined $result;
 
178
 
 
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"; 
 
197
 
 
198
    while ( ($tooltopic_name,$charvalue) = ($query[2]->fetchrow_array) ) {
 
199
      if (($charvalue eq "none") || ($charvalue eq "None")) {
 
200
          $charvalue = "";
 
201
      }
 
202
      next if $charvalue eq "";
 
203
      if (!$tooltopics{"$tooltopic_name"}) {
 
204
        $tooltopics{"$tooltopic_name"} = $charvalue;
 
205
      } else {
 
206
        $tooltopics{"$tooltopic_name"} .= ",".$charvalue;
 
207
      }
 
208
    }
 
209
 
 
210
    write_info $arch_name, $xfree, $has3d, $vId, $dId, $svId, $sdId, $vendor_name, $product_name, \%tooltopics;
 
211
  }
 
212
}
 
213
 
 
214
 
 
215
GetOptions(
 
216
  'dir=s' => \$opt_dir
 
217
) ;
 
218
 
 
219
 
 
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;
 
222
 
 
223
print "\nStoring files in \"$opt_dir\"\n\n";
 
224
 
 
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);
 
230
}
 
231
 
 
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";
 
236
  print FH "#\n";
 
237
  print FH "# x11.hwinfo-file for architecture $arch_name\n";
 
238
  print FH "#\n";
 
239
  print FH "# generated at: $date\n";
 
240
  print FH "# data source:  CDB\n";
 
241
  print FH "# distribution: $dist_name\n";
 
242
  print FH "#\n\n\n";
 
243
 
 
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);
 
264
 
 
265
    $vId = "" if $vId eq "----";
 
266
    $dId = "" if $dId eq "----";
 
267
    $svId = "" if $svId eq "----";
 
268
    $sdId = "" if $sdId eq "----";
 
269
 
 
270
    # Step 1: Erzeuge Zeilen für XFree 3 ohne 3D
 
271
    # get_info $arch_name, "XFree3";
 
272
 
 
273
    # Step 2: Erzeuge Zeilen für XFree 3 mit 3D
 
274
    # get_info $arch_name, "XFree3 with 3D";
 
275
 
 
276
    # Step 2: Erzeuge Zeilen für XFree 4 ohne 3D
 
277
    get_info $arch_name, "Xorg";
 
278
 
 
279
    # Step 2: Erzeuge Zeilen für XFree 4 mit 3D
 
280
    get_info $arch_name, "Xorg with 3D";
 
281
 
 
282
  } # Ende der Produktschleife
 
283
  close(FH);
 
284
} # Ende der Arch-Schleife
 
285
 
 
286
 
 
287
 
 
288
 
 
289
sub multiple_supportedtopics {
 
290
  my $handle = shift;
 
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);
 
297
 
 
298
  my $min_key = "0";
 
299
  undef %key;
 
300
 
 
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";
 
305
  print "\n";
 
306
  
 
307
    $query = $handle->prepare("SELECT toolproperty.id,tooltopic.name,
 
308
                                   toolproperty.charvalue,toolproperty.createtime
 
309
                             FROM toolproperty
 
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;
 
326
    $min_key = $id;
 
327
  }
 
328
  foreach $key (sort keys %topic) {
 
329
    $min_key = $key if $key<$min_key;
 
330
  }
 
331
  foreach $key (sort keys %topic) {
 
332
    print "\nD toolproperty-ID $key: $topic{$key}" if $key != $min_key;
 
333
  }
 
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] ?";
 
336
  $answer = <STDIN>;
 
337
  chop($answer);
 
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
 
343
                                WHERE id=$key")
 
344
          or die "Can\'t delete from toolproperty";
 
345
        $query->execute or die "Can\'t delete from toolproperty";
 
346
      }
 
347
    }
 
348
  }
 
349
  return;
 
350
}
 
351