--- Begin Message ---
Package: src:libusb-1.0
Version: 2:1.0.20-1
Severity: wishlist
The fact that libusb-1.0 is not available on Hurd block several hundred
packages that would otherwise work just fine without USB support on Hurd
from building in Debian. A fix for this, which I've been told was
present in the libusb 0.1 era, is to provide a Hurd backend for libusb
returning an empty list of USB devices. Would you be willing to include
such implementation?
The attached patch provide such stub implementation. It is tested on
the Hurd porter box.
--
Happy hacking
Petter Reinholdtsen
Description: Implement stub backend for Hurd
Author: Petter Reinholdtsen <p...@hungry.com>
---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:
Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2016-08-24
--- libusb-1.0-1.0.20.orig/config.h.in
+++ libusb-1.0-1.0.20/config.h.in
@@ -88,6 +88,9 @@
/* Haiku backend */
#undef OS_HAIKU
+/* Hurd backend */
+#undef OS_HURD
+
/* Linux backend */
#undef OS_LINUX
--- libusb-1.0-1.0.20.orig/configure
+++ libusb-1.0-1.0.20/configure
@@ -659,6 +659,8 @@ OS_NETBSD_FALSE
OS_NETBSD_TRUE
OS_OPENBSD_FALSE
OS_OPENBSD_TRUE
+OS_HURD_FALSE
+OS_HURD_TRUE
OS_DARWIN_FALSE
OS_DARWIN_TRUE
OS_LINUX_FALSE
@@ -667,6 +669,7 @@ OS_HAIKU
OS_WINDOWS
OS_NETBSD
OS_OPENBSD
+OS_HURD
OS_DARWIN
USE_UDEV
OS_LINUX
@@ -768,6 +771,7 @@ infodir
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -855,6 +859,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1107,6 +1112,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1244,7 +1258,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1397,6 +1411,7 @@ Fine tuning of the installation director
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -11933,6 +11948,12 @@ $as_echo "Darwin/Mac OS X" >&6; }
backend="darwin"
threads="posix"
;;
+*-gnu*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: Hurd" >&5
+$as_echo "Hurd" >&6; }
+ backend="hurd"
+ threads="posix"
+ ;;
*-openbsd*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: OpenBSD" >&5
$as_echo "OpenBSD" >&6; }
@@ -12207,6 +12228,29 @@ $as_echo "#define POLL_NFDS_TYPE unsigne
fi
;;
+hurd)
+
+$as_echo "#define OS_HURD 1" >>confdefs.h
+
+
+ THREAD_CFLAGS="-pthread"
+ LIBS="-pthread"
+ for ac_header in poll.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "poll.h" "ac_cv_header_poll_h" "$ac_includes_default"
+if test "x$ac_cv_header_poll_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_POLL_H 1
+_ACEOF
+
+fi
+
+done
+
+
+$as_echo "#define POLL_NFDS_TYPE nfds_t" >>confdefs.h
+
+ ;;
openbsd)
$as_echo "#define OS_OPENBSD 1" >>confdefs.h
@@ -12309,6 +12353,14 @@ else
OS_DARWIN_FALSE=
fi
+ if test "x$backend" = xhurd; then
+ OS_HURD_TRUE=
+ OS_HURD_FALSE='#'
+else
+ OS_HURD_TRUE='#'
+ OS_HURD_FALSE=
+fi
+
if test "x$backend" = xopenbsd; then
OS_OPENBSD_TRUE=
OS_OPENBSD_FALSE='#'
@@ -12830,6 +12882,10 @@ if test -z "${OS_DARWIN_TRUE}" && test -
as_fn_error $? "conditional \"OS_DARWIN\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${OS_HURD_TRUE}" && test -z "${OS_HURD_FALSE}"; then
+ as_fn_error $? "conditional \"OS_HURD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${OS_OPENBSD_TRUE}" && test -z "${OS_OPENBSD_FALSE}"; then
as_fn_error $? "conditional \"OS_OPENBSD\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
--- libusb-1.0-1.0.20.orig/configure.ac
+++ libusb-1.0-1.0.20/configure.ac
@@ -67,6 +67,11 @@ case $host in
backend="darwin"
threads="posix"
;;
+*-gnu*)
+ AC_MSG_RESULT([Hurd])
+ backend="hurd"
+ threads="posix"
+ ;;
*-openbsd*)
AC_MSG_RESULT([OpenBSD])
backend="openbsd"
@@ -149,6 +154,14 @@ darwin)
[AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])],
[#include <poll.h>])
;;
+hurd)
+ AC_DEFINE(OS_HURD, 1, [Hurd backend])
+ AC_SUBST(OS_HURD)
+ THREAD_CFLAGS="-pthread"
+ LIBS="-pthread"
+ AC_CHECK_HEADERS([poll.h])
+ AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
+ ;;
openbsd)
AC_DEFINE(OS_OPENBSD, 1, [OpenBSD backend])
AC_SUBST(OS_OPENBSD)
@@ -186,6 +199,7 @@ AC_SUBST(LIBS)
AM_CONDITIONAL(OS_LINUX, test "x$backend" = xlinux)
AM_CONDITIONAL(OS_DARWIN, test "x$backend" = xdarwin)
+AM_CONDITIONAL(OS_HURD, test "x$backend" = xhurd)
AM_CONDITIONAL(OS_OPENBSD, test "x$backend" = xopenbsd)
AM_CONDITIONAL(OS_NETBSD, test "x$backend" = xnetbsd)
AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows)
--- libusb-1.0-1.0.20.orig/libusb/core.c
+++ libusb-1.0-1.0.20/libusb/core.c
@@ -48,6 +48,8 @@
const struct usbi_os_backend * const usbi_backend = &linux_usbfs_backend;
#elif defined(OS_DARWIN)
const struct usbi_os_backend * const usbi_backend = &darwin_backend;
+#elif defined(OS_HURD)
+const struct usbi_os_backend * const usbi_backend = &hurd_backend;
#elif defined(OS_OPENBSD)
const struct usbi_os_backend * const usbi_backend = &openbsd_backend;
#elif defined(OS_NETBSD)
--- libusb-1.0-1.0.20.orig/libusb/libusbi.h
+++ libusb-1.0-1.0.20/libusb/libusbi.h
@@ -493,7 +493,7 @@ int usbi_signal_event(struct libusb_cont
int usbi_clear_event(struct libusb_context *ctx);
/* Internal abstraction for poll (needs struct usbi_transfer on Windows) */
-#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_HAIKU)
+#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_HURD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_HAIKU)
#include <unistd.h>
#include "os/poll_posix.h"
#elif defined(OS_WINDOWS) || defined(OS_WINCE)
@@ -1086,6 +1086,7 @@ extern const struct usbi_os_backend * co
extern const struct usbi_os_backend linux_usbfs_backend;
extern const struct usbi_os_backend darwin_backend;
+extern const struct usbi_os_backend hurd_backend;
extern const struct usbi_os_backend openbsd_backend;
extern const struct usbi_os_backend netbsd_backend;
extern const struct usbi_os_backend windows_backend;
--- /dev/null
+++ libusb-1.0-1.0.20/libusb/os/hurd_usb.c
@@ -0,0 +1,214 @@
+/*
+ * Copyright © 2016 Petter Reinholdtsen <p...@hungry.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Stup libusb implementation for GNU Hurd returning empty list of
+ * devices. This allow programs to build on Hurd without USB support
+ * without having to update a lot of build dependencies.
+ */
+
+#include "libusbi.h"
+
+static int
+hurd_init(struct libusb_context *ctx)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static int
+hurd_get_device_list(struct libusb_context * ctx,
+ struct discovered_devs **discdevs)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static int
+hurd_open(struct libusb_device_handle *handle)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static void
+hurd_close(struct libusb_device_handle *handle)
+{
+ usbi_dbg(__FUNCTION__);
+}
+
+static int
+hurd_get_device_descriptor(struct libusb_device *dev, unsigned char *buf,
+ int *host_endian)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+int
+hurd_get_active_config_descriptor(struct libusb_device *dev,
+ unsigned char *buf, size_t len, int *host_endian)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+int
+hurd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
+ unsigned char *buf, size_t len, int *host_endian)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static int
+hurd_get_configuration(struct libusb_device_handle *handle, int *config)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static int
+hurd_set_configuration(struct libusb_device_handle *handle, int config)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static int
+hurd_claim_interface(struct libusb_device_handle *handle, int iface)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static int
+hurd_release_interface(struct libusb_device_handle *handle, int iface)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static int
+hurd_set_interface_altsetting(struct libusb_device_handle *handle, int iface,
+ int altsetting)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static int
+hurd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static int
+hurd_reset_device(struct libusb_device_handle *handle)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static int
+hurd_alloc_streams(struct libusb_device_handle *handle,
+ uint32_t num_streams, unsigned char *endpoints, int num_endpoints)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static int
+hurd_free_streams(struct libusb_device_handle *handle,
+ unsigned char *endpoints, int num_endpoints)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+static void
+hurd_destroy_device(struct libusb_device *dev)
+{
+ usbi_dbg(__FUNCTION__);
+}
+
+static int
+hurd_submit_transfer(struct usbi_transfer *itransfer)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+int
+hurd_cancel_transfer(struct usbi_transfer *itransfer)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+void
+hurd_clear_transfer_priv(struct usbi_transfer *itransfer)
+{
+ usbi_dbg(__FUNCTION__);
+}
+
+int
+hurd_handle_transfer_completion(struct usbi_transfer *itransfer)
+{
+ usbi_dbg(__FUNCTION__);
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
+
+int
+hurd_clock_gettime(int clkid, struct timespec *tp)
+{
+ usbi_dbg("clock %d", clkid);
+
+ if (clkid == USBI_CLOCK_REALTIME)
+ return clock_gettime(CLOCK_REALTIME, tp);
+
+ if (clkid == USBI_CLOCK_MONOTONIC)
+ return clock_gettime(CLOCK_MONOTONIC, tp);
+
+ return (LIBUSB_ERROR_INVALID_PARAM);
+}
+
+const struct usbi_os_backend hurd_backend = {
+ .name = "Synchronous Hurd backend",
+ .caps = 0,
+ .init = hurd_init,
+ .get_device_list = hurd_get_device_list,
+ .open = hurd_open,
+ .close = hurd_close,
+ .get_device_descriptor = hurd_get_device_descriptor,
+ .get_active_config_descriptor = hurd_get_active_config_descriptor,
+ .get_config_descriptor = hurd_get_config_descriptor,
+ .set_configuration = hurd_set_configuration,
+ .claim_interface = hurd_claim_interface,
+ .release_interface = hurd_release_interface,
+ .set_interface_altsetting = hurd_set_interface_altsetting,
+ .clear_halt = hurd_clear_halt,
+ .reset_device = hurd_reset_device,
+ .alloc_streams = hurd_alloc_streams,
+ .free_streams = hurd_free_streams,
+ .submit_transfer = hurd_submit_transfer,
+ .cancel_transfer = hurd_cancel_transfer,
+ .clear_transfer_priv = hurd_clear_transfer_priv,
+ .clock_gettime = hurd_clock_gettime,
+};
--- End Message ---