perl-device-usb: New package
authorMarcel Denia <naoir@gmx.net>
Thu, 10 Sep 2015 14:12:35 +0000 (16:12 +0200)
committerMarcel Denia <naoir@gmx.net>
Mon, 14 Sep 2015 13:33:18 +0000 (15:33 +0200)
Signed-off-by: Marcel Denia <naoir@gmx.net>
lang/perl-device-usb/Makefile [new file with mode: 0644]
lang/perl-device-usb/README.patches [new file with mode: 0644]
lang/perl-device-usb/patches/100-fix_buildsystem.patch [new file with mode: 0644]
lang/perl-device-usb/patches/110-just_assume_libusb_is_there.diff [new file with mode: 0644]
lang/perl-device-usb/patches/120-use_libusb_0_1.patch [new file with mode: 0644]
lang/perl-device-usb/patches/130-provide-proper-library-paths.patch [new file with mode: 0644]
lang/perl-device-usb/patches/140-avoid-libusb-name-conflicts.patch [new file with mode: 0644]

diff --git a/lang/perl-device-usb/Makefile b/lang/perl-device-usb/Makefile
new file mode 100644 (file)
index 0000000..f2baeed
--- /dev/null
@@ -0,0 +1,75 @@
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=perl-device-usb
+PKG_VERSION:=0.36
+PKG_RELEASE:=1
+
+PKG_SOURCE_URL:=http://www.cpan.org/authors/id/G/GW/GWADEJ/
+PKG_SOURCE:=Device-USB-$(PKG_VERSION).tar.gz
+PKG_MD5SUM:=aa91bee777f7ed7a18225a84f8795344
+
+PKG_LICENSE:=GPL-1.0+ Artistic-1.0-Perl
+PKG_MAINTAINER:=Marcel Denia <naoir@gmx.net>
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/perl/Device-USB-$(PKG_VERSION)
+PKG_BUILD_DEPENDS:=perl-inline-c/host
+
+include $(INCLUDE_DIR)/package.mk
+include ../perl/perlmod.mk
+
+define Package/perl-device-usb
+  SUBMENU:=Perl
+  SECTION:=lang
+  CATEGORY:=Languages
+  TITLE:=libusb library wrapper
+  URL:=http://search.cpan.org/dist/Device-USB/
+  DEPENDS:=perl +libusb-compat +perl-inline +perl-inline-c +perlbase-essential +perlbase-test
+endef
+
+# Device::USB will generate a second Makefile.PL to build it's native code
+# using Inline::C under _Inline/. The goal here is to prevent Inline::C from
+# running that one automatically, as we need to supply a bunch of overrides via
+# perlmod/Configure.
+# _INLINE_C_NO_COMPILE_ is an OpenWRT-specific environment variable to Inline::C
+# that does just that.
+define Build/Configure
+       $(call perlmod/Configure,,)
+       
+       # Prepare a library directory where we can link againt lusb-0.1(as
+       # opposed to -lusb) to avoid confusion at runtime
+       mkdir $(PKG_BUILD_DIR)/syslib
+       $(LN) $(STAGING_DIR)/usr/lib/libusb.so $(PKG_BUILD_DIR)/syslib/libusb-0.1.so
+       
+       # Generate _Inline
+       $(call perlmod/Compile,config,LIBUSB_LIBDIR=$(PKG_BUILD_DIR)/syslib \
+                                     _INLINE_C_NO_COMPILE_=1 \
+                                     _INLINE_C_SYSTEM_TYPEMAP_=$(STAGING_DIR)/usr/lib/perl5/$(PERL_VERSION)/ExtUtils/typemap)
+       $(call perlmod/Compile,dynamic,_INLINE_C_NO_COMPILE_=1)
+       
+       # Configure _Inline
+       $(call perlmod/Configure,SITELIB=/foo,LIBUSB_INCDIR=$(STAGING_DIR)/usr/include/ \
+                                 LIBUSB_LIBDIR=$(STAGING_DIR)/usr/lib/ \
+                               ,$(PKG_BUILD_DIR)/_Inline/build/Device/USB)
+       
+       # Prevent re-configuring Inline code
+       sed 's/^dynamic :: D.*$$$$//' -i $(PKG_BUILD_DIR)/Makefile
+endef
+
+define Build/Compile
+       $(call perlmod/Compile,,,$(PKG_BUILD_DIR)/_Inline/build/Device/USB)
+       $(call perlmod/Compile,,)
+endef
+
+define Package/perl-device-usb/install
+        $(call perlmod/Install,$(1),Device auto/Device)
+endef
+
+
+$(eval $(call BuildPackage,perl-device-usb))
diff --git a/lang/perl-device-usb/README.patches b/lang/perl-device-usb/README.patches
new file mode 100644 (file)
index 0000000..66ece00
--- /dev/null
@@ -0,0 +1,8 @@
+This package contains some patches taken directly from Debian Jessie(stable at 
+the time of writing). 
+Namely, these are:
+- 100-fix_buildsystem.patch
+- 110-just_assume_libusb_is_there.diff
+
+The other patches are specific to OpenWRT, fixing bugs and resolving conflicts
+where necessary.
\ No newline at end of file
diff --git a/lang/perl-device-usb/patches/100-fix_buildsystem.patch b/lang/perl-device-usb/patches/100-fix_buildsystem.patch
new file mode 100644 (file)
index 0000000..5201894
--- /dev/null
@@ -0,0 +1,20 @@
+Description: Ignore files we do not want installed.
+Forwarded: not-needed
+Author: Tim Retout <diocles@debian.org>
+Reviewed-by: gregor herrmann <gregoa@debian.org>
+Last-Update: 2013-10-28
+
+--- a/Makefile.PL
++++ b/Makefile.PL
+@@ -2,6 +2,11 @@
+ use warnings;
+ use Inline::MakeMaker;
++sub MY::libscan {
++      return if ($_[1] eq 'USB.pm' or $_[1] eq 'dump_usb.pl');
++      return $_[1];
++}
++
+ if($^O eq 'MSWin32')
+ {
+     if(!$ENV{LIBUSB_LIBDIR} or !$ENV{LIBUSB_INCDIR})
diff --git a/lang/perl-device-usb/patches/110-just_assume_libusb_is_there.diff b/lang/perl-device-usb/patches/110-just_assume_libusb_is_there.diff
new file mode 100644 (file)
index 0000000..9365eb4
--- /dev/null
@@ -0,0 +1,30 @@
+Subject: Just assume libusb is out there
+ Makefile.PL should not try to check for libusb in a given list of directories
+ as the compiler might look in other places as well.
+Origin: vendor
+Bug-Debian: http://bugs.debian.org/639677
+Forwarded: not-needed
+From: Ansgar Burchardt <ansgar@debian.org>
+Reviewed-by: gregor herrmann <gregoa@debian.org>
+Last-Update: 2013-10-28
+
+--- libdevice-usb-perl.orig/Makefile.PL
++++ libdevice-usb-perl/Makefile.PL
+@@ -21,7 +21,7 @@
+     }
+ }
+-unless(header_found())
++unless(1 || header_found())
+ {
+     die <<"END";
+ ERROR: Can't find usb.h header.
+@@ -36,7 +36,7 @@
+ END
+ }
+-unless(lib_found())
++unless(1 || lib_found())
+ {
+     die <<"END";
+ ERROR: Can't find libusb library.
diff --git a/lang/perl-device-usb/patches/120-use_libusb_0_1.patch b/lang/perl-device-usb/patches/120-use_libusb_0_1.patch
new file mode 100644 (file)
index 0000000..7d43e73
--- /dev/null
@@ -0,0 +1,13 @@
+--- a/lib/Device/USB.pm
++++ b/lib/Device/USB.pm
+@@ -9,8 +9,8 @@ use Inline (
+         C => "DATA",
+         ($ENV{LIBUSB_LIBDIR}
+             ? ( LIBS => "-L\"$ENV{LIBUSB_LIBDIR}\" " .
+-                        ($^O eq 'MSWin32' ? ' -llibusb -L\"$ENV{WINDDK}\\lib\\crt\\i386\" -lmsvcrt ' : '-lusb') )
+-            : ( LIBS => '-lusb', )
++                        ($^O eq 'MSWin32' ? ' -llibusb -L\"$ENV{WINDDK}\\lib\\crt\\i386\" -lmsvcrt ' : '-lusb-0.1') )
++            : ( LIBS => '-lusb-0.1', )
+         ),
+         ($ENV{LIBUSB_INCDIR} ? ( INC => "-I\"$ENV{LIBUSB_INCDIR}\"" ) : () ),
+         NAME => 'Device::USB',
diff --git a/lang/perl-device-usb/patches/130-provide-proper-library-paths.patch b/lang/perl-device-usb/patches/130-provide-proper-library-paths.patch
new file mode 100644 (file)
index 0000000..3fce75a
--- /dev/null
@@ -0,0 +1,13 @@
+--- a/lib/Device/USB.pm
++++ b/lib/Device/USB.pm
+@@ -8,8 +8,8 @@ use Carp;
+ use Inline (
+         C => "DATA",
+         ($ENV{LIBUSB_LIBDIR}
+-            ? ( LIBS => "-L\"$ENV{LIBUSB_LIBDIR}\" " .
+-                        ($^O eq 'MSWin32' ? ' -llibusb -L\"$ENV{WINDDK}\\lib\\crt\\i386\" -lmsvcrt ' : '-lusb-0.1') )
++            ? ( LIBS => "-L$ENV{LIBUSB_LIBDIR} " .
++                        ($^O eq 'MSWin32' ? ' -llibusb -L$ENV{WINDDK}\\lib\\crt\\i386 -lmsvcrt ' : '-lusb-0.1') )
+             : ( LIBS => '-lusb-0.1', )
+         ),
+         ($ENV{LIBUSB_INCDIR} ? ( INC => "-I\"$ENV{LIBUSB_INCDIR}\"" ) : () ),
diff --git a/lang/perl-device-usb/patches/140-avoid-libusb-name-conflicts.patch b/lang/perl-device-usb/patches/140-avoid-libusb-name-conflicts.patch
new file mode 100644 (file)
index 0000000..55e5cc3
--- /dev/null
@@ -0,0 +1,219 @@
+--- a/lib/Device/USB.pm
++++ b/lib/Device/USB.pm
+@@ -15,6 +15,7 @@ use Inline (
+         ($ENV{LIBUSB_INCDIR} ? ( INC => "-I\"$ENV{LIBUSB_INCDIR}\"" ) : () ),
+         NAME => 'Device::USB',
+         VERSION => '0.36',
++        PREFIX => 'deviceusb_',
+    );
+ Inline->init();
+@@ -540,74 +541,74 @@ unsigned DeviceUSBDebugLevel()
+     return debugLevel;
+ }
+-void libusb_init()
++void deviceusb_libusb_init()
+ {
+     usb_init();
+ }
+-int libusb_find_busses()
++int deviceusb_libusb_find_busses()
+ {
+     return usb_find_busses();
+ }
+-int libusb_find_devices()
++int deviceusb_libusb_find_devices()
+ {
+     return usb_find_devices();
+ }
+-void *libusb_get_busses()
++void *deviceusb_libusb_get_busses()
+ {
+     return usb_get_busses();
+ }
+-void *libusb_open(void *dev)
++void *deviceusb_libusb_open(void *dev)
+ {
+     return usb_open( (struct usb_device*)dev );
+ }
+-int libusb_close(void *dev)
++int deviceusb_libusb_close(void *dev)
+ {
+     return usb_close((usb_dev_handle *)dev);
+ }
+-int libusb_set_configuration(void *dev, int configuration)
++int deviceusb_libusb_set_configuration(void *dev, int configuration)
+ {
+     if(DeviceUSBDebugLevel())
+     {
+-        printf( "libusb_set_configuration( %d )\n", configuration );
++        printf( "deviceusb_libusb_set_configuration( %d )\n", configuration );
+     }
+     return usb_set_configuration((usb_dev_handle *)dev, configuration);
+ }
+-int libusb_set_altinterface(void *dev, int alternate)
++int deviceusb_libusb_set_altinterface(void *dev, int alternate)
+ {
+     if(DeviceUSBDebugLevel())
+     {
+-        printf( "libusb_set_altinterface( %d )\n", alternate );
++        printf( "deviceusb_libusb_set_altinterface( %d )\n", alternate );
+     }
+     return usb_set_altinterface((usb_dev_handle *)dev, alternate);
+ }
+-int libusb_clear_halt(void *dev, unsigned int ep)
++int deviceusb_libusb_clear_halt(void *dev, unsigned int ep)
+ {
+     if(DeviceUSBDebugLevel())
+     {
+-        printf( "libusb_clear_halt( %d )\n", ep );
++        printf( "deviceusb_libusb_clear_halt( %d )\n", ep );
+     }
+     return usb_clear_halt((usb_dev_handle *)dev, ep);
+ }
+-int libusb_reset(void *dev)
++int deviceusb_libusb_reset(void *dev)
+ {
+     return usb_reset((usb_dev_handle *)dev);
+ }
+-int libusb_get_driver_np(void *dev, int interface, char *name, unsigned int namelen)
++int deviceusb_libusb_get_driver_np(void *dev, int interface, char *name, unsigned int namelen)
+ {
+     int ret = 0;
+     if(DeviceUSBDebugLevel())
+     {
+-        printf( "libusb_get_driver_np( %d )\n", interface );
++        printf( "deviceusb_libusb_get_driver_np( %d )\n", interface );
+     }
+ #if LIBUSB_HAS_GET_DRIVER_NP
+     ret = usb_get_driver_np((usb_dev_handle *)dev, interface, name, namelen);
+@@ -618,11 +619,11 @@ int libusb_get_driver_np(void *dev, int
+ #endif
+ }
+-int libusb_detach_kernel_driver_np(void *dev, int interface)
++int deviceusb_libusb_detach_kernel_driver_np(void *dev, int interface)
+ {
+     if(DeviceUSBDebugLevel())
+     {
+-        printf( "libusb_detach_kernel_driver_np( %d )\n", interface );
++        printf( "deviceusb_libusb_detach_kernel_driver_np( %d )\n", interface );
+     }
+ #if LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
+     return usb_detach_kernel_driver_np((usb_dev_handle *)dev, interface);
+@@ -631,25 +632,25 @@ int libusb_detach_kernel_driver_np(void
+ #endif
+ }
+-int libusb_claim_interface(void *dev, int interface)
++int deviceusb_libusb_claim_interface(void *dev, int interface)
+ {
+     if(DeviceUSBDebugLevel())
+     {
+-        printf( "libusb_claim_interface( %d )\n", interface );
++        printf( "deviceusb_libusb_claim_interface( %d )\n", interface );
+     }
+     return usb_claim_interface((usb_dev_handle *)dev, interface);
+ }
+-int libusb_release_interface(void *dev, int interface)
++int deviceusb_libusb_release_interface(void *dev, int interface)
+ {
+     if(DeviceUSBDebugLevel())
+     {
+-        printf( "libusb_release_interface( %d )\n", interface );
++        printf( "deviceusb_libusb_release_interface( %d )\n", interface );
+     }
+     return usb_release_interface((usb_dev_handle *)dev, interface);
+ }
+-void libusb_control_msg(void *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout)
++void deviceusb_libusb_control_msg(void *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout)
+ {
+     int i = 0;
+     int retval = 0;
+@@ -658,7 +659,7 @@ void libusb_control_msg(void *dev, int r
+     if(DeviceUSBDebugLevel())
+     {
+-        printf( "libusb_control_msg( %#04x, %#04x, %#04x, %#04x, %p, %d, %d )\n",
++        printf( "deviceusb_libusb_control_msg( %#04x, %#04x, %#04x, %#04x, %p, %d, %d )\n",
+             requesttype, request, value, index, bytes, size, timeout
+         );
+         /* maybe need to add support for printing the bytes string. */
+@@ -691,54 +692,54 @@ void libusb_control_msg(void *dev, int r
+     Inline_Stack_Done;
+ }
+-int libusb_get_string(void *dev, int index, int langid, char *buf, size_t buflen)
++int deviceusb_libusb_get_string(void *dev, int index, int langid, char *buf, size_t buflen)
+ {
+     if(DeviceUSBDebugLevel())
+     {
+-        printf( "libusb_get_string( %d, %d, %p, %lu )\n",
++        printf( "deviceusb_libusb_get_string( %d, %d, %p, %lu )\n",
+             index, langid, buf, (unsigned long)buflen
+         );
+     }
+     return usb_get_string((usb_dev_handle *)dev, index, langid, buf, buflen);
+ }
+-int libusb_get_string_simple(void *dev, int index, char *buf, size_t buflen)
++int deviceusb_libusb_get_string_simple(void *dev, int index, char *buf, size_t buflen)
+ {
+     if(DeviceUSBDebugLevel())
+     {
+-        printf( "libusb_get_string_simple( %d, %p, %lu )\n",
++        printf( "deviceusb_libusb_get_string_simple( %d, %p, %lu )\n",
+             index, buf, (unsigned long)buflen
+         );
+     }
+     return usb_get_string_simple((usb_dev_handle *)dev, index, buf, buflen);
+ }
+-int libusb_get_descriptor(void *dev, unsigned char type, unsigned char index, char *buf, int size)
++int deviceusb_libusb_get_descriptor(void *dev, unsigned char type, unsigned char index, char *buf, int size)
+ {
+     return usb_get_descriptor((usb_dev_handle *)dev, type, index, buf, size);
+ }
+-int libusb_get_descriptor_by_endpoint(void *dev, int ep, unsigned char type, unsigned char index, char *buf, int size)
++int deviceusb_libusb_get_descriptor_by_endpoint(void *dev, int ep, unsigned char type, unsigned char index, char *buf, int size)
+ {
+     return usb_get_descriptor_by_endpoint((usb_dev_handle *)dev, ep, type, index, buf, size);
+ }
+-int libusb_bulk_write(void *dev, int ep, char *bytes, int size, int timeout)
++int deviceusb_libusb_bulk_write(void *dev, int ep, char *bytes, int size, int timeout)
+ {
+     return usb_bulk_write((usb_dev_handle *)dev, ep, bytes, size, timeout);
+ }
+-int libusb_bulk_read(void *dev, int ep, char *bytes, int size, int timeout)
++int deviceusb_libusb_bulk_read(void *dev, int ep, char *bytes, int size, int timeout)
+ {
+     return usb_bulk_read((usb_dev_handle *)dev, ep, bytes, size, timeout);
+ }
+-int libusb_interrupt_write(void *dev, int ep, char *bytes, int size, int timeout)
++int deviceusb_libusb_interrupt_write(void *dev, int ep, char *bytes, int size, int timeout)
+ {
+     return usb_interrupt_write((usb_dev_handle *)dev, ep, bytes, size, timeout);
+ }
+-int libusb_interrupt_read(void *dev, int ep, char *bytes, int size, int timeout)
++int deviceusb_libusb_interrupt_read(void *dev, int ep, char *bytes, int size, int timeout)
+ {
+     return usb_interrupt_read((usb_dev_handle *)dev, ep, bytes, size, timeout);
+ }