[packages/usbutils] - updated to 010 - updated hwdata patch - added python3 patch (fix python3 port of lsusb.py), packag

qboosh qboosh at pld-linux.org
Sun May 20 16:57:46 CEST 2018


commit da55ee4601f87d8bae43bb8b594e8deba554f83e
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Sun May 20 16:58:36 2018 +0200

    - updated to 010
    - updated hwdata patch
    - added python3 patch (fix python3 port of lsusb.py), package lsusb.py in -python subpackage
    - since 008 only lsusb.py uses hwdata usb.ids; base utilities use udev API

 hwdata.patch           |  55 ++++++++-----------
 usbutils-python3.patch | 145 +++++++++++++++++++++++++++++++++++++++++++++++++
 usbutils.spec          |  55 +++++++++----------
 3 files changed, 196 insertions(+), 59 deletions(-)
---
diff --git a/usbutils.spec b/usbutils.spec
index 551dc81..e93c61c 100644
--- a/usbutils.spec
+++ b/usbutils.spec
@@ -1,37 +1,32 @@
-#
-# Conditional build:
-%bcond_with	hwdata_check	# check hwdata usb.ids freshness
-
+# NOTE: usbutils>=008 requires udev; for udevless usage use usbutils-007
 Summary:	Linux USB utilities
 Summary(pl.UTF-8):	Linuksowe narzędzia do USB
 Summary(pt_BR.UTF-8):	Utilitários Linux USB
 Name:		usbutils
-Version:	008
-# see http://lists.pld-linux.org/mailman/pipermail/pld-devel-en/2016-April/024800.html
+Version:	010
 Release:	1
 License:	GPL v2+
 Group:		Applications/System
 Source0:	https://www.kernel.org/pub/linux/utils/usb/usbutils/%{name}-%{version}.tar.xz
-# Source0-md5:	2780b6ae21264c888f8f30fb2aab1259
+# Source0-md5:	938e3707593974be99a0dd6d1de76671
 Patch0:		hwdata.patch
+Patch1:		%{name}-python3.patch
 URL:		http://www.linux-usb.org/
 BuildRequires:	autoconf >= 2.60
 BuildRequires:	automake >= 1:1.9
-%{?with_hwdata_check:BuildRequires:	hwdata >= 0.249}
 BuildRequires:	libtool
-BuildRequires:	libusb-devel >= 1.0.0
+BuildRequires:	libusb-devel >= 1.0.9
 BuildRequires:	pkgconfig
+BuildRequires:	rpmbuild(macros) >= 1.507
+BuildRequires:	sed >= 4.0
 BuildRequires:	tar >= 1:1.22
 BuildRequires:	udev-devel >= 1:196
 BuildRequires:	xz
 BuildRequires:	zlib-devel
-Requires:	hwdata >= 0.249
+Requires:	libusb >= 1.0.9
 Requires:	udev-core >= 1:196
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
-%define		hwdatadir	/lib/hwdata
-%define		_datadir	%{hwdatadir}
-
 %description
 usbutils contains a utility for inspecting devices connected to the
 USB bus.
@@ -44,49 +39,53 @@ podłączonych do szyny USB.
 Este pacote contém utilitários para inspecionar dispositivos
 conectados a um barramento USB.
 
+%package python
+Summary:	Python based lsusb program
+Summary(pl.UTF-8):	Program lsusb napisany w Pythonie
+Group:		Applications/System
+Requires:	hwdata >= 0.249
+
+%description python
+Python based lsusb program.
+
+%description python -l pl.UTF-8
+Program lsusb napisany w Pythonie.
+
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
 
-%if %{with hwdata_check}
-# paranoid check whether usb.ids in system isn't too old
-if [ usb.ids -nt %{hwdatadir}/usb.ids ]; then
-	: usb.ids needs to be updated
-	exit 1
-fi
-%endif
+%{__sed} -i -e '1s,/usr/bin/env python3,%{__python3},' lsusb.py.in
 
 %build
