Imported Upstream version 2.7.2
This commit is contained in:
parent
0121794af9
commit
a356b56d11
263 changed files with 6039 additions and 8151 deletions
|
|
@ -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