3 ########################################################################
5 ## This script will create a registry tree based on the detected HW
6 ## located in /etc/sysconfig/hwconf. That file is parsed and
7 ## re-generated at every boot by kudzu.
9 ## This script must calculate a unique ID for each device. It can't
10 ## be sequential because sequence may change. It can't be only the
11 ## description of device, because you may have 2 identical devices.
13 ## It will generate 2 trees for faster searches:
14 ## system/hw/byClass and
16 ## The entries in the second tree are links to the first.
18 ## The correct way to run it is:
20 ## bash# ./hwconfKudzu-convert | sh -e
23 ## To make tests you can do:
25 ## bash$ ROOT=user/test ./hwconfKudzu-convert | sh -e
27 ## Avi Alkalay <avi@unix.sh>
32 ########################################################################
35 $HWFILE="/etc/sysconfig/hwconf";
43 $entry{desc}=~s/^\"(.*)\"$/$1/; # remove "
45 $uniqDevID=$entry{desc};
46 $uniqDevID=~s/[\W|\s]*//g;
47 if (defined($entry{pcifn})) {
48 $uniqDevID.=$entry{pcifn};
49 } elsif (defined($entry{usbbus})) {
50 $uniqDevID.=$entry{usbbus};
51 } elsif (defined($entry{device})) {
52 $uniqDevID.=$entry{device};
54 printf STDERR "Can't calculate unique identifier for \"$entry{desc}\"\n";
58 # Some escaping and treatments
59 $entry{desc}=~s/\'/\\'/g; # escape '
60 $entry{desc}=~s/\"/\\"/g; # escape "
61 $entry{desc}=~s/\(/\\\(/g; # escape (
62 $entry{desc}=~s/\)/\\\)/g; # escape )
63 $entry{desc}=~s/\|/\\\|/g; # escape |
64 $entry{desc}=~s/\#/\\\#/g; # escape #
66 foreach $key (keys(%entry)) {
67 print("$RG set $ROOT/byClass/$entry{class}/$uniqDevID/$key " );
68 print("-- $entry{$key}\n");
71 # Make link for the 'byBus' tree
72 # print("$RG set -t dir \"$ROOT/byBus/$entry{bus}\"\n");
73 print("$RG ln \"$ROOT/byClass/$entry{class}/$uniqDevID\" \"$ROOT/byBus/$entry{bus}/$uniqDevID\"\n\n");
88 # if (/^class\:\s*(.*)/) {
92 # if (/^bus\:\s*(.*)/) {