-%{__libtoolize}
 %{__aclocal}
 %{__autoconf}
 %{__autoheader}
 %{__automake}
 %configure \
-	--disable-usbids \
 	--disable-silent-rules
 %{__make}
 
 %install
 rm -rf $RPM_BUILD_ROOT
 %{__make} install \
-	pkgconfigdir=%{_pkgconfigdir} \
 	INSTALL="install -p" \
 	DESTDIR=$RPM_BUILD_ROOT
 
-%{__rm} $RPM_BUILD_ROOT%{_bindir}/lsusb.py
-
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(644,root,root,755)
-%doc AUTHORS ChangeLog NEWS README
+%doc NEWS
 %attr(755,root,root) %{_bindir}/lsusb
 %attr(755,root,root) %{_bindir}/usb-devices
 %attr(755,root,root) %{_bindir}/usbhid-dump
 %{_mandir}/man1/usb-devices.1*
 %{_mandir}/man8/lsusb.8*
 %{_mandir}/man8/usbhid-dump.8*
-# there is no devel package for now and the dir is part of filesystem
-%{_pkgconfigdir}/usbutils.pc
+
+%files python
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/lsusb.py
diff --git a/hwdata.patch b/hwdata.patch
index 87e8280..24ce2e9 100644
--- a/hwdata.patch
+++ b/hwdata.patch
@@ -1,21 +1,23 @@
-diff --git a/lsusb.py b/lsusb.py
-index 14d9a31..a34f736 100755
---- a/lsusb.py
-+++ b/lsusb.py
-@@ -16,7 +16,7 @@ nohub = False
- warnsort = False
- 
- prefix = "/sys/bus/usb/devices/"
--usbids = "/usr/share/usb.ids"
-+usbids = "/lib/hwdata/usb.ids"
- 
- esc = chr(27)
- norm = esc + "[0;0m"
-diff -up usbutils-004/Makefile.am.orig usbutils-004/Makefile.am
---- usbutils-004/Makefile.am.orig	2011-09-20 09:42:04.282566870 +0200
-+++ usbutils-004/Makefile.am	2011-09-20 09:42:41.399102845 +0200
-@@ -38,7 +38,7 @@ EXTRA_DIST = \
- 	usbutils.pc.in
+--- usbutils-010/lsusb.py.in.orig	2018-05-20 16:28:37.757075652 +0200
++++ usbutils-010/lsusb.py.in	2018-05-20 16:30:24.147074439 +0200
+@@ -519,7 +519,7 @@
+ 	print(" -c use colors")
+ 	print(" -e display endpoint info")
+ 	print(" -w display warning if usb.ids is not sorted correctly")
+-	print(" -f FILE override filename for /usr/share/usb.ids")
++	print(" -f FILE override filename for " + usbids)
+ 	print("Use lsusb.py -ciu to get a nice overview of your USB devices.")
+ 	return 2
+ 
+--- usbutils-010/Makefile.am.orig	2018-05-15 15:45:26.000000000 +0200
++++ usbutils-010/Makefile.am	2018-05-20 15:33:58.907113099 +0200
+@@ -51,11 +51,11 @@
+ 	usbreset.c
+ 
+ lsusb.py: $(srcdir)/lsusb.py.in
+-	sed 's|VERSION|$(VERSION)|g;s|@usbids@|$(datadir)/usb.ids|g' $< >$@
++	sed 's|VERSION|$(VERSION)|g;s|@usbids@|/lib/hwdata/usb.ids|g' $< >$@
+ 	chmod 755 $@
  
  lsusb.8: $(srcdir)/lsusb.8.in
 -	sed 's|VERSION|$(VERSION)|g;s|@usbids@|$(datadir)/usb.ids|g' $< >$@
@@ -23,23 +25,14 @@ diff -up usbutils-004/Makefile.am.orig usbutils-004/Makefile.am
  
  usb-devices.1: $(srcdir)/usb-devices.1.in
  	sed 's|VERSION|$(VERSION)|g' $< >$@
