ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/utils/hplip/patches/010-libusb_fix.patch b/external/subpack/utils/hplip/patches/010-libusb_fix.patch
new file mode 100644
index 0000000..b630c1c
--- /dev/null
+++ b/external/subpack/utils/hplip/patches/010-libusb_fix.patch
@@ -0,0 +1,33 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -110,7 +110,7 @@ libhpmud_la_SOURCES += io/hpmud/musb_lib
+ libhpmud_la_LDFLAGS += -lusb
+ else
+ libhpmud_la_SOURCES += io/hpmud/musb.c
+-libhpmud_la_CFLAGS += -I/usr/include/libusb-1.0
++libhpmud_la_CFLAGS += ${LIBUSB_1_0_CFLAGS}
+ libhpmud_la_LDFLAGS += -lusb-1.0
+ endif
+
+@@ -363,7 +363,7 @@ hpmudext_la_CFLAGS += -Iprotocol/discove
+ endif
+
+ if !LIBUSB01_BUILD
+-hpmudext_la_CFLAGS +=-I/usr/include/libusb-1.0
++hpmudext_la_CFLAGS += ${LIBUSB_1_0_CFLAGS}
+ endif
+ endif #!HPLIP_CLASS_DRIVER
+ # ui (qt3)
+--- a/configure.in
++++ b/configure.in
+@@ -611,6 +611,10 @@ if test "$class_driver" = "no" && test "
+ else
+ AC_CHECK_LIB([usb-1.0], [libusb_init], [LIBS="$LIBS"], [AC_MSG_ERROR([cannot find libusb 1.0 support], 2)])
+ AC_CHECK_HEADERS(libusb-1.0/libusb.h, ,[AC_MSG_ERROR([cannot find libusb-1.0-devel support], 11)])
++ PKG_CHECK_MODULES(LIBUSB_1_0, [ libusb-1.0 >= 1.0.0 ], have_libusb_1_0=yes, have_libusb_1_0=no)
++ if test "$have_libusb_1_0" = "yes"; then
++ CFLAGS="$CFLAGS $LIBUSB_1_0_CFLAGS"
++ fi
+ fi
+ fi
+
diff --git a/external/subpack/utils/hplip/patches/020-remove_cups_dep_on_scan.patch b/external/subpack/utils/hplip/patches/020-remove_cups_dep_on_scan.patch
new file mode 100644
index 0000000..b7dd6c0
--- /dev/null
+++ b/external/subpack/utils/hplip/patches/020-remove_cups_dep_on_scan.patch
@@ -0,0 +1,167 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -71,7 +71,7 @@ else
+ libsane_hpaio_la_LDFLAGS = -version-info 1:0:0
+ endif
+ # The following is a interlibrary dependency that must be compiled first.
+-libsane_hpaio_la_LIBADD = libhpip.la libhpmud.la libhpipp.la $(DBUS_LIBS) -lcups -ldl
++libsane_hpaio_la_LIBADD = libhpip.la libhpmud.la libhpipp.la $(DBUS_LIBS) -ldl
+ #libsane_hpaio_la_CFLAGS = -DWITH_NONAMESPACES -DSOAP_DEBUG
+ libsane_hpaio_la_CFLAGS = $(DBUS_CFLAGS) -Iprotocol
+
+--- a/scan/sane/hpaio.c
++++ b/scan/sane/hpaio.c
+@@ -34,7 +34,6 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <cups/cups.h>
+ #include "hpmud.h"
+
+ #ifdef HAVE_LIBAVAHI
+@@ -150,98 +149,6 @@ static int GetUriLine(char *buf, char *u
+ return i;
+ }
+
+-static int AddCupsList(char *uri, char ***printer)
+-{
+- int i, stat=1;
+-
+- /* Look for hp network URIs only. */
+- if (strncasecmp(uri, "hp:/net/", 8) !=0)
+- goto bugout;
+-
+- if (*printer == NULL)
+- {
+- /* Allocate array of string pointers. */
+- *printer = malloc(sizeof(char *) * MAX_DEVICE);
+- memset(*printer, 0, sizeof(char *) * MAX_DEVICE);
+- }
+-
+- /* Ignor duplicates (ie: printer queues using the same device). */
+- for (i=0; (*printer)[i] != NULL && i<MAX_DEVICE; i++)
+- {
+- if (strcmp((*printer)[i], uri) == 0)
+- goto bugout;
+- }
+-
+- /* Find empty slot in array of pointers. */
+- for (i=0; i<MAX_DEVICE; i++)
+- {
+- if ((*printer)[i] == NULL)
+- {
+- (*printer)[i] = strdup(uri);
+- break;
+- }
+- }
+-
+- stat = 0;
+-
+-bugout:
+-
+- return stat;
+-}
+-
+-
+-static int GetCupsPrinters(char ***printer)
+-{
+- http_t *http=NULL; /* HTTP object */
+- ipp_t *request=NULL; /* IPP request object */
+- ipp_t *response=NULL; /* IPP response object */
+- ipp_attribute_t *attr; /* Current IPP attribute */
+- int cnt=0;
+-
+- /* Connect to the HTTP server */
+- if ((http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption())) == NULL)
+- goto bugout;
+-
+- /* Assemble the IPP request */
+- request = ippNew();
+-
+- ippSetOperation( request, CUPS_GET_PRINTERS );
+- ippSetRequestId( request, 1 );
+-
+- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, "utf-8");
+- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, "en");
+- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", NULL, "device-uri");
+-
+- /* Send the request and get a response. */
+- if ((response = cupsDoRequest(http, request, "/")) == NULL)
+- goto bugout;
+-
+- for (attr = ippFirstAttribute ( response ); attr != NULL; attr = ippNextAttribute( response ))
+- {
+- /* Skip leading attributes until we hit a printer. */
+- while (attr != NULL && ippGetGroupTag( attr ) != IPP_TAG_PRINTER)
+- attr = ippNextAttribute( response );
+-
+- if (attr == NULL)
+- break;
+-
+- while (attr != NULL && ippGetGroupTag( attr ) == IPP_TAG_PRINTER)
+- {
+- if (strcmp(ippGetName( attr ), "device-uri") == 0 && ippGetValueTag( attr ) == IPP_TAG_URI && AddCupsList(ippGetString( attr, 0, NULL ), printer) == 0)
+- cnt++;
+- attr = ippNextAttribute( response );
+- }
+-
+- if (attr == NULL)
+- break;
+- }
+-
+- ippDelete(response);
+-
+- bugout:
+- return cnt;
+-}
+-
+ static int AddDevice(char *uri)
+ {
+ struct hpmud_model_attributes ma;
+@@ -294,7 +201,6 @@ static int DevDiscovery(int localOnly)
+ char uri[HPMUD_LINE_SIZE];
+ char *tail = message;
+ int i, scan_type, cnt=0, total=0, bytes_read;
+- char **cups_printer=NULL; /* list of printers */
+ char* token = NULL;
+ enum HPMUD_RESULT stat;
+
+@@ -308,38 +214,6 @@ static int DevDiscovery(int localOnly)
+ GetUriLine(tail, uri, &tail);
+ total += AddDevice(uri);
+ }
+- /* Look for Network Scan devices if localonly flag if FALSE. */
+- if (!localOnly)
+- {
+- /* Look for all-in-one scan devices for which print queue created */
+- cnt = GetCupsPrinters(&cups_printer);
+- for (i=0; i<cnt; i++)
+- {
+- total += AddDevice(cups_printer[i]);
+- free(cups_printer[i]);
+- }
+- if (cups_printer)
+- free(cups_printer);
+-#ifdef HAVE_LIBAVAHI
+- /* Discover NW scanners using Bonjour*/
+- if( (avahi_probe_nw_scanners() == AVAHI_STATUS_OK) && (aUriBuf != NULL) )
+- {
+- token = strtok(aUriBuf, ";");
+- while (token)
+- {
+- total += AddDevice(token);
+- token = strtok(NULL, ";");
+- }
+- free(aUriBuf);
+- aUriBuf = NULL;
+- }
+-#endif
+- if(!total)
+- {
+- SendScanEvent("hpaio:/net/HP_Scan_Devices?ip=1.1.1.1", EVENT_ERROR_NO_PROBED_DEVICES_FOUND);
+- }
+- }
+-
+ bugout:
+ return total;
+ }
diff --git a/external/subpack/utils/hplip/patches/030-replace_unsafe_memcpy_with_memmove.patch b/external/subpack/utils/hplip/patches/030-replace_unsafe_memcpy_with_memmove.patch
new file mode 100644
index 0000000..2babb2b
--- /dev/null
+++ b/external/subpack/utils/hplip/patches/030-replace_unsafe_memcpy_with_memmove.patch
@@ -0,0 +1,15 @@
+https://bugs.launchpad.net/hplip/+bug/1672256
+
+memcpy should never be used with overlapping memory regions
+
+--- a/io/hpmud/musb.c
++++ b/io/hpmud/musb.c
+@@ -775,7 +775,7 @@ static int device_id(int fd, unsigned ch
+ len = size-1; /* leave byte for zero termination */
+ if (len > 2)
+ len -= 2;
+- memcpy(buffer, buffer+2, len); /* remove length */
++ memmove(buffer, buffer+2, len); /* remove length */
+ buffer[len]=0;
+ DBG("read actual device_id successfully fd=%d len=%d\n", fd, len);
+
diff --git a/external/subpack/utils/hplip/patches/050-fix-glibcisms.patch b/external/subpack/utils/hplip/patches/050-fix-glibcisms.patch
new file mode 100644
index 0000000..82bb382
--- /dev/null
+++ b/external/subpack/utils/hplip/patches/050-fix-glibcisms.patch
@@ -0,0 +1,15 @@
+--- a/scan/sane/OrbliteScan/LinuxCommon.h
++++ b/scan/sane/OrbliteScan/LinuxCommon.h
+@@ -18,10 +18,8 @@ typedef u_int32_t UInt32;
+ typedef int32_t SInt32;
+ //typedef unsigned long UInt32;
+ //typedef signed long SInt32;
+-typedef __S64_TYPE SInt64;
+-typedef __U64_TYPE UInt64;
+-typedef __S64_TYPE int64_t;
+-typedef __U64_TYPE uint64_t;
++typedef int64_t SInt64;
++typedef uint64_t UInt64;
+
+ //typedef unsigned long ULONG;
+ //typedef void* LPVOID;
diff --git a/external/subpack/utils/hplip/patches/060-fix-glibc.patch b/external/subpack/utils/hplip/patches/060-fix-glibc.patch
new file mode 100644
index 0000000..6a35c74
--- /dev/null
+++ b/external/subpack/utils/hplip/patches/060-fix-glibc.patch
@@ -0,0 +1,15 @@
+Fix missing definition of uint64_t while compiling
+under uclibc or glibc
+
+https://bugs.launchpad.net/hplip/+bug/1826965
+
+--- a/scan/sane/OrbliteScan/LinuxCommon.h
++++ b/scan/sane/OrbliteScan/LinuxCommon.h
+@@ -2,6 +2,7 @@
+ #define H_LinuxCommon
+
+ #include <sys/types.h>
++#include <stdint.h>
+
+ /* Common typedefs for Linux */
+
diff --git a/external/subpack/utils/hplip/patches/070-respect-cflags.patch b/external/subpack/utils/hplip/patches/070-respect-cflags.patch
new file mode 100644
index 0000000..b76a673
--- /dev/null
+++ b/external/subpack/utils/hplip/patches/070-respect-cflags.patch
@@ -0,0 +1,29 @@
+--- a/configure.in
++++ b/configure.in
+@@ -618,14 +618,14 @@ if test "$class_driver" = "no" && test "
+ fi
+ fi
+
+-SAVE_CPPFLAGS="$CPPFLAGS"
++SAVE_CFLAGS="$CFLAGS"
+ CFLAGS=`python-config --includes`
+-if [ $? -eq 0 ]
++if test $? -eq 0
+ then
+ echo $FLAGS
+ else
+ CFLAGS=`python3-config --includes`
+- if [ $? -eq 0 ]
++ if test $? -eq 0
+ then
+ echo $FLAGS
+ fi
+@@ -645,7 +645,7 @@ if test "$class_driver" = "no" && test "
+ AS_IF([test "x$FOUND_HEADER" != "xyes"],
+ [AC_MSG_ERROR([cannot find python-devel support], 6)])
+ fi
+-CFLAGS="$save_CFLAGS"
++CFLAGS="$SAVE_CFLAGS"
+
+ if test "$hpijs_only_build" = "no" && test "$scan_build" = "yes" && test "$hpcups_only_build" = "no"; then
+ AC_CHECK_LIB([sane], [sane_open], [LIBS="$LIBS"], [AC_MSG_ERROR([cannot find sane-backends-devel support (or --disable-scan-build)], 12)])