packages: cups/cups.spec, cups/cups-avahi-1-config.patch (NEW), cups/cups-a...
glen
glen at pld-linux.org
Wed Dec 14 23:15:12 CET 2011
Author: glen Date: Wed Dec 14 22:15:12 2011 GMT
Module: packages Tag: HEAD
---- Log message:
- enable dnssd via avahi (using patches from fedora)
---- Files affected:
packages/cups:
cups.spec (1.308 -> 1.309) , cups-avahi-1-config.patch (NONE -> 1.1) (NEW), cups-avahi-2-backend.patch (NONE -> 1.1) (NEW), cups-avahi-3-timeouts.patch (NONE -> 1.1) (NEW), cups-avahi-4-poll.patch (NONE -> 1.1) (NEW), cups-avahi-5-services.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: packages/cups/cups.spec
diff -u packages/cups/cups.spec:1.308 packages/cups/cups.spec:1.309
--- packages/cups/cups.spec:1.308 Wed Dec 14 23:11:30 2011
+++ packages/cups/cups.spec Wed Dec 14 23:15:07 2011
@@ -2,7 +2,8 @@
#
# Conditional build:
%bcond_with gnutls # use GNU TLS for SSL/TLS support (instead of OpenSSL)
-%bcond_without dnssd # DNS Service Discovery support
+%bcond_with dnssd # DNS Service Discovery support (obsoleted by Avahi patch)
+%bcond_without avahi # DNS Service Discovery support via Avahi
%bcond_without ldap # do not include LDAP support
%bcond_without gssapi # do not include GSSAPI support
%bcond_without php # don't build PHP extension/support in web interface
@@ -10,15 +11,14 @@
%bcond_without python # don't build Python support in web interface
%bcond_without slp # do not include SLP support
%bcond_without static_libs # don't build static library
-#
-%include /usr/lib/rpm/macros.perl
-%define pdir CUPS
+%define pdir CUPS
+%include /usr/lib/rpm/macros.perl
Summary(pl.UTF-8): Ogólny system druku dla Uniksa
Summary(pt_BR.UTF-8): Sistema Unix de Impressão
Name: cups
Version: 1.5.0
-Release: 5
+Release: 6
Epoch: 1
License: LGPL v2 (libraries), GPL v2 (the rest) + openssl exception
Group: Applications/Printing
@@ -45,11 +45,18 @@
Patch12: %{name}-desktop.patch
Patch13: %{name}-ssl-segfault.patch
Patch14: %{name}-auth.patch
+# avahi patches from fedora
+Patch100: %{name}-avahi-1-config.patch
+Patch101: %{name}-avahi-2-backend.patch
+Patch102: %{name}-avahi-3-timeouts.patch
+Patch103: %{name}-avahi-4-poll.patch
+Patch104: %{name}-avahi-5-services.patch
URL: http://www.cups.org/
BuildRequires: acl-devel
BuildRequires: autoconf >= 2.60
BuildRequires: automake
-%{?with_dnssd:BuildRequires: avahi-compat-libdns_sd-devel}
+%{?with_dnssd:BuildRequires: avahi-compat-libdns_sd-devel}
+%{?with_avahi:BuildRequires: avahi-devel}
BuildRequires: dbus-devel
BuildRequires: glibc-headers
%{?with_gnutls:BuildRequires: gnutls-devel}
@@ -317,6 +324,12 @@
%patch13 -p0
%patch14 -p0
+%patch100 -p1
+%patch101 -p1
+%patch102 -p1
+%patch103 -p1
+%patch104 -p1
+
%build
%{__aclocal} -I config-scripts
%{__autoconf}
@@ -333,6 +346,7 @@
--enable-shared \
--enable-ssl \
%{?debug:--enable-debug} \
+ --%{!?with_avahi:dis}%{?with_avahi:en}able-avahi \
--%{!?with_dnssd:dis}%{?with_dnssd:en}able-dnssd \
--%{!?with_ldap:dis}%{?with_ldap:en}able-ldap \
--%{!?with_gssapi:dis}%{?with_gssapi:en}able-gssapi \
@@ -520,11 +534,13 @@
%lang(pl) %{_ulibdir}/cups/cgi-bin/pl
%lang(ru) %{_ulibdir}/cups/cgi-bin/ru
+%attr(755,root,root) %{_ulibdir}/cups/backend/dnssd
%attr(755,root,root) %{_ulibdir}/cups/backend/http
%attr(755,root,root) %{_ulibdir}/cups/backend/https
%attr(755,root,root) %{_ulibdir}/cups/backend/ipp
%attr(755,root,root) %{_ulibdir}/cups/backend/ipps
%attr(755,root,root) %{_ulibdir}/cups/backend/lpd
+%attr(755,root,root) %{_ulibdir}/cups/backend/mdns
%attr(755,root,root) %{_ulibdir}/cups/backend/snmp
%attr(755,root,root) %{_ulibdir}/cups/backend/socket
%attr(755,root,root) %{_ulibdir}/cups/daemon/cups-deviced
@@ -739,6 +755,9 @@
All persons listed below can be reached at <cvs_login>@pld-linux.org
$Log$
+Revision 1.309 2011/12/14 22:15:07 glen
+- enable dnssd via avahi (using patches from fedora)
+
Revision 1.308 2011/12/14 22:11:30 glen
- do not use glob, list all backends to be sure they don't go missing!
================================================================
Index: packages/cups/cups-avahi-1-config.patch
diff -u /dev/null packages/cups/cups-avahi-1-config.patch:1.1
--- /dev/null Wed Dec 14 23:15:12 2011
+++ packages/cups/cups-avahi-1-config.patch Wed Dec 14 23:15:07 2011
@@ -0,0 +1,42 @@
+diff -up cups-1.5.0/config.h.in.avahi-1-config cups-1.5.0/config.h.in
+--- cups-1.5.0/config.h.in.avahi-1-config 2011-06-16 21:12:16.000000000 +0100
++++ cups-1.5.0/config.h.in 2011-08-05 15:04:09.535759988 +0100
+@@ -390,6 +390,13 @@
+
+
+ /*
++ * Do we have Avahi for DNS Service Discovery?
++ */
++
++#undef HAVE_AVAHI
++
++
++/*
+ * Do we have <sys/ioctl.h>?
+ */
+
+diff -up cups-1.5.0/config-scripts/cups-dnssd.m4.avahi-1-config cups-1.5.0/config-scripts/cups-dnssd.m4
+--- cups-1.5.0/config-scripts/cups-dnssd.m4.avahi-1-config 2011-05-12 06:21:56.000000000 +0100
++++ cups-1.5.0/config-scripts/cups-dnssd.m4 2011-08-05 15:04:09.525760307 +0100
+@@ -23,6 +23,21 @@ AC_ARG_WITH(dnssd-includes, [ --with-dn
+ DNSSDLIBS=""
+ DNSSD_BACKEND=""
+
++AC_ARG_ENABLE(avahi, [ --enable-avahi turn on DNS Service Discovery support, default=no],
++ [if test x$enable_avahi = xyes; then
++ AC_MSG_CHECKING(for Avahi)
++ if $PKGCONFIG --exists avahi-client; then
++ AC_MSG_RESULT(yes)
++ CFLAGS="$CFLAGS `$PKGCONFIG --cflags avahi-client`"
++ DNSSDLIBS="`$PKGCONFIG --libs avahi-client`"
++ DNSSD_BACKEND="dnssd"
++ AC_DEFINE(HAVE_AVAHI)
++ enable_dnssd=no
++ else
++ AC_MSG_RESULT(no)
++ fi
++ fi])
++
+ if test x$enable_dnssd != xno; then
+ AC_CHECK_HEADER(dns_sd.h, [
+ case "$uname" in
================================================================
Index: packages/cups/cups-avahi-2-backend.patch
diff -u /dev/null packages/cups/cups-avahi-2-backend.patch:1.1
--- /dev/null Wed Dec 14 23:15:12 2011
+++ packages/cups/cups-avahi-2-backend.patch Wed Dec 14 23:15:07 2011
@@ -0,0 +1,1117 @@
+diff -up cups-1.5.0/backend/dnssd.c.avahi-2-backend cups-1.5.0/backend/dnssd.c
+--- cups-1.5.0/backend/dnssd.c.avahi-2-backend 2011-08-05 15:04:46.182591844 +0100
++++ cups-1.5.0/backend/dnssd.c 2011-08-05 15:05:13.868710181 +0100
+@@ -15,14 +15,21 @@
+ *
+ * Contents:
+ *
++ * next_txt_record() - Get next TXT record from a cups_txt_records_t.
++ * parse_txt_record_pair() - Read key/value pair in cups_txt_records_t.
+ * main() - Browse for printers.
+ * browse_callback() - Browse devices.
+ * browse_local_callback() - Browse local devices.
+ * compare_devices() - Compare two devices.
+ * exec_backend() - Execute the backend that corresponds to the
+ * resolved service name.
++ * device_type() - Get DNS-SD type enumeration from string.
+ * get_device() - Create or update a device.
+ * query_callback() - Process query data.
++ * avahi_client_callback() - Avahi client callback function.
++ * avahi_query_callback() - Avahi query callback function.
++ * avahi_browse_callback() - Avahi browse callback function.
++ * find_device() - Find a device from its name and domain.
+ * sigterm_handler() - Handle termination signals...
+ * unquote() - Unquote a name string.
+ */
+@@ -33,7 +40,18 @@
+
+ #include "backend-private.h"
+ #include <cups/array.h>
+-#include <dns_sd.h>
++#ifdef HAVE_DNSSD
++# include <dns_sd.h>
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++# include <avahi-client/client.h>
++# include <avahi-client/lookup.h>
++# include <avahi-common/simple-watch.h>
++# include <avahi-common/domain.h>
++# include <avahi-common/error.h>
++# include <avahi-common/malloc.h>
++#define kDNSServiceMaxDomainName AVAHI_DOMAIN_NAME_MAX
++#endif /* HAVE_AVAHI */
+
+
+ /*
+@@ -53,7 +71,12 @@ typedef enum
+
+ typedef struct
+ {
++#ifdef HAVE_DNSSD
+ DNSServiceRef ref; /* Service reference for resolve */
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ int resolved; /* Did we resolve the device? */
++#endif /* HAVE_AVAHI */
+ char *name, /* Service name */
+ *domain, /* Domain name */
+ *fullName, /* Full name */
+@@ -65,6 +88,20 @@ typedef struct
+ sent; /* Did we list the device? */
+ } cups_device_t;
+
++typedef struct
++{
++ char key[256];
++ char value[256];
++
++#ifdef HAVE_DNSSD
++ const uint8_t *data;
++ const uint8_t *datanext;
++ const uint8_t *dataend;
++#else /* HAVE_AVAHI */
++ AvahiStringList *txt;
++#endif /* HAVE_DNSSD */
++} cups_txt_records_t;
++
+
+ /*
+ * Local globals...
+@@ -78,6 +115,7 @@ static int job_canceled = 0;
+ * Local functions...
+ */
+
++#ifdef HAVE_DNSSD
+ static void browse_callback(DNSServiceRef sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+@@ -93,12 +131,6 @@ static void browse_local_callback(DNSSe
+ const char *regtype,
+ const char *replyDomain,
+ void *context);
+-static int compare_devices(cups_device_t *a, cups_device_t *b);
+-static void exec_backend(char **argv);
+-static cups_device_t *get_device(cups_array_t *devices,
+- const char *serviceName,
+- const char *regtype,
+- const char *replyDomain);
+ static void query_callback(DNSServiceRef sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+@@ -107,9 +139,118 @@ static void query_callback(DNSServiceRe
+ uint16_t rrclass, uint16_t rdlen,
+ const void *rdata, uint32_t ttl,
+ void *context);
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++static void avahi_client_callback (AvahiClient *client,
++ AvahiClientState state,
++ void *context);
++static void avahi_browse_callback (AvahiServiceBrowser *browser,
++ AvahiIfIndex interface,
++ AvahiProtocol protocol,
++ AvahiBrowserEvent event,
++ const char *serviceName,
++ const char *regtype,
++ const char *replyDomain,
++ AvahiLookupResultFlags flags,
++ void *context);
++#endif /* HAVE_AVAHI */
++
++static cups_device_t * find_device (cups_array_t *devices,
++ cups_txt_records_t *txt,
++ cups_device_t *dkey);
++static int compare_devices(cups_device_t *a, cups_device_t *b);
++static void exec_backend(char **argv);
++static cups_device_t *get_device(cups_array_t *devices,
++ const char *serviceName,
++ const char *regtype,
++ const char *replyDomain);
+ static void sigterm_handler(int sig);
+ static void unquote(char *dst, const char *src, size_t dstsize);
+
++#ifdef HAVE_AVAHI
++static AvahiSimplePoll *simple_poll = NULL;
++static int avahi_got_callback;
++#endif /* HAVE_AVAHI */
++
++
++/*
++ * 'next_txt_record()' - Get next TXT record from a cups_txt_records_t.
++ */
++
++static cups_txt_records_t *
++next_txt_record (cups_txt_records_t *txt)
++{
++#ifdef HAVE_DNSSD
++ txt->data = txt->datanext;
++#else /* HAVE_AVAHI */
++ txt->txt = avahi_string_list_get_next (txt->txt);
++ if (txt->txt == NULL)
++ return NULL;
++#endif /* HAVE_DNSSD */
++
++ return txt;
++}
++
++
++/*
++ * 'parse_txt_record_pair()' - Read key/value pair in cups_txt_records_t.
++ */
++
++static int
++parse_txt_record_pair (cups_txt_records_t *txt)
++{
++#ifdef HAVE_DNSSD
++ uint8_t datalen;
++ uint8_t *data = txt->data;
++ char *ptr;
++
++ /*
++ * Read a key/value pair starting with an 8-bit length. Since the
++ * length is 8 bits and the size of the key/value buffers is 256, we
++ * don't need to check for overflow...
++ */
++
++ datalen = *data++;
++ if (!datalen || (data + datalen) >= txt->dataend)
++ return NULL;
++ txt->datanext = data + datalen;
++
++ for (ptr = txt->key; data < txt->datanext && *data != '='; data ++)
++ *ptr++ = *data;
++ *ptr = '\0';
++
++ if (data < txt->datanext && *data == '=')
++ {
++ data++;
++
++ if (data < datanext)
++ memcpy (txt->value, data, txt->datanext - data);
++ value[txt->datanext - data] = '\0';
++ }
++ else
++ return 1;
++#else /* HAVE_AVAHI */
++ char *key, *value;
++ size_t len;
++ avahi_string_list_get_pair (txt->txt, &key, &value, &len);
++ if (len > sizeof (txt->value) - 1)
++ len = sizeof (txt->value) - 1;
++
++ memcpy (txt->value, value, len);
++ txt->value[len] = '\0';
++ len = strlen (key);
++ if (len > sizeof (txt->key) - 1)
++ len = sizeof (txt->key) - 1;
++
++ memcpy (txt->key, key, len);
++ txt->key[len] = '\0';
++ avahi_free (key);
++ avahi_free (value);
++#endif /* HAVE_AVAHI */
++
++ return 0;
++}
++
+
+ /*
+ * 'main()' - Browse for printers.
+@@ -120,6 +261,13 @@ main(int argc, /* I - Number of comm
+ char *argv[]) /* I - Command-line arguments */
+ {
+ const char *name; /* Backend name */
++ cups_array_t *devices; /* Device array */
++ cups_device_t *device; /* Current device */
++ char uriName[1024]; /* Unquoted fullName for URI */
++#ifdef HAVE_DNSSD
++ int fd; /* Main file descriptor */
++ fd_set input; /* Input set for select() */
++ struct timeval timeout; /* Timeout for select() */
+ DNSServiceRef main_ref, /* Main service reference */
+ fax_ipp_ref, /* IPP fax service reference */
+ ipp_ref, /* IPP service reference */
+@@ -133,12 +281,11 @@ main(int argc, /* I - Number of comm
+ pdl_datastream_ref, /* AppSocket service reference */
+ printer_ref, /* LPD service reference */
+ riousbprint_ref; /* Remote IO service reference */
+- int fd; /* Main file descriptor */
+- fd_set input; /* Input set for select() */
+- struct timeval timeout; /* Timeout for select() */
+- cups_array_t *devices; /* Device array */
+- cups_device_t *device; /* Current device */
+- char uriName[1024]; /* Unquoted fullName for URI */
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ AvahiClient *client;
++ int error;
++#endif /* HAVE_AVAHI */
+ #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
+ struct sigaction action; /* Actions for POSIX signals */
+ #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
+@@ -198,6 +345,49 @@ main(int argc, /* I - Number of comm
+ * Browse for different kinds of printers...
+ */
+
++#ifdef HAVE_AVAHI
++ if ((simple_poll = avahi_simple_poll_new ()) == NULL)
++ {
++ perror ("ERROR: Unable to create avahi simple poll object");
++ return (1);
++ }
++
++ client = avahi_client_new (avahi_simple_poll_get (simple_poll),
++ 0, avahi_client_callback, NULL, &error);
++ if (!client)
++ {
++ perror ("DEBUG: Unable to create avahi client");
++ return (0);
++ }
++
++ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ "_fax-ipp._tcp", NULL, 0,
++ avahi_browse_callback, devices);
++ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ "_ipp._tcp", NULL, 0,
++ avahi_browse_callback, devices);
++ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ "_ipp-tls._tcp", NULL, 0,
++ avahi_browse_callback, devices);
++ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ "_pdl-datastream._tcp",
++ NULL, 0,
++ avahi_browse_callback,
++ devices);
++ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ "_printer._tcp", NULL, 0,
++ avahi_browse_callback, devices);
++ avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
++ AVAHI_PROTO_UNSPEC,
++ "_riousbprint._tcp", NULL, 0,
++ avahi_browse_callback, devices);
++#endif /* HAVE_AVAHI */
++#ifdef HAVE_DNSSD
+ if (DNSServiceCreateConnection(&main_ref) != kDNSServiceErr_NoError)
+ {
+ perror("ERROR: Unable to create service connection");
+@@ -258,6 +448,7 @@ main(int argc, /* I - Number of comm
+ riousbprint_ref = main_ref;
+ DNSServiceBrowse(&riousbprint_ref, kDNSServiceFlagsShareConnection, 0,
+ "_riousbprint._tcp", NULL, browse_callback, devices);
++#endif /* HAVE_DNSSD */
+
+ /*
+ * Loop until we are killed...
+@@ -265,6 +456,9 @@ main(int argc, /* I - Number of comm
+
+ while (!job_canceled)
+ {
++ int announce = 0;
++
++#ifdef HAVE_DNSSD
+ FD_ZERO(&input);
+ FD_SET(fd, &input);
+
+@@ -284,11 +478,35 @@ main(int argc, /* I - Number of comm
+ }
+ else
+ {
++ announce = 1;
++ }
++#else /* HAVE_AVAHI */
++ int r;
++ avahi_got_callback = 0;
++ r = avahi_simple_poll_iterate (simple_poll, 1);
++ if (r != 0 && r != EINTR)
++ {
++ /*
++ * We've been told to exit the loop. Perhaps the connection to
++ * avahi failed.
++ */
++
++ break;
++ }
++
++ if (avahi_got_callback)
++ announce = 1;
++#endif /* HAVE_DNSSD */
++
++ if (announce)
++ {
+ /*
+ * Announce any devices we've found...
+ */
+
++#ifdef HAVE_DNSSD
+ DNSServiceErrorType status; /* DNS query status */
++#endif /* HAVE_DNSSD */
+ cups_device_t *best; /* Best matching device */
+ char device_uri[1024]; /* Device URI */
+ int count; /* Number of queries */
+@@ -302,6 +520,7 @@ main(int argc, /* I - Number of comm
+ if (device->sent)
+ sent ++;
+
++#ifdef HAVE_DNSSD
+ if (device->ref)
+ count ++;
+
+@@ -333,14 +552,23 @@ main(int argc, /* I - Number of comm
+ count ++;
+ }
+ }
+- else if (!device->sent)
++ else
++#endif /* HAVE_DNSSD */
++#ifdef HAVE_AVAHI
++ if (!device->resolved)
++ continue;
++ else
++#endif /* HAVE_AVAHI */
++ if (!device->sent)
+ {
++#ifdef HAVE_DNSSD
+ /*
+ * Got the TXT records, now report the device...
+ */
+
+ DNSServiceRefDeallocate(device->ref);
+ device->ref = 0;
++#endif /* HAVE_DNSSD */
+
+ if (!best)
+ best = device;
+@@ -401,6 +629,7 @@ main(int argc, /* I - Number of comm
+ }
+
+
++#ifdef HAVE_DNSSD
+ /*
+ * 'browse_callback()' - Browse devices.
+ */
+@@ -489,6 +718,7 @@ browse_local_callback(
+ device->fullName);
+ device->sent = 1;
+ }
++#endif /* HAVE_DNSSD */
+
+
+ /*
+@@ -569,6 +799,41 @@ exec_backend(char **argv) /* I - Comman
+
+
+ /*
++ * 'device_type()' - Get DNS-SD type enumeration from string.
++ */
++
++static int
++device_type (const char *regtype)
++{
++#ifdef HAVE_AVAHI
++ if (!strcmp(regtype, "_ipp._tcp"))
++ return (CUPS_DEVICE_IPP);
++ else if (!strcmp(regtype, "_ipps._tcp") ||
++ !strcmp(regtype, "_ipp-tls._tcp"))
++ return (CUPS_DEVICE_IPPS);
++ else if (!strcmp(regtype, "_fax-ipp._tcp"))
++ return (CUPS_DEVICE_FAX_IPP);
++ else if (!strcmp(regtype, "_printer._tcp"))
++ return (CUPS_DEVICE_PDL_DATASTREAM);
++#else
++ if (!strcmp(regtype, "_ipp._tcp."))
++ return (CUPS_DEVICE_IPP);
++ else if (!strcmp(regtype, "_ipps._tcp.") ||
++ !strcmp(regtype, "_ipp-tls._tcp."))
++ return (CUPS_DEVICE_IPPS);
++ else if (!strcmp(regtype, "_fax-ipp._tcp."))
++ return (CUPS_DEVICE_FAX_IPP);
++ else if (!strcmp(regtype, "_printer._tcp."))
++ return (CUPS_DEVICE_PRINTER);
++ else if (!strcmp(regtype, "_pdl-datastream._tcp."))
++ return (CUPS_DEVICE_PDL_DATASTREAM);
++#endif /* HAVE_AVAHI */
++
++ return (CUPS_DEVICE_RIOUSBPRINT);
++}
++
++
++/*
+ * 'get_device()' - Create or update a device.
<<Diff was trimmed, longer than 597 lines>>
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/cups/cups.spec?r1=1.308&r2=1.309&f=u
More information about the pld-cvs-commit
mailing list