-@@ -47,7 +47,7 @@ pkgconfigdir = $(datarootdir)/pkgconfig
- pkgconfig_DATA = usbutils.pc
- 
- usbutils.pc: $(srcdir)/usbutils.pc.in
--	sed 's|@usbids@|$(datadir)/usb.ids|g;s|@VERSION[@]|$(VERSION)|g' $< >$@
-+	sed 's|@usbids@|/lib/hwdata/usb.ids|g;s|@VERSION[@]|$(VERSION)|g' $< >$@
- 
- DISTCLEANFILES = \
- 	lsusb.8 \
---- usbutils-006/configure.ac~	2012-07-06 23:20:41.000000000 +0300
-+++ usbutils-006/configure.ac	2013-01-20 00:04:33.521843802 +0200
-@@ -41,7 +41,7 @@
+--- usbutils-010/configure.ac.orig	2018-05-20 11:34:32.067277134 +0200
++++ usbutils-010/configure.ac	2018-05-20 15:35:00.030445728 +0200
+@@ -35,7 +35,7 @@
  	datadir:                ${datadir}
  	mandir:                 ${mandir}
  
 -	usb.ids:                ${datadir}/usb.ids
 +	usb.ids:                /lib/hwdata/usb.ids
- 	zlib:                   ${USE_ZLIB}
  
  	compiler:               ${CC}
