/usr/share/doc/elektra-doc/scripts/convert-hwconfKudzu is in elektra-doc 0.7.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | #!/usr/bin/perl
########################################################################
##
## This script will create a registry tree based on the detected HW
## located in /etc/sysconfig/hwconf. That file is parsed and
## re-generated at every boot by kudzu.
##
## This script must calculate a unique ID for each device. It can't
## be sequential because sequence may change. It can't be only the
## description of device, because you may have 2 identical devices.
##
## It will generate 2 trees for faster searches:
## system/hw/byClass and
## system/hw/byBus
## The entries in the second tree are links to the first.
##
## The correct way to run it is:
##
## bash# ./hwconfKudzu-convert | sh -e
##
##
## To make tests you can do:
##
## bash$ ROOT=user/test ./hwconfKudzu-convert | sh -e
##
## Avi Alkalay <avi@unix.sh>
## Apr 2004
##
## $Id$
##
########################################################################
$HWFILE="/etc/sysconfig/hwconf";
$ROOT="system/hw";
$RG="kdb";
sub printEntry {
if (%entry) {
$entry{desc}=~s/^\"(.*)\"$/$1/; # remove "
$uniqDevID=$entry{desc};
$uniqDevID=~s/[\W|\s]*//g;
if (defined($entry{pcifn})) {
$uniqDevID.=$entry{pcifn};
} elsif (defined($entry{usbbus})) {
$uniqDevID.=$entry{usbbus};
} elsif (defined($entry{device})) {
$uniqDevID.=$entry{device};
} else {
printf STDERR "Can't calculate unique identifier for \"$entry{desc}\"\n";
return;
}
# Some escaping and treatments
$entry{desc}=~s/\'/\\'/g; # escape '
$entry{desc}=~s/\"/\\"/g; # escape "
$entry{desc}=~s/\(/\\\(/g; # escape (
$entry{desc}=~s/\)/\\\)/g; # escape )
$entry{desc}=~s/\|/\\\|/g; # escape |
$entry{desc}=~s/\#/\\\#/g; # escape #
foreach $key (keys(%entry)) {
print("$RG set $ROOT/byClass/$entry{class}/$uniqDevID/$key " );
print("-- $entry{$key}\n");
}
# Make link for the 'byBus' tree
# print("$RG set -t dir \"$ROOT/byBus/$entry{bus}\"\n");
print("$RG ln \"$ROOT/byClass/$entry{class}/$uniqDevID\" \"$ROOT/byBus/$entry{bus}/$uniqDevID\"\n\n");
}
}
open(HWFILE);
while(<HWFILE>) {
SWITCH: {
if (/^-$/) {
printEntry(%entry);
undef(%entry);
last SWITCH;
}
# if (/^class\:\s*(.*)/) {
# $entry{class}=$1;
# last SWITCH;
# }
# if (/^bus\:\s*(.*)/) {
# $entry{bus}=$1;
# last SWITCH;
# }
/(.*)\:\s+(.*)/;
$entry{$1}=$2;
}
}
close(HWFILE);
# Handle last entry
printEntry(%entry);
|