Nicholas Chin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/85790?usp=email )
Change subject: util/find_usbdebug: Fix lsusb -t parsing for usbutils v016 and newer ......................................................................
util/find_usbdebug: Fix lsusb -t parsing for usbutils v016 and newer
Commit e24294ff9ade ("lsusb -t: print ports and busses and devices with same width") [1] in the usbutils repository changed the format of the lsusb -t output, breaking the find_usbdebug.sh script. This commit is present in usbutils version 016 and later.
Use the output of lsusb -V to determine the version and set the bus/port parsing patterns accordingly to fix lsusb -t parsing for newer versions of usbutils while maintaining compatibility with older versions. A simple integer comparison of the version number is used, which will not work with versions of usbutils older than v001 which used a 0.nn version numbers. However, the newer version number format has been used since 2010, so it is probably safe to assume that no one will be using a version of usbutils older than that.
[1] https://github.com/gregkh/usbutils/commit/e24294ff9ade6dafcd1909763e888d97b3...
Change-Id: Iffa1238b995d387d6e51459f85ae96da52a5c0ff Signed-off-by: Nicholas Chin nic.c3.14@gmail.com --- M util/find_usbdebug/find_usbdebug.sh 1 file changed, 9 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/85790/1
diff --git a/util/find_usbdebug/find_usbdebug.sh b/util/find_usbdebug/find_usbdebug.sh index de370b1..ed5527e 100755 --- a/util/find_usbdebug/find_usbdebug.sh +++ b/util/find_usbdebug/find_usbdebug.sh @@ -32,8 +32,15 @@ find_devs_in_tree () { bus=$1 port=$2 - busstr=`printf "Bus %02d" "$bus"` - portstr="Port $port" + + # lsusb -t uses 3 digits for bus/port nunmbers as of version 016 and later + if [ $(lsusb -V | cut -f 3 -d " ") -lt 16 ]; then + busstr=`printf "Bus %02d" "$bus"` + portstr="Port $port" + else + busstr=`printf "Bus %03d" "$bus"` + portstr=`printf "Port %03d" "$port"` + fi
hubs_to_ignore="8087:0020 8087:0024 8087:8000 8087:8008" reqlvl=1