Imported Upstream version 2.7.2
This commit is contained in:
parent
0121794af9
commit
a356b56d11
263 changed files with 6039 additions and 8151 deletions
|
@ -16,7 +16,7 @@
|
|||
# sub-directory
|
||||
SUBDIRS = . nut-scanner
|
||||
|
||||
EXTRA_DIST = nut-usbinfo.pl nut-hclinfo.py nut-recorder.sh gitlog2changelog.py nut-snmpinfo.py
|
||||
EXTRA_DIST = nut-usbinfo.pl nut-recorder.sh gitlog2changelog.py nut-snmpinfo.py
|
||||
|
||||
all: nut-scanner-deps
|
||||
|
||||
|
@ -45,22 +45,9 @@ nut-scanner-deps:
|
|||
echo "----------------------------------------------------------------------"; \
|
||||
fi
|
||||
|
||||
website:
|
||||
@if python -c "import json,simplejson,lxml"; then \
|
||||
echo "Regenerating the HTML and JSON formated HCL tables."; \
|
||||
$(top_srcdir)/tools/nut-hclinfo.py; \
|
||||
else \
|
||||
echo "----------------------------------------------------------------------"; \
|
||||
echo "Warning: either Python, or a required module (json, simplejson, lxml) "; \
|
||||
echo "is not available."; \
|
||||
echo "Skipping the HTML and JSON formated HCL tables regeneration."; \
|
||||
echo "----------------------------------------------------------------------"; \
|
||||
fi
|
||||
|
||||
# call the USB info script upon "make dist", and if Perl is present
|
||||
# call the SNMP info script upon "make dist", and if Python is present
|
||||
# and call both for building nut-scanner
|
||||
# also generate HCL data files
|
||||
dist-hook:
|
||||
@if python -c 1; then \
|
||||
echo "Regenerating the SNMP helper files."; \
|
||||
|
@ -82,15 +69,4 @@ dist-hook:
|
|||
echo "----------------------------------------------------------------------"; \
|
||||
fi
|
||||
|
||||
@if python -c "import json,simplejson,lxml"; then \
|
||||
echo "Regenerating the HTML and JSON formated HCL tables."; \
|
||||
$(distdir)/nut-hclinfo.py; \
|
||||
else \
|
||||
echo "----------------------------------------------------------------------"; \
|
||||
echo "Warning: either Python, or a required module (json, simplejson, lxml) "; \
|
||||
echo "is not available."; \
|
||||
echo "Skipping the HTML and JSON formated HCL tables regeneration."; \
|
||||
echo "----------------------------------------------------------------------"; \
|
||||
fi
|
||||
|
||||
.PHONY: nut-scanner-deps nut-scanner-snmp-deps nut-scanner-usb-deps
|
||||
|
|
|
@ -65,7 +65,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
|
|||
$(top_srcdir)/m4/nut_check_libavahi.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libgd.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libhal.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libltdl.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libneon.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libnetsnmp.m4 \
|
||||
|
@ -75,10 +74,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
|
|||
$(top_srcdir)/m4/nut_check_libusb.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libwrap.m4 \
|
||||
$(top_srcdir)/m4/nut_check_os.m4 \
|
||||
$(top_srcdir)/m4/nut_config_libhal.m4 \
|
||||
$(top_srcdir)/m4/nut_report_feature.m4 \
|
||||
$(top_srcdir)/m4/nut_type_socklen_t.m4 \
|
||||
$(top_srcdir)/configure.in
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
|
@ -175,10 +173,6 @@ EGREP = @EGREP@
|
|||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAL_CALLOUTS_PATH = @HAL_CALLOUTS_PATH@
|
||||
HAL_DEVICE_MATCH_KEY = @HAL_DEVICE_MATCH_KEY@
|
||||
HAL_FDI_PATH = @HAL_FDI_PATH@
|
||||
HAL_USER = @HAL_USER@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
|
@ -190,8 +184,6 @@ LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
|
|||
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
|
||||
LIBGD_CFLAGS = @LIBGD_CFLAGS@
|
||||
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
|
||||
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
|
||||
LIBHAL_LIBS = @LIBHAL_LIBS@
|
||||
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
|
||||
LIBIPMI_LIBS = @LIBIPMI_LIBS@
|
||||
LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@
|
||||
|
@ -277,6 +269,7 @@ builddir = @builddir@
|
|||
cgiexecdir = @cgiexecdir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
devddir = @devddir@
|
||||
docdir = @docdir@
|
||||
driverexecdir = @driverexecdir@
|
||||
dvidir = @dvidir@
|
||||
|
@ -334,7 +327,7 @@ udevdir = @udevdir@
|
|||
# to have nutscan-{usb,snmp}.h built before going into the nut-scanner
|
||||
# sub-directory
|
||||
SUBDIRS = . nut-scanner
|
||||
EXTRA_DIST = nut-usbinfo.pl nut-hclinfo.py nut-recorder.sh gitlog2changelog.py nut-snmpinfo.py
|
||||
EXTRA_DIST = nut-usbinfo.pl nut-recorder.sh gitlog2changelog.py nut-snmpinfo.py
|
||||
all: all-recursive
|
||||
|
||||
.SUFFIXES:
|
||||
|
@ -714,22 +707,9 @@ nut-scanner-deps:
|
|||
echo "----------------------------------------------------------------------"; \
|
||||
fi
|
||||
|
||||
website:
|
||||
@if python -c "import json,simplejson,lxml"; then \
|
||||
echo "Regenerating the HTML and JSON formated HCL tables."; \
|
||||
$(top_srcdir)/tools/nut-hclinfo.py; \
|
||||
else \
|
||||
echo "----------------------------------------------------------------------"; \
|
||||
echo "Warning: either Python, or a required module (json, simplejson, lxml) "; \
|
||||
echo "is not available."; \
|
||||
echo "Skipping the HTML and JSON formated HCL tables regeneration."; \
|
||||
echo "----------------------------------------------------------------------"; \
|
||||
fi
|
||||
|
||||
# call the USB info script upon "make dist", and if Perl is present
|
||||
# call the SNMP info script upon "make dist", and if Python is present
|
||||
# and call both for building nut-scanner
|
||||
# also generate HCL data files
|
||||
dist-hook:
|
||||
@if python -c 1; then \
|
||||
echo "Regenerating the SNMP helper files."; \
|
||||
|
@ -751,17 +731,6 @@ dist-hook:
|
|||
echo "----------------------------------------------------------------------"; \
|
||||
fi
|
||||
|
||||
@if python -c "import json,simplejson,lxml"; then \
|
||||
echo "Regenerating the HTML and JSON formated HCL tables."; \
|
||||
$(distdir)/nut-hclinfo.py; \
|
||||
else \
|
||||
echo "----------------------------------------------------------------------"; \
|
||||
echo "Warning: either Python, or a required module (json, simplejson, lxml) "; \
|
||||
echo "is not available."; \
|
||||
echo "Skipping the HTML and JSON formated HCL tables regeneration."; \
|
||||
echo "----------------------------------------------------------------------"; \
|
||||
fi
|
||||
|
||||
.PHONY: nut-scanner-deps nut-scanner-snmp-deps nut-scanner-usb-deps
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
|
|
|
@ -1,277 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2009 - Arnaud Quette <arnaud.quette@gmail.com>
|
||||
# Copyright (c) 2010 - Sébastien Volle <sebastien.volle@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
# This script convert the driver.list into HTML and JSON formated tables
|
||||
# These tables are then used by the AsciiDoc generated website and
|
||||
# documentation
|
||||
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
import simplejson as json # Required for Python < 2.6
|
||||
|
||||
import re
|
||||
import sys
|
||||
import os, errno
|
||||
|
||||
# HCL file location and name
|
||||
rawHCL="../data/driver.list";
|
||||
|
||||
# Website output
|
||||
webJsonHCL = "../docs/website/scripts/ups_data.js";
|
||||
webStaticHCL = "../docs/ups-html.txt";
|
||||
|
||||
# from http://wiki.python.org/moin/EscapingHtml
|
||||
|
||||
html_escape_table = {
|
||||
"&": "&",
|
||||
'"': """,
|
||||
"'": "'",
|
||||
">": ">",
|
||||
"<": "<",
|
||||
}
|
||||
|
||||
def html_escape(text):
|
||||
"""Produce entities within text."""
|
||||
return "".join(html_escape_table.get(c,c) for c in text)
|
||||
|
||||
# # #
|
||||
|
||||
class WrongFieldNumberException(Exception):
|
||||
pass
|
||||
|
||||
def buildData(deviceDataFile):
|
||||
"""
|
||||
Read and parse data file under provided path.
|
||||
Return a bi-dimensional list representing parsed data.
|
||||
"""
|
||||
|
||||
deviceData = []
|
||||
numFields = 6 # Manufacturer, type, support level, model comment, driver
|
||||
|
||||
try:
|
||||
file = open(deviceDataFile, "r")
|
||||
except IOError:
|
||||
print "Cannot open", deviceDataFile
|
||||
exit(1)
|
||||
|
||||
for line in file:
|
||||
# Ignore empty lines or comments
|
||||
if re.match(r"^$|^\s*#", line):
|
||||
continue
|
||||
|
||||
# Strip all trailing whitespace chars
|
||||
line = re.sub(r"\s+$", "", line)
|
||||
|
||||
# Replace all tabs by commas
|
||||
line = re.sub(r"\t", ",", line)
|
||||
|
||||
# Remove trailing comma
|
||||
line = re.sub(r",$", "", line)
|
||||
|
||||
# Split fields and append result to device data list
|
||||
# We suppose there are no double-quotes in fields
|
||||
row = re.findall(r'"([^"]*)",?', line)
|
||||
|
||||
if len(row) != numFields:
|
||||
print "Warning: Unexpected number of fields in line: %s" % row
|
||||
print "\tLine will be skipped."
|
||||
else:
|
||||
deviceData.append(re.findall(r'"([^"]*)",?', line))
|
||||
|
||||
return deviceData
|
||||
|
||||
def buildHTMLTable(deviceData):
|
||||
"""
|
||||
Convert provided device data into an HTML table.
|
||||
Return string representation of the HTML table.
|
||||
|
||||
Identical cells are merged vertically with rowspan attribute.
|
||||
The driver column is color-coded on support level.
|
||||
|
||||
A support level column is also provided. It should be hidden in a graphic
|
||||
browser but should be visible from a console based browser (w3m).
|
||||
"""
|
||||
|
||||
from lxml import etree, html
|
||||
from lxml.builder import E
|
||||
|
||||
if not type(deviceData).__name__ == "list" or len(deviceData) == 0:
|
||||
raise Exception("Incorrect data was provided")
|
||||
|
||||
# HTML table columns definition
|
||||
columns = [
|
||||
{
|
||||
"name": "manufacturer", "id": "manufacturer-col",
|
||||
"text": "Manufacturer", "fields": ["manufacturer"]
|
||||
},
|
||||
{
|
||||
"name": "model", "id": "model-col",
|
||||
"text": "Model", "fields": ["model", "comment"]
|
||||
},
|
||||
{
|
||||
"name": "driver", "id": "driver-col",
|
||||
"text": "Driver", "fields": ["driver"]
|
||||
},
|
||||
{
|
||||
"name": "support-level", "id": "support-level-col",
|
||||
"text": "Support Level", "fields": ["support-level"]
|
||||
},
|
||||
]
|
||||
# Device data fields definition
|
||||
dataFields = [
|
||||
"manufacturer", "device-type", "support-level",
|
||||
"model", "comment", "driver"
|
||||
]
|
||||
|
||||
# FIXME: CSS classes should be defined in script global settings
|
||||
supportLevelClasses = {
|
||||
"0": "", "1": "red", "2": "orange",
|
||||
"3": "yellow", "4": "blue", "5": "green"
|
||||
}
|
||||
hiddenClass = "hidden"
|
||||
|
||||
# Build table header
|
||||
table = E.table(id="ups_list", border="1")
|
||||
header = E.tr()
|
||||
|
||||
for column in columns:
|
||||
td = E.td(column.get("text"), id=column.get("id"))
|
||||
if column["id"] == "support-level-col":
|
||||
td.set("class", hiddenClass)
|
||||
header.append(td)
|
||||
|
||||
table.append(E.thead(header))
|
||||
|
||||
# Build table body
|
||||
tbody = E.tbody(id="ups_list_body")
|
||||
|
||||
cellHistory = []
|
||||
rowHistory = deviceData[0][0]
|
||||
rows = []
|
||||
classes = ("even", "odd")
|
||||
currentClass = 0
|
||||
manufIndex = dataFields.index("manufacturer")
|
||||
|
||||
# Build table rows
|
||||
for device in deviceData:
|
||||
|
||||
# Devices are expected to have a specified number of fields
|
||||
if len(device) < len(dataFields):
|
||||
print "Unexpected number of fields in device: %s" % device
|
||||
print "Device will not be included in result set."
|
||||
continue
|
||||
|
||||
# Alternate CSS class if current manufacturer is different from the last
|
||||
if device[manufIndex] != rowHistory :
|
||||
currentClass = (currentClass + 1) % 2
|
||||
rowHistory = device[manufIndex]
|
||||
|
||||
cells = []
|
||||
|
||||
colIndex = 0
|
||||
for column in columns:
|
||||
cellContent = []
|
||||
for field in column["fields"]:
|
||||
fieldIndex = dataFields.index(field)
|
||||
fieldContent = device[fieldIndex]
|
||||
cellContent.append(html_escape(fieldContent))
|
||||
cellContent = "<br />".join(cellContent)
|
||||
|
||||
try:
|
||||
cH = cellHistory[colIndex]
|
||||
except:
|
||||
cH = False
|
||||
|
||||
if not column["name"] == "driver" and cH and cH.get("text") == cellContent:
|
||||
cH["rowspan"] = cH.get("rowspan", 1) + 1
|
||||
else:
|
||||
cell = { "text": cellContent, "rowspan": 1 }
|
||||
if column["name"] == "driver":
|
||||
cell["class"] = supportLevelClasses[device[dataFields.index("support-level")]]
|
||||
else:
|
||||
cell["class"] = classes[currentClass]
|
||||
if column["name"] == "support-level":
|
||||
cell["class"] = hiddenClass
|
||||
|
||||
cells.append(cell)
|
||||
try:
|
||||
cellHistory[colIndex] = cell
|
||||
except:
|
||||
cellHistory.append(cell)
|
||||
|
||||
colIndex += 1
|
||||
|
||||
rows.append(cells)
|
||||
|
||||
for row in rows:
|
||||
r = E.tr()
|
||||
for cell in row:
|
||||
attr = ""
|
||||
innerHTML = ""
|
||||
for key, value in cell.iteritems():
|
||||
val = unicode(str(value), "utf-8")
|
||||
if key != "text":
|
||||
attr += " %s='%s'" % (key, val)
|
||||
else:
|
||||
innerHTML = val
|
||||
|
||||
r.append(html.fromstring("<td%s>%s</td>" % (attr, innerHTML)))
|
||||
|
||||
tbody.append(r)
|
||||
|
||||
table.append(tbody)
|
||||
|
||||
return etree.tostring(table, pretty_print=True)
|
||||
|
||||
# main program
|
||||
deviceData = buildData(rawHCL)
|
||||
|
||||
# Dump device data as JSON
|
||||
jsonData = "var UPSData = %s" % json.dumps(deviceData, encoding="utf-8")
|
||||
|
||||
# First, check if target directory exists (which is not the case for 'dist')
|
||||
dir = os.path.dirname(webJsonHCL)
|
||||
try:
|
||||
os.makedirs(dir)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
try:
|
||||
file = open(webJsonHCL, "w")
|
||||
file.write(jsonData)
|
||||
file.close()
|
||||
print "JSON HCL written"
|
||||
except IOError:
|
||||
print "Unable to write JSON device data to %s" % webJsonHCL
|
||||
exit(1)
|
||||
|
||||
# Create HTML table from device data
|
||||
table = buildHTMLTable(deviceData)
|
||||
try:
|
||||
file = open(webStaticHCL, "w")
|
||||
file.write("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n")
|
||||
file.write(table)
|
||||
file.write("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n")
|
||||
print "HTML HCL written"
|
||||
except IOError:
|
||||
print "Unable to write HTML device table to %s" % webStaticHCL
|
||||
exit(1)
|
||||
|
|
@ -77,7 +77,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
|
|||
$(top_srcdir)/m4/nut_check_libavahi.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libgd.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libhal.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libltdl.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libneon.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libnetsnmp.m4 \
|
||||
|
@ -87,10 +86,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
|
|||
$(top_srcdir)/m4/nut_check_libusb.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libwrap.m4 \
|
||||
$(top_srcdir)/m4/nut_check_os.m4 \
|
||||
$(top_srcdir)/m4/nut_config_libhal.m4 \
|
||||
$(top_srcdir)/m4/nut_report_feature.m4 \
|
||||
$(top_srcdir)/m4/nut_type_socklen_t.m4 \
|
||||
$(top_srcdir)/configure.in
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
|
@ -221,10 +219,6 @@ EGREP = @EGREP@
|
|||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAL_CALLOUTS_PATH = @HAL_CALLOUTS_PATH@
|
||||
HAL_DEVICE_MATCH_KEY = @HAL_DEVICE_MATCH_KEY@
|
||||
HAL_FDI_PATH = @HAL_FDI_PATH@
|
||||
HAL_USER = @HAL_USER@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
|
@ -236,8 +230,6 @@ LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
|
|||
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
|
||||
LIBGD_CFLAGS = @LIBGD_CFLAGS@
|
||||
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
|
||||
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
|
||||
LIBHAL_LIBS = @LIBHAL_LIBS@
|
||||
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
|
||||
LIBIPMI_LIBS = @LIBIPMI_LIBS@
|
||||
LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@
|
||||
|
@ -323,6 +315,7 @@ builddir = @builddir@
|
|||
cgiexecdir = @cgiexecdir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
devddir = @devddir@
|
||||
docdir = @docdir@
|
||||
driverexecdir = @driverexecdir@
|
||||
dvidir = @dvidir@
|
||||
|
|
|
@ -39,6 +39,7 @@ static snmp_device_id_t snmp_device_table[] = {
|
|||
{ ".1.3.6.1.4.1.20677.1" , "pulizzi_switched2", ".1.3.6.1.4.1.20677.2"},
|
||||
{ ".1.3.6.1.4.1.2947.1.1.2.0" , "bestpower", NULL},
|
||||
{ ".1.3.6.1.4.1.3808.1.1.1.1.1.1.0" , "cyberpower", ".1.3.6.1.4.1.3808"},
|
||||
{ "" , "xppc", ".1.3.6.1.4.1.935"},
|
||||
{ "" , "delta_ups", ".1.3.6.1.4.1.2254.2.4"},
|
||||
{ ".1.3.6.1.4.1.705.1.1.1.0" , "mge", ".1.3.6.1.4.1.705.1"},
|
||||
{ ".1.3.6.1.4.1.232.165.3.1.1.0" , "cpqpower", ".1.3.6.1.4.1.232.165.3"},
|
||||
|
|
|
@ -31,7 +31,7 @@ typedef struct {
|
|||
/* USB IDs device table */
|
||||
static usb_device_id_t usb_device_table[] = {
|
||||
|
||||
{ 0x0001, 0x0000, "blazer_usb" },
|
||||
{ 0x0001, 0x0000, "nutdrv_atcl_usb" },
|
||||
{ 0x03f0, 0x0001, "usbhid-ups" },
|
||||
{ 0x03f0, 0x1f01, "bcmxcp_usb" },
|
||||
{ 0x03f0, 0x1f02, "bcmxcp_usb" },
|
||||
|
@ -119,6 +119,7 @@ static usb_device_id_t usb_device_table[] = {
|
|||
{ 0x0d9f, 0x00a6, "usbhid-ups" },
|
||||
{ 0x0f03, 0x0001, "blazer_usb" },
|
||||
{ 0x10af, 0x0001, "usbhid-ups" },
|
||||
{ 0x10af, 0x0004, "usbhid-ups" },
|
||||
{ 0x14f0, 0x00c9, "blazer_usb" },
|
||||
{ 0xffff, 0x0000, "blazer_usb" },
|
||||
/* Terminating entry */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env perl
|
||||
# Current Version : 1.2
|
||||
# Copyright (C) 2008 - 2012
|
||||
# Arnaud Quette <arnaud.quette@gmail.com>
|
||||
# dloic (loic.dardant AT gmail DOT com)
|
||||
# Current Version : 1.3
|
||||
# Copyright (C) 2008 - 2012 dloic (loic.dardant AT gmail DOT com)
|
||||
# Copyright (C) 2008 - 2014 Arnaud Quette <arnaud.quette@free.fr>
|
||||
# Copyright (C) 2013 - 2014 Charles Lepple <clepple+nut@gmail.com>
|
||||
#
|
||||
# Based on the usbdevice.pl script, made for the Ubuntu Media Center
|
||||
# for the final use of the LIRC project.
|
||||
|
@ -31,17 +31,18 @@ use strict;
|
|||
# path to scan for USB_DEVICE pattern
|
||||
my $scanPath="../drivers";
|
||||
|
||||
# HAL output file
|
||||
my $outputHAL="../scripts/hal/ups-nut-device.fdi.in";
|
||||
|
||||
# Hotplug output file
|
||||
my $outputHotplug="../scripts/hotplug/libhid.usermap";
|
||||
|
||||
# udev output file
|
||||
my $outputUdev="../scripts/udev/nut-usbups.rules.in";
|
||||
|
||||
# BSD devd output file
|
||||
my $output_devd="../scripts/devd/nut-usb.conf.in";
|
||||
|
||||
# UPower output file
|
||||
my $outputUPower="../scripts/upower/95-upower-hid.rules";
|
||||
|
||||
# tmp output, to allow generating the ENV{UPOWER_VENDOR} header list
|
||||
my $tmpOutputUPower;
|
||||
# mfr header flag
|
||||
|
@ -81,13 +82,6 @@ find(\&find_usbdevs,$scanPath);
|
|||
################# SUB METHOD #################
|
||||
sub gen_usb_files
|
||||
{
|
||||
# HAL file header
|
||||
open my $outHAL, ">$outputHAL" || die "error $outputHAL : $!";
|
||||
print $outHAL '<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->'."\n";
|
||||
print $outHAL '<deviceinfo version="0.2">'."\n";
|
||||
print $outHAL ' <device>'."\n";
|
||||
print $outHAL ' <match key="@HAL_DEVICE_MATCH_KEY@" string="usb_device">'."\n";
|
||||
|
||||
# Hotplug file header
|
||||
open my $outHotplug, ">$outputHotplug" || die "error $outputHotplug : $!";
|
||||
print $outHotplug '# This file is generated and installed by the Network UPS Tools package.'."\n";
|
||||
|
@ -109,6 +103,10 @@ sub gen_usb_files
|
|||
print $outUdev 'SUBSYSTEM!="usb", GOTO="nut-usbups_rules_end"'."\n\n";
|
||||
print $outUdev 'LABEL="nut-usbups_rules_real"'."\n";
|
||||
|
||||
open my $out_devd, ">$output_devd" || die "error $output_devd : $!";
|
||||
print $out_devd '# This file is generated and installed by the Network UPS Tools package.'."\n";
|
||||
print $out_devd "# Homepage: http://www.networkupstools.org/\n\n";
|
||||
|
||||
# UPower file header
|
||||
open my $outputUPower, ">$outputUPower" || die "error $outputUPower : $!";
|
||||
print $outputUPower '##############################################################################################################'."\n";
|
||||
|
@ -131,12 +129,6 @@ sub gen_usb_files
|
|||
# generate the file in alphabetical order (first for VendorID, then for ProductID)
|
||||
foreach my $vendorId (sort { lc $a cmp lc $b } keys %vendorName)
|
||||
{
|
||||
# HAL vendor header
|
||||
if ($vendorName{$vendorId}) {
|
||||
print $outHAL "\n <!-- ".$vendorName{$vendorId}." -->\n";
|
||||
}
|
||||
print $outHAL " <match key=\"usb_device.vendor_id\" int=\"".$vendorId."\">\n";
|
||||
|
||||
# Hotplug vendor header
|
||||
if ($vendorName{$vendorId}) {
|
||||
print $outHotplug "\n# ".$vendorName{$vendorId}."\n";
|
||||
|
@ -147,20 +139,17 @@ sub gen_usb_files
|
|||
print $outUdev "\n# ".$vendorName{$vendorId}."\n";
|
||||
}
|
||||
|
||||
# devd vendor header
|
||||
if ($vendorName{$vendorId}) {
|
||||
print $out_devd "\n# ".$vendorName{$vendorId}."\n";
|
||||
}
|
||||
|
||||
|
||||
# UPower vendor header flag
|
||||
$upowerMfrHeaderDone = 0;
|
||||
|
||||
foreach my $productId (sort { lc $a cmp lc $b } keys %{$vendor{$vendorId}})
|
||||
{
|
||||
# HAL device entry
|
||||
print $outHAL " <!-- ".$vendor{$vendorId}{$productId}{"comment"}." -->\n";
|
||||
print $outHAL " <match key=\"usb_device.product_id\" int=\"".$productId."\">\n";
|
||||
print $outHAL ' <append key="info.category" type="string">battery</append>'."\n";
|
||||
print $outHAL ' <merge key="info.capabilities" type="strlist">battery</merge>'."\n";
|
||||
print $outHAL " <merge key=\"info.addons\" type=\"strlist\">hald-addon-".$vendor{$vendorId}{$productId}{"driver"}."</merge>\n";
|
||||
print $outHAL ' <merge key="battery.type" type="string">ups</merge>'."\n";
|
||||
print $outHAL ' </match>'."\n";
|
||||
|
||||
# Hotplug device entry
|
||||
print $outHotplug "# ".$vendor{$vendorId}{$productId}{"comment"}."\n";
|
||||
print $outHotplug "libhidups 0x0003 ".$vendorId." ".$productId." 0x0000 0x0000 0x00";
|
||||
|
@ -172,6 +161,17 @@ sub gen_usb_files
|
|||
print $outUdev "\", ATTR{idProduct}==\"".removeHexPrefix($productId)."\",";
|
||||
print $outUdev ' MODE="664", GROUP="@RUN_AS_GROUP@"'."\n";
|
||||
|
||||
# devd device entry
|
||||
print $out_devd "# ".$vendor{$vendorId}{$productId}{"comment"}.' - '.$vendor{$vendorId}{$productId}{"driver"}."\n";
|
||||
print $out_devd "notify 100 {\n\tmatch \"system\"\t\t\"USB\";\n";
|
||||
print $out_devd "\tmatch \"subsystem\"\t\"DEVICE\";\n";
|
||||
print $out_devd "\tmatch \"type\"\t\t\"ATTACH\";\n";
|
||||
print $out_devd "\tmatch \"vendor\"\t\t\"$vendorId\";\n";
|
||||
#
|
||||
print $out_devd "\tmatch \"product\"\t\t\"$productId\";\n";
|
||||
print $out_devd "\taction \"chgrp \@RUN_AS_GROUP\@ /dev/\$device-name*; chmod g+rw /dev/\$device-name*\";\n";
|
||||
print $out_devd "};\n";
|
||||
|
||||
# UPower device entry (only for USB/HID devices!)
|
||||
if ($vendor{$vendorId}{$productId}{"driver"} eq "usbhid-ups")
|
||||
{
|
||||
|
@ -192,14 +192,7 @@ sub gen_usb_files
|
|||
# Device scanner entry
|
||||
print $outputDevScanner "\t{ ".$vendorId.', '.$productId.", \"".$vendor{$vendorId}{$productId}{"driver"}."\" },\n";
|
||||
}
|
||||
# HAL vendor footer
|
||||
print $outHAL " </match>\n";
|
||||
}
|
||||
# HAL footer
|
||||
print $outHAL " </match>\n";
|
||||
print $outHAL " </device>\n";
|
||||
print $outHAL "</deviceinfo>\n";
|
||||
|
||||
# Udev footer
|
||||
print $outUdev "\n".'LABEL="nut-usbups_rules_end"'."\n";
|
||||
|
||||
|
@ -297,6 +290,9 @@ sub find_usbdevs
|
|||
elsif ($nameFile eq "richcomm_usb.c") {
|
||||
$driver="richcomm_usb";
|
||||
}
|
||||
elsif ($nameFile eq "nutdrv_atcl_usb.c") {
|
||||
$driver="nutdrv_atcl_usb";
|
||||
}
|
||||
elsif ($nameFile eq "riello_usb.c") {
|
||||
$driver="riello_usb";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue