From edf3b151d7692fc67b56ef47853440539fcd10c2 Mon Sep 17 00:00:00 2001 From: zyppe <210hcl@gmail.com> Date: Thu, 29 Feb 2024 15:58:38 +0800 Subject: [PATCH] Initialize for libusb-1_0 --- .gitignore | 1 + .libusb-1_0.metadata | 1 + 0001-fix-descriptor-parsing.patch | 44 +++ ...cefully-handle-buggy-config0-devices.patch | 217 ++++++++++++++ baselibs.conf | 5 + libusb-1_0.changes | 274 ++++++++++++++++++ libusb-1_0.spec | 75 +++++ 7 files changed, 617 insertions(+) create mode 100644 .gitignore create mode 100644 .libusb-1_0.metadata create mode 100644 0001-fix-descriptor-parsing.patch create mode 100644 0002-gracefully-handle-buggy-config0-devices.patch create mode 100644 baselibs.conf create mode 100644 libusb-1_0.changes create mode 100644 libusb-1_0.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d38add1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +libusb-1.0.24.tar.bz2 diff --git a/.libusb-1_0.metadata b/.libusb-1_0.metadata new file mode 100644 index 0000000..b03f203 --- /dev/null +++ b/.libusb-1_0.metadata @@ -0,0 +1 @@ +2a84acc5db3387a9c0232aa4a7cb7170277471fbcd266c7801d0e5f251307b57 libusb-1.0.24.tar.bz2 diff --git a/0001-fix-descriptor-parsing.patch b/0001-fix-descriptor-parsing.patch new file mode 100644 index 0000000..9e4873b --- /dev/null +++ b/0001-fix-descriptor-parsing.patch @@ -0,0 +1,44 @@ +From f6d2cb561402c3b6d3627c0eb89e009b503d9067 Sun 17 01 11:38:45 2021 +From: Simon Vogl +Date: Sun, 17 Jan 2021 11:38:45 UTC +Subject: [PATCH] Fix USB Device enumeration + +This patch fixes a regression introduced in libusb 1.0.24 that prevents certain devices like smartphones from being detected. + +diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c +index fb2ed53a..4d2dc8d6 100644 +--- a/libusb/os/linux_usbfs.c ++++ b/libusb/os/linux_usbfs.c +@@ -641,7 +641,12 @@ static int seek_to_next_config(struct libusb_context *ctx, + uint8_t *buffer, size_t len) + { + struct usbi_descriptor_header *header; +- int offset = 0; ++ int offset; ++ ++ /* Start seeking past the config descriptor */ ++ offset = LIBUSB_DT_CONFIG_SIZE; ++ buffer += LIBUSB_DT_CONFIG_SIZE; ++ len -= LIBUSB_DT_CONFIG_SIZE; + + while (len > 0) { + if (len < 2) { +@@ -718,7 +723,7 @@ static int parse_config_descriptors(struct libusb_device *dev) + } + + if (priv->sysfs_dir) { +- /* ++ /* + * In sysfs wTotalLength is ignored, instead the kernel returns a + * config descriptor with verified bLength fields, with descriptors + * with an invalid bLength removed. +@@ -727,8 +732,7 @@ static int parse_config_descriptors(struct libusb_device *dev) + int offset; + + if (num_configs > 1 && idx < num_configs - 1) { +- offset = seek_to_next_config(ctx, buffer + LIBUSB_DT_CONFIG_SIZE, +- remaining - LIBUSB_DT_CONFIG_SIZE); ++ offset = seek_to_next_config(ctx, buffer, remaining); + if (offset < 0) + return offset; + sysfs_config_len = (uint16_t)offset; diff --git a/0002-gracefully-handle-buggy-config0-devices.patch b/0002-gracefully-handle-buggy-config0-devices.patch new file mode 100644 index 0000000..5a208d8 --- /dev/null +++ b/0002-gracefully-handle-buggy-config0-devices.patch @@ -0,0 +1,217 @@ +From f38f09da98acc63966b65b72029b1f7f81166bef Mon Sep 17 00:00:00 2001 +From: Chris Dickens +Date: Mon, 8 Feb 2021 11:56:13 -0800 +Subject: [PATCH] linux_usbfs: Gracefully handle buggy devices with a + configuration 0 + +The USB spec states that a configuration value of 0 is reserved and is +used to indicate the device in not configured (e.g. is in the address +state). Unfortunately some devices do exist that violate this and use 0 +as the bConfigurationValue of the configuration descriptor. + +Improve how the Linux backend handles such non-conformant devices by +adding special handling around the configuration value 0. Most devices +will not require this special handling, but for those that do there is +no way to distinguish between the device being unconfigured and using +configuration 0. + +Closes #850 + +Signed-off-by: Chris Dickens +--- + libusb/os/linux_usbfs.c | 94 ++++++++++++++++++++++++++--------------- + libusb/version_nano.h | 2 +- + 2 files changed, 60 insertions(+), 36 deletions(-) + +diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c +index ebf8cfedb..3a1894cf5 100644 +--- a/libusb/os/linux_usbfs.c ++++ b/libusb/os/linux_usbfs.c +@@ -128,7 +128,7 @@ struct linux_device_priv { + void *descriptors; + size_t descriptors_len; + struct config_descriptor *config_descriptors; +- uint8_t active_config; /* cache val for !sysfs_available */ ++ int active_config; /* cache val for !sysfs_available */ + }; + + struct linux_device_handle_priv { +@@ -169,6 +169,21 @@ struct linux_transfer_priv { + int iso_packet_offset; + }; + ++static int dev_has_config0(struct libusb_device *dev) ++{ ++ struct linux_device_priv *priv = usbi_get_device_priv(dev); ++ struct config_descriptor *config; ++ uint8_t idx; ++ ++ for (idx = 0; idx < dev->device_descriptor.bNumConfigurations; idx++) { ++ config = &priv->config_descriptors[idx]; ++ if (config->desc->bConfigurationValue == 0) ++ return 1; ++ } ++ ++ return 0; ++} ++ + static int get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent) + { + struct libusb_context *ctx = DEVICE_CTX(dev); +@@ -574,22 +589,12 @@ static int sysfs_scan_device(struct libusb_context *ctx, const char *devname) + } + + /* read the bConfigurationValue for a device */ +-static int sysfs_get_active_config(struct libusb_device *dev, uint8_t *config) ++static int sysfs_get_active_config(struct libusb_device *dev, int *config) + { + struct linux_device_priv *priv = usbi_get_device_priv(dev); +- int ret, tmp; +- +- ret = read_sysfs_attr(DEVICE_CTX(dev), priv->sysfs_dir, "bConfigurationValue", +- UINT8_MAX, &tmp); +- if (ret < 0) +- return ret; + +- if (tmp == -1) +- tmp = 0; /* unconfigured */ +- +- *config = (uint8_t)tmp; +- +- return 0; ++ return read_sysfs_attr(DEVICE_CTX(dev), priv->sysfs_dir, "bConfigurationValue", ++ UINT8_MAX, config); + } + + int linux_get_device_address(struct libusb_context *ctx, int detached, +@@ -765,6 +770,9 @@ static int parse_config_descriptors(struct libusb_device *dev) + } + } + ++ if (config_desc->bConfigurationValue == 0) ++ usbi_warn(ctx, "device has configuration 0"); ++ + priv->config_descriptors[idx].desc = config_desc; + priv->config_descriptors[idx].actual_len = config_len; + +@@ -798,7 +806,7 @@ static int op_get_active_config_descriptor(struct libusb_device *dev, + { + struct linux_device_priv *priv = usbi_get_device_priv(dev); + void *config_desc; +- uint8_t active_config; ++ int active_config; + int r; + + if (priv->sysfs_dir) { +@@ -810,12 +818,12 @@ static int op_get_active_config_descriptor(struct libusb_device *dev, + active_config = priv->active_config; + } + +- if (active_config == 0) { ++ if (active_config == -1) { + usbi_err(DEVICE_CTX(dev), "device unconfigured"); + return LIBUSB_ERROR_NOT_FOUND; + } + +- r = op_get_config_descriptor_by_value(dev, active_config, &config_desc); ++ r = op_get_config_descriptor_by_value(dev, (uint8_t)active_config, &config_desc); + if (r < 0) + return r; + +@@ -863,17 +871,26 @@ static int usbfs_get_active_config(struct libusb_device *dev, int fd) + + /* we hit this error path frequently with buggy devices :( */ + usbi_warn(DEVICE_CTX(dev), "get configuration failed, errno=%d", errno); ++ ++ /* assume the current configuration is the first one if we have ++ * the configuration descriptors, otherwise treat the device ++ * as unconfigured. */ ++ if (priv->config_descriptors) ++ priv->active_config = (int)priv->config_descriptors[0].desc->bConfigurationValue; ++ else ++ priv->active_config = -1; + } else if (active_config == 0) { +- /* some buggy devices have a configuration 0, but we're +- * reaching into the corner of a corner case here, so let's +- * not support buggy devices in these circumstances. +- * stick to the specs: a configuration value of 0 means +- * unconfigured. */ +- usbi_warn(DEVICE_CTX(dev), "active cfg 0? assuming unconfigured device"); ++ if (dev_has_config0(dev)) { ++ /* some buggy devices have a configuration 0, but we're ++ * reaching into the corner of a corner case here. */ ++ priv->active_config = 0; ++ } else { ++ priv->active_config = -1; ++ } ++ } else { ++ priv->active_config = (int)active_config; + } + +- priv->active_config = active_config; +- + return LIBUSB_SUCCESS; + } + +@@ -1004,9 +1021,9 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum, + usbi_warn(ctx, "Missing rw usbfs access; cannot determine " + "active configuration descriptor"); + if (priv->config_descriptors) +- priv->active_config = priv->config_descriptors[0].desc->bConfigurationValue; ++ priv->active_config = (int)priv->config_descriptors[0].desc->bConfigurationValue; + else +- priv->active_config = 0; /* No config dt */ ++ priv->active_config = -1; /* No config dt */ + + return LIBUSB_SUCCESS; + } +@@ -1428,22 +1445,27 @@ static int op_get_configuration(struct libusb_device_handle *handle, + uint8_t *config) + { + struct linux_device_priv *priv = usbi_get_device_priv(handle->dev); ++ int active_config; + int r; + + if (priv->sysfs_dir) { +- r = sysfs_get_active_config(handle->dev, config); ++ r = sysfs_get_active_config(handle->dev, &active_config); + } else { + struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle); + + r = usbfs_get_active_config(handle->dev, hpriv->fd); + if (r == LIBUSB_SUCCESS) +- *config = priv->active_config; ++ active_config = priv->active_config; + } + if (r < 0) + return r; + +- if (*config == 0) +- usbi_err(HANDLE_CTX(handle), "device unconfigured"); ++ if (active_config == -1) { ++ usbi_warn(HANDLE_CTX(handle), "device unconfigured"); ++ active_config = 0; ++ } ++ ++ *config = (uint8_t)active_config; + + return 0; + } +@@ -1467,11 +1489,13 @@ static int op_set_configuration(struct libusb_device_handle *handle, int config) + return LIBUSB_ERROR_OTHER; + } + +- if (config == -1) +- config = 0; ++ /* if necessary, update our cached active config descriptor */ ++ if (!priv->sysfs_dir) { ++ if (config == 0 && !dev_has_config0(handle->dev)) ++ config = -1; + +- /* update our cached active config descriptor */ +- priv->active_config = (uint8_t)config; ++ priv->active_config = config; ++ } + + return LIBUSB_SUCCESS; + } diff --git a/baselibs.conf b/baselibs.conf new file mode 100644 index 0000000..e8f427b --- /dev/null +++ b/baselibs.conf @@ -0,0 +1,5 @@ +libusb-1_0-0 +libusb-1_0-devel + requires -libusb-1_0- + requires "libusb-1_0-0- = " + diff --git a/libusb-1_0.changes b/libusb-1_0.changes new file mode 100644 index 0000000..f524f2f --- /dev/null +++ b/libusb-1_0.changes @@ -0,0 +1,274 @@ +* Thu Sep 22 2022 jsikes@suse.com +- Added 0002-gracefully-handle-buggy-config0-devices.patch + * Fix regression where some buggy devices no longer work + if they have a configuration value of 0. + * [bsc#1201590] +* Sun Jan 17 2021 simon.vogl@gmx.net +- Add 0001-fix-descriptor-parsing.patch to fix detection of some devices. +* Thu Dec 10 2020 mardnh@gmx.de +- Update to version 1.0.24 + * Add new platform abstraction (#252). + * Add Null POSIX backend. + * Add support for eventfd. + * New API libusb_hotplug_get_user_data(). + * Linux: Drop support for kernel older than 2.6.32. + * Linux: Provide an event thread name. (#689). + * Linux: Wait until all USBs have been reaped before freeing + them. (#607) + * Documentation fixes and improvements. + * Various other bug fixes and improvements. +* Thu Aug 29 2019 mardnh@gmx.de +- Update to version 1.0.23 + * Core: abandon synchronous transfers when device closure is + detected. + * Core: fix error in handling the removal of file descriptors + while handling events. + * New API libusb_set_log_cb() to redirect global and per context + log messages to the provided log handling function. + * New API libusb_wrap_sys_device to allow the user to specify + the usb device to use. + * Various other bug fixes and improvements. +* Sun Mar 25 2018 mardnh@gmx.de +- Update to version 1.0.22 + * Core: Refactor code related to transfer flags and timeout handling + * Linux: Support preallocating kernel memory for zerocopy USB + * Linux: Deal with receiving POLLERR before all transfers have completed + * Prevent attempts to recursively handle events + * Fix race condition in handle_timeout() + * Allow transferred argument to be optional in bulk APIs + * Various other bug fixes and improvements + * Fix the inclusion of "sys/time.h" on PowerPC (bsc#1178376) +* Thu Mar 22 2018 jengelh@inai.de +- Fix SRPM group. +* Tue Mar 20 2018 tchvatal@suse.com +- Use dos2unix to generate the non-windows trailing on files +- Remove sle11 support as it got borged with last commit and + we don't mostly need it to build there +* Tue Mar 20 2018 kukuk@suse.de +- Use %%license instead of %%doc [bsc#1082318] +* Sun Oct 30 2016 mardnh@gmx.de +- Update to version 1.0.21 + * Core: Refactor code related to transfer flags and timeout handling + * Darwin: Ignore root hub simulation devices + * Darwin: Improved support for OS X El Capitan + * Darwin: Work around devices with buggy endpoint descriptors + * Darwin: Do not use objc_registerThreadWithCollector after its deprecation + * Darwin: Use C11 atomics on 10.12+ as the OS atomics are now deprecated + * Linux: Support preallocating kernel memory for zerocopy USB + * Linux: Deal with receiving POLLERR before all transfers have completed + * Solaris: Add solaris backend + * Windows: Add Visual Studio 2015 support + * Windows: Add usbdk backend + * Prevent attempts to recursively handle events + * Fix race condition in handle_timeout() + * Allow transferred argument to be optional in bulk APIs + * Various other bug fixes and improvements +- Fix source url +* Wed May 25 2016 idonmez@suse.com +- Update to GNOME 3.20.2 FATE#318572 +* Fri Oct 23 2015 olaf@aepfle.de +- Remove _smp_mflags usage to fix sporadic build errors +* Mon Sep 14 2015 mardnh@gmx.de +- Update to version 1.0.20: + * Add Haiku support + * Fix multiple memory and resource leaks (#16, #52, #76, #81) + * Fix possible deadlock when executing transfer callback + * New libusb_free_pollfds() API + * Darwin: Fix devices not being detected on OS X 10.8 (#48) + * Linux: Allow larger isochronous transfer submission (#23) + * Windows: Fix broken builds Cygwin/MinGW builds and compiler warnings + * Windows: Fix broken bus number lookup + * Windows: Improve submission of control requests for composite devices + * Examples: Add two-stage load support to fxload (#12) + * Correctly report cancellations due to timeouts + * Improve efficiency of event handling + * Improve speed of transfer submission in multi-threaded environments + * Various other bug fixes and improvements +* Wed Jul 23 2014 mardnh@gmx.de +- Update to version 1.0.19: + * Add support for USB bulk streams on Linux and Mac OS X (#11) + * Windows: Add AMD and Intel USB-3.0 root hub support + * Windows: Fix USB 3.0 speed detection on Windows 8 or later (#10) + * Added Russian translation for libusb_strerror strings + * All: Various small fixes and cleanups +* Wed May 21 2014 sbrabec@suse.cz +- Build with pkgconfig(libudev), not pkgconfig(udev). +* Fri Feb 7 2014 sbrabec@suse.cz +- New upstream, new home page. +- Update to version 1.0.18: + * API extensions: + * hotplug support + * topology support + * error processing, detaching, debugging etc. + * many fixes + * for more see ChangeLog +* Mon Apr 15 2013 mmeister@suse.com +- Added url as source. + Please see http://en.opensuse.org/SourceUrls +* Thu Apr 26 2012 sbrabec@suse.cz +- Use %%makeinstall instead of %%make_install to build on SLE11. +* Fri Apr 20 2012 dimstar@opensuse.org +- Update to version 1.0.9: + + Numerous bug fixes and improvements + + Backend for Windows, for devices using the WinUSB.sys driver + + Backend for OpenBSD and NetBSD, for devices using the ugen + driver + + Add libusb_get_device_speed() + + Add libusb_has_capability() + + Add libusb_error_name() + + Add libusb_get_version() +- Drop libtool BuildRequires and call to autoreconf: as we switched + to an officialy released tarball, there is no need to bootstrap + anymore. +* Tue Apr 3 2012 sbrabec@suse.cz +- Update to the latest git snapshot 6b1982b: + * Bug fixes. + * Support for USB 3.0. + * Add LIBUSB_TRANSFER_ADD_ZERO_PACKET flag. +* Sun Feb 12 2012 crrodriguez@opensuse.org +- Libraries back in %%{_libdir}, /usr merge project. +* Thu Nov 24 2011 dimstar@opensuse.org +- Update to version 1.0.9rc3: + + Fix memory leaks + + Factorize event handler interruption code + + Add Windows support + + Fix inconsistencies between prototypes and definitions + + Add libusb_error_name() API function. +* Sun Nov 20 2011 coolo@suse.com +- add libtool as buildrequire to avoid implicit dependency +* Wed Jun 1 2011 seife+obs@b1-systems.com +- move libusb from /usr to / to make it usable for other packages + and work around rpmlint stupidity +* Mon Jun 21 2010 opensuse@sukimashita.com +- Updated to version 1.0.8: + * Bug fixes and documentation tweaks + * Add more interface class definitions +- This release fixes a crash for kernel's with debug flag enabled +* Sat Apr 24 2010 coolo@novell.com +- buildrequire pkg-config to fix provides +* Tue Dec 15 2009 jengelh@medozas.de +- add baselibs.conf as a source +* Wed Dec 9 2009 aj@suse.de +- Create libusb-1_0-devel-32bit for grub2. +* Mon Nov 23 2009 sbrabec@suse.cz +- Updated to version 1.0.6: + * Increase libusb_handle_events() timeout to 60 seconds. + * Allows libusb applications to access multiple interfaces of the + same device in the same application. + * Use timerfd for timeout handling. + * Add support for the new URB_BULK_CONTINUATION flag. + * Support for transfer locking. + * More flexibility with monotonic clock. +* Tue Sep 8 2009 opensuse@sukimashita.com +- Updated to version 1.0.3: + * Bug fixes + * Allow sending zero length bulk packets + * Add libusb_get_max_iso_packet_size() +* Mon Jun 29 2009 sbrabec@suse.cz +- Updated to version 1.0.2: + * Bug fixes, see ChangeLog. +* Wed May 20 2009 sbrabec@suse.cz +- Updated to version 1.0.1: + * Bug fixes + * Darwin backend +* Thu Apr 9 2009 sbrabec@suse.cz +- Updated to version 1.0.0, the new official stable branch: + * Bug fixes + * Add libusb_attach_kernel_driver() +* Thu Feb 5 2009 crrodriguez@suse.de +- remove "la" files +* Mon Oct 6 2008 sbrabec@suse.cz +- Added baselibs.conf (bnc#432304). +* Wed Sep 24 2008 ro@suse.de +- fix debug package requires +* Wed Sep 10 2008 sbrabec@suse.cz +- Updated to version 0.9.3: + * New branch, new API. + * Introduced contexts to the API. + * Compatible with new Linux kernel features. + * Isochronous endpoint I/O + * Asynchronous I/O with per-URB style callbacks + * Zero threads (lightweight, uses main thread of calling + application) + * Exposure of poll fds to applications for good mainloop + integration +* Fri Sep 5 2008 sbrabec@suse.cz +- Split according to shared library policy. +- Disabled static library. +* Wed May 7 2008 schwab@suse.de +- Fix configure script. +* Thu Apr 10 2008 ro@suse.de +- added baselibs.conf file to build xxbit packages + for multilib support +* Wed May 23 2007 meissner@suse.de +- libusb main package no longer should provide libusb-devel. +- run ldconfig in %%post/%%postun +* Tue May 22 2007 olh@suse.de +- split libusb-devel package (#203989) +* Tue Apr 17 2007 sbrabec@suse.cz +- Provide libusb-devel. +* Sun Mar 5 2006 olh@suse.de +- update to 0.1.12 + endian fixes, memory leaks fixed +* Wed Jan 25 2006 mls@suse.de +- converted neededforbuild to BuildRequires +* Sat Jan 21 2006 olh@suse.de +- update to 0.1.11 + pkgconfig support + Workaround regression in 0.1.10 with multi-threaded applications +* Fri Dec 9 2005 olh@suse.de +- remove resmgr patch +* Wed Nov 16 2005 lnussel@suse.de +- prefer /dev/bus/usb over /proc/bus/usb +- disable resmgr patch, not needed for /dev/bus/usb anymore +* Wed Aug 10 2005 olh@suse.de +- add patch from Kay Sievers to look also into /dev/bus/usb +* Tue May 31 2005 olh@suse.de +- add libusb-libusb_la-dep.patch to allow make -j +* Fri May 27 2005 olh@suse.de +- update to 0.1.10a +* Thu May 26 2005 olh@suse.de +- fix compile warnings +- build as user +- split our resmgr patch +* Sat Mar 19 2005 meissner@suse.de +- fixed a filedescriptor leak. #73967 +* Sat Feb 21 2004 meissner@suse.de +- upgraded to 0.1.8 final. +* Thu Feb 5 2004 lnussel@suse.de +- add -lresmgr to output of libusb-config +* Mon Aug 25 2003 adrian@suse.de +- do not provide usb anymore, it is not needed for an update + and breaks rpm4 update concept +* Tue Jul 22 2003 meissner@suse.de +- Upgraded to 0.1.8beta (finally supports USB interrupt + tranfers). +- Forward ported resmgr patch. +* Wed May 14 2003 meissner@suse.de +- added libusb.la. +* Wed Mar 5 2003 meissner@suse.de +- the resmgr device finder part was adding all devices + to all USB busses, leading to confusion later on. Check + for correct busnumber. +* Mon Nov 18 2002 schwab@suse.de +- Fix use of AC_DIVERT_PUSH. +* Mon Nov 11 2002 okir@suse.de +- allow opening USB devices via the resource manager +* Tue Oct 15 2002 freitag@suse.de +- updated to 0.1.6a stable release to support more scanners +* Thu Feb 7 2002 meissner@suse.de +- updated to 0.1.5 stable release +* Mon Jan 21 2002 meissner@suse.de +- updated to latest CVS snapshot, so I can build gphoto2. +- use buildroot +* Sat Nov 3 2001 ro@suse.de +- call automake with "-a -f" +* Mon Sep 3 2001 ro@suse.de +- removed Obsoletes and Provides usbutils (package reanimated) +* Fri May 25 2001 adrian@suse.de +- update to libusb-0.1.3b +- rename package from usbutils to libusb +* Tue Dec 5 2000 schwab@suse.de +- Add %%suse_update_config. +* Thu Nov 30 2000 olaf@suse.de +- add usbutils 0.7 to SuSE dist, will replace the usb.rpm diff --git a/libusb-1_0.spec b/libusb-1_0.spec new file mode 100644 index 0000000..fe59597 --- /dev/null +++ b/libusb-1_0.spec @@ -0,0 +1,75 @@ +# +# spec file for package libusb-1_0 +# +# Copyright (c) 2022-2023 ZhuningOS +# + + +%define _name libusb +%define debug_package_requires libusb-1_0-0 = %{version}-%{release} +Name: libusb-1_0 +Version: 1.0.24 +Release: 150400.3.3.1 +Summary: USB Library +License: LGPL-2.1-or-later +Group: System/Hardware +URL: http://libusb.info/ +Source: https://github.com/libusb/libusb/releases/download/v%{version}/libusb-%{version}.tar.bz2 +Source1: baselibs.conf +# PATCH-FIX-UPSTREAM +Patch1: 0001-fix-descriptor-parsing.patch +# PATCH-FIX-UPSTREAM +Patch2: 0002-gracefully-handle-buggy-config0-devices.patch +BuildRequires: dos2unix +BuildRequires: pkgconfig +BuildRequires: pkgconfig(libudev) + +%description +Libusb is a library that allows userspace access to USB devices. + +%package -n libusb-1_0-0 +Summary: USB Library +Group: System/Libraries + +%description -n libusb-1_0-0 +Libusb is a library that allows userspace access to USB devices. + +%package devel +Summary: USB Library +Group: Development/Libraries/C and C++ +Requires: glibc-devel +Requires: libusb-1_0-0 = %{version} + +%description devel +Libusb is a library that allows userspace access to USB devices. + +%prep +%autosetup -p1 -n %{_name}-%{version} +dos2unix NEWS + +%build +%configure \ + --with-pic \ + --disable-silent-rules \ + --disable-static +make %{?_smp_mflags} + +%install +%make_install +find %{buildroot} -type f -name "*.la" -delete -print + +%post -n libusb-1_0-0 -p /sbin/ldconfig +%postun -n libusb-1_0-0 -p /sbin/ldconfig + +%files -n libusb-1_0-0 +%license COPYING +%doc AUTHORS ChangeLog NEWS README TODO +%{_libdir}/*.so.* + +%files devel +%doc PORTING +%{_includedir}/libusb-1.0 +%{_libdir}/*.so +%{_libdir}/pkgconfig/*.pc + +%changelog