+ 	cflags:                 ${CFLAGS}
diff --git a/usbutils-python3.patch b/usbutils-python3.patch
new file mode 100644
index 0000000..c95bb73
--- /dev/null
+++ b/usbutils-python3.patch
@@ -0,0 +1,145 @@
+From a7c25eadbc998bf359e5b7dac03aaea8c30d2932 Mon Sep 17 00:00:00 2001
+From: Georg Brandl <georg at python.org>
+Date: Thu, 17 May 2018 08:51:27 +0200
+Subject: [PATCH] lsusb.py: fix up Python 3 conversion
+
+- Use open() and ignore encoding errors
+- Replace removed __cmp__ by rich comparison methods
+- Convert commented-out print statements, remove unused future import
+
+Fixes #68
+---
+ lsusb.py.in | 50 ++++++++++++++++++++++----------------------------
+ 1 file changed, 22 insertions(+), 28 deletions(-)
+
+diff --git a/lsusb.py.in b/lsusb.py.in
+index 0f4d318..083b512 100644
+--- a/lsusb.py.in
++++ b/lsusb.py.in
+@@ -12,8 +12,6 @@
+ 
+ import os, sys, re, getopt
+ 
+-# from __future__ import print_function
+-
+ # Global options
+ showint = False
+ showhubint = False
+@@ -53,15 +51,12 @@ class UsbClass:
+ 		self.desc = str
+ 	def __repr__(self):
+ 		return self.desc
+-	def __cmp__(self, oth):
+-		# Works only on 64bit systems:
+-		#return self.pclass*0x10000+self.subclass*0x100+self.proto \
+-		#	- oth.pclass*0x10000-oth.subclass*0x100-oth.proto
+-		if self.pclass != oth.pclass:
+-			return self.pclass - oth.pclass
+-		if self.subclass != oth.subclass:
+-			return self.subclass - oth.subclass
+-		return self.proto - oth.proto
++	def __lt__(self, oth):
++		return (self.pclass, self.subclass, self.proto) < \
++				(oth.pclass, oth.subclass, oth.proto)
++	def __eq__(self, oth):
++		return (self.pclass, self.subclass, self.proto) == \
++				(oth.pclass, oth.subclass, oth.proto)
+ 
+ class UsbVendor:
+ 	"Container for USB Vendors"
+@@ -70,8 +65,10 @@ class UsbVendor:
+ 		self.vname = vname
+ 	def __repr__(self):
+ 		return self.vname
+-	def __cmp__(self, oth):
+-		return self.vid - oth.vid
++	def __lt__(self, oth):
++		return self.vid < oth.vid
++	def __eq__(self, oth):
++		return self.vid == oth.vid
+ 
+ class UsbProduct:
+ 	"Container for USB VID:PID devices"
+@@ -81,13 +78,10 @@ class UsbProduct:
+ 		self.pname = pname
+ 	def __repr__(self):
+ 		return self.pname
+-	def __cmp__(self, oth):
+-		# Works only on 64bit systems:
+-		# return self.vid*0x10000 + self.pid \
+-		#	- oth.vid*0x10000 - oth.pid
+-		if self.vid != oth.vid:
+-			return self.vid - oth.vid
+-		return self.pid - oth.pid
++	def __lt__(self, oth):
++		return (self.vid, self.pid) < (oth.vid, oth.pid)
++	def __eq__(self, oth):
++		return (self.vid, self.pid) == (oth.vid, oth.pid)
+ 
+ usbvendors = []
+ usbproducts = []
+@@ -107,7 +101,7 @@ def parse_usb_ids():
+ 	mode = 0
+ 	strg = ""
+ 	cstrg = ""
+-	for ln in file(usbids, "r").readlines():
++	for ln in open(usbids, "r", errors="ignore"):
+ 		if ln[0] == '#':
+ 			continue
+ 		ln = ln.rstrip('\n')
+@@ -146,7 +140,7 @@ def parse_usb_ids():
+ 
+ def bin_search(first, last, item, list):
+ 	"binary search on list, returns -1 on fail, match idx otherwise, recursive"
+-	#print "bin_search(%i,%i)" % (first, last)
++	#print("bin_search(%i,%i)" % (first, last))
+ 	if first == last:
+ 		return -1
+ 	if first == last-1:
+@@ -233,7 +227,7 @@ def find_dev(driver, usbname):
+ 	for nm in devlst:
+ 		dir = prefix + usbname
+ 		prep = ""
+-		#print nm
++		#print(nm)
+ 		idx = nm.find('/')
+ 		if idx != -1:
+ 			prep = nm[:idx+1]
+@@ -404,8 +398,8 @@ class UsbDevice:
+ 		try:
+ 			self.nointerfaces = int(readattr(fname, "bNumInterfaces"))
+ 		except:
+-			#print "ERROR: %s/bNumInterfaces = %s" % (fname,
+-			#		readattr(fname, "bNumInterfaces"))a
++			#print("ERROR: %s/bNumInterfaces = %s" % (fname,
++			#		readattr(fname, "bNumInterfaces")))
+ 			self.nointerfaces = 0
+ 		try:
+ 			self.driver = readlink(fname, "driver")
+@@ -421,7 +415,7 @@ class UsbDevice:
+ 		for dirent in os.listdir(prefix + self.fname):
+ 			if not dirent[0:1].isdigit():
+ 				continue
+-			#print dirent
++			#print(dirent)
+ 			if os.access(prefix + dirent + "/bInterfaceClass", os.R_OK):
+ 				iface = UsbInterface(self, self.level+1)
+ 				iface.read(dirent)
+@@ -532,7 +526,7 @@ def usage():
+ def read_usb():
+ 	"Read toplevel USB entries and print"
+ 	for dirent in os.listdir(prefix):
+-		#print dirent,
++		#print(dirent)
+ 		if not dirent[0:3] == "usb":
+ 			continue
+ 		usbdev = UsbDevice(None, 0)
+@@ -590,7 +584,7 @@ def main(argv):
+ 		fix_usbclass()
+ 	except:
+ 		print(" WARNING: Failure to read usb.ids", file=sys.stderr)
+-		#print >>sys.stderr, sys.exc_info()
++		#print(sys.exc_info(), file=sys.stderr)
+ 	read_usb()
+ 
+ # Entry point
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/usbutils.git/commitdiff/da55ee4601f87d8bae43bb8b594e8deba554f83e



More information about the pld-cvs-commit mailing list