https://bugs.freebsd.org/bugzilla/attachment.cgi?bugid=293567 Fix potential build error of tools/. If not told otherwise, configure will detect presence of glib20 and, if found, enable the build of "tools" (usbredirect client). Currently building this throws an error because libusb_set_options is not in FreeBSD's libusb currently. To get past that, patch usbredirect.c to skip the code that calls libusb_set_options - it is not necessary. It adjusts libusb log level based on usbredirect log level, but the user can use the LIBUSB_DEBUG environment variable to control the libusb log level. Add a CLIENT option which will install the usbredirect client tool if enabled (or explicitly disable "tools" if not). usbredirect depends on devel/glib20. Make CLIENT off by default to favor a lighter package by default. This could be set to be enabled by default in the future if it proves popular. While here, pet portclippy and sort plist. diff --git a/net/usbredir/Makefile b/net/usbredir/Makefile index 9d915e6d8cdc..a0f36ad26a5d 100644 --- a/net/usbredir/Makefile +++ b/net/usbredir/Makefile @@ -1,6 +1,7 @@ PORTNAME= usbredir -DISTVERSION= 0.9.0 DISTVERSIONPREFIX= ${PORTNAME}- +DISTVERSION= 0.9.0 +PORTREVISION= 1 CATEGORIES= net devel MAINTAINER= bofh@FreeBSD.org @@ -20,6 +21,14 @@ GNU_CONFIGURE= yes INSTALL_TARGET= install-strip +OPTIONS_DEFINE= CLIENT +OPTIONS_SUB= yes + +CLIENT_DESC= Include usbredir client + +CLIENT_LIB_DEPENDS= libgio-2.0.so:devel/glib20 +CLIENT_CONFIGURE_WITH= tools + post-patch: @${REINPLACE_CMD} 's|SOL_TCP|IPPROTO_TCP|' \ ${WRKSRC}/usbredirserver/usbredirserver.c diff --git a/net/usbredir/files/patch-tools_usbredirect.c b/net/usbredir/files/patch-tools_usbredirect.c new file mode 100644 index 000000000000..aaf301d676ed --- /dev/null +++ b/net/usbredir/files/patch-tools_usbredirect.c @@ -0,0 +1,28 @@ +FreeBSD's libusb does not have libusb_set_option. +Just skip the adjusting of libusb log level to avoid +a build error. + +The way to adjust the FreeBSD libusb log level is via passing options +to usb_init_context(3) or with the LIBUSB_DEBUG environment variable +- also read by usb_init_context(3). + +But that's more invasive patching for little benefit here. + +--- tools/usbredirect.c.orig 2021-04-02 15:42:05 UTC ++++ tools/usbredirect.c +@@ -528,11 +528,15 @@ main(int argc, char *argv[]) + /* Only allow libusb logging if log verbosity is uredirparser_debug_data + * (or higher), otherwise we disable it here while keeping usbredir's logs enable. */ + if (self->verbosity < usbredirparser_debug_data) { ++#if 0 + int ret = libusb_set_option(NULL, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_NONE); + if (ret != LIBUSB_SUCCESS) { + g_warning("error disabling libusb log level: %s", libusb_error_name(ret)); + goto end; + } ++#else ++ g_warning("libusb_set_option not available, so not reducing libusb log level based on usbredirect level (%d)", self->verbosity); ++#endif + } + + if (self->is_client) { diff --git a/net/usbredir/pkg-plist b/net/usbredir/pkg-plist index be40b9424b04..5c94a8721f04 100644 --- a/net/usbredir/pkg-plist +++ b/net/usbredir/pkg-plist @@ -1,16 +1,18 @@ +%%CLIENT%%bin/usbredirect include/usbredirfilter.h include/usbredirhost.h -include/usbredirproto.h include/usbredirparser.h -lib/libusbredirparser.a -lib/libusbredirparser.so -lib/libusbredirparser.so.1 -lib/libusbredirparser.so.1.0.2 +include/usbredirproto.h lib/libusbredirhost.a lib/libusbredirhost.so lib/libusbredirhost.so.1 lib/libusbredirhost.so.1.0.2 -libdata/pkgconfig/libusbredirparser-0.5.pc +lib/libusbredirparser.a +lib/libusbredirparser.so +lib/libusbredirparser.so.1 +lib/libusbredirparser.so.1.0.2 libdata/pkgconfig/libusbredirhost.pc -share/man/man1/usbredirserver.1.gz +libdata/pkgconfig/libusbredirparser-0.5.pc sbin/usbredirserver +%%CLIENT%%share/man/man1/usbredirect.1.gz +share/man/man1/usbredirserver.1.gz