| 1 |
#!/usr/bin/ruby |
| 2 |
|
| 3 |
# |
| 4 |
# NVRAM WakeUp - Add new board to yaml database |
| 5 |
# |
| 6 |
# Copyright (c) 2008 Tobias Grimm |
| 7 |
# |
| 8 |
# $Id$ |
| 9 |
# This program is free software; you can redistribute it and/or modify |
| 10 |
# it under the terms of the GNU General Public License as published by |
| 11 |
# the Free Software Foundation; either version 2 of the License, or |
| 12 |
# (at your option) any later version. |
| 13 |
# |
| 14 |
# This program is distributed in the hope that it will be useful, |
| 15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 |
# GNU General Public License for more details. |
| 18 |
# |
| 19 |
# You should have received a copy of the GNU General Public License along |
| 20 |
# with this program; if not, write to the Free Software Foundation, Inc., |
| 21 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 22 |
# |
| 23 |
|
| 24 |
require 'yaml' |
| 25 |
require 'pp' |
| 26 |
require 'keys' |
| 27 |
|
| 28 |
dmi = {} |
| 29 |
infowriter = {} |
| 30 |
|
| 31 |
def dump_settings(infowriter) |
| 32 |
for key_value in @biosinfo_keys |
| 33 |
if infowriter[key_value] |
| 34 |
puts "#{key_value} = #{infowriter[key_value]}" |
| 35 |
end |
| 36 |
end |
| 37 |
end |
| 38 |
|
| 39 |
for line in File.new(ARGV[0], 'r') |
| 40 |
if line =~ /(Mainboard|BIOS) ([^:]*):\s*"(.*)"\s*$/ |
| 41 |
key = $2 |
| 42 |
key = 'bios' + key if $1 == 'BIOS' |
| 43 |
key = 'version' if key == 'revision' |
| 44 |
value = $3 |
| 45 |
dmi[key] = value |
| 46 |
end |
| 47 |
if line =~ /\s*([^ ]*)\s*=\s*([^ ]*)\s*/ |
| 48 |
infowriter[$1]=$2.chomp |
| 49 |
end |
| 50 |
end |
| 51 |
|
| 52 |
boards = YAML.load(File.new('boards.yaml', 'r')) |
| 53 |
|
| 54 |
for board in boards |
| 55 |
if board.slice(@dmi_keys) == dmi |
| 56 |
puts "The list of boards already contains one with the same DMI identifier" |
| 57 |
if board.slice(@biosinfo_keys) == infowriter |
| 58 |
puts "...and with the same settings" |
| 59 |
else |
| 60 |
puts "...but with different settings" |
| 61 |
puts "Original settings:" |
| 62 |
dump_settings board |
| 63 |
puts |
| 64 |
puts "New settings:" |
| 65 |
dump_settings infowriter |
| 66 |
end |
| 67 |
exit 1 |
| 68 |
end |
| 69 |
end |
| 70 |
|
| 71 |
iw_name='AUTO' |
| 72 |
|
| 73 |
for board in boards |
| 74 |
if board.slice(@biosinfo_keys) == infowriter |
| 75 |
iw_name = board.infowriter |
| 76 |
puts "Matching infowriter: #{board.infowriter}" |
| 77 |
break |
| 78 |
end |
| 79 |
end |
| 80 |
|
| 81 |
puts "- vendor : '#{dmi.vendor}'" |
| 82 |
puts " type : '#{dmi['type']}'" |
| 83 |
puts " version : '#{dmi.version}'" |
| 84 |
puts " biosvendor : '#{dmi.biosvendor}'" |
| 85 |
puts " biosversion : '#{dmi.biosversion}'" |
| 86 |
puts " biosrelease : '#{dmi.biosrelease}'" |
| 87 |
puts " infowriter : '#{iw_name}'" |
| 88 |
|
| 89 |
for key in @biosinfo_keys |
| 90 |
if infowriter[key] |
| 91 |
puts " %-15s: '%s'" % [key, infowriter[key]] |
| 92 |
end |
| 93 |
end |