hplip/create_hal_global_fdi_from_hpmud_rules

66 lines
1.6 KiB
Plaintext
Raw Normal View History

#! /bin/bash
#
# Johannes Meixner <jsmeix@suse.de>, 2004, 2005, 2006, 2007, 2008
# Till Kamppeter <till.kamppeter@gmail.com>, 2008
#set -x
export PATH="/sbin:/usr/sbin:/usr/bin:/bin"
export LC_ALL="POSIX"
export LANG="POSIX"
umask 022
MY_NAME=${0##*/}
# Input:
# Create temporary files:
TMP_DATA=$(mktemp -u /tmp/$MY_NAME.XXXXXX)
cat /dev/null >$TMP_DATA
# Extract HPLIP USB ID classes (the digits in entries like SYSFS{idProduct}=="??12")
# and generate all possible HPLIP USB device IDs, see
# https://bugs.launchpad.net/bugs/195782
test -n "$1" && RULES_FILE="$1" || RULES_FILE="hpmud.rules"
test -r $RULES_FILE || { echo "$MY_NAME error: Cannot read file '$RULES_FILE'." 1>&2 ; exit 3 ; }
for CLASS in $( sed -n -e '/idVendor}=="03f0"/s/.*idProduct}=="??\([0-9A-Za-z]*\)".*/\1/p' $RULES_FILE )
do for A in 0 1 2 3 4 5 6 7 8 9 a b c d e f
do for B in 0 1 2 3 4 5 6 7 8 9 a b c d e f
do echo "0x$A$B$CLASS" >>$TMP_DATA
done
done
done
# Output:
# Output header:
echo '<?xml version="1.0" encoding="ISO-8859-1"?>'
echo '<deviceinfo version="0.2">'
echo ' <device>'
# Output model specific HP USB device entries:
exec <$TMP_DATA
while read PRODUCT
do echo
echo ' <match key="info.subsystem" string="usb">'
echo ' <match key="usb.vendor_id" int="0x03f0">'
echo -n ' <match key="usb.product_id" int="'
echo -n "$PRODUCT"
echo '">'
echo ' <append key="info.capabilities" type="strlist">scanner</append>'
echo ' </match>'
echo ' </match>'
echo ' </match>'
done
# Output footer:
echo
echo ' </device>'
echo '</deviceinfo>'
# Remove the temporary file
rm $TMP_DATA
exit 0