Browse Source

python-cups package creation

Signed-off-by: fpdpbuilder_pel7x64builder0 <fpdpbuilder@powerel.org>
master
fpdpbuilder_pel7x64builder0 5 years ago
parent
commit
95cba57a12
  1. 21
      SOURCES/python-cups-booleans.patch
  2. 14
      SOURCES/python-cups-decoding.patch
  3. 177
      SOURCES/python-cups-uris.patch
  4. 139
      SPECS/python-cups.spec

21
SOURCES/python-cups-booleans.patch

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
From 2e0078c0bcc4f02aa904cac00028da43cb6f6862 Mon Sep 17 00:00:00 2001
From: Jiri Popelka <jpopelka@redhat.com>
Date: Wed, 31 Jul 2013 15:31:15 +0200
Subject: [PATCH] Fix getting of boolean values.

diff --git a/cupsconnection.c b/cupsconnection.c
index d386e95..dda9789 100644
--- a/cupsconnection.c
+++ b/cupsconnection.c
@@ -641,7 +641,7 @@ PyObject_from_attr_value (ipp_attribute_t *attr, int i)
val = PyInt_FromLong (ippGetInteger (attr, i));
break;
case IPP_TAG_BOOLEAN:
- val = PyBool_FromLong (ippGetInteger (attr, i));
+ val = PyBool_FromLong (ippGetBoolean (attr, i));
break;
case IPP_TAG_RANGE:
lower = ippGetRange (attr, i, &upper);
--
1.8.3.1

14
SOURCES/python-cups-decoding.patch

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
diff -U0 pycups-1.9.63/ChangeLog.encoding pycups-1.9.63/ChangeLog
diff -up pycups-1.9.63/cupsconnection.c.encoding pycups-1.9.63/cupsconnection.c
--- pycups-1.9.63/cupsconnection.c.encoding 2013-04-12 11:35:20.604099365 +0100
+++ pycups-1.9.63/cupsconnection.c 2013-04-12 11:35:34.945163243 +0100
@@ -129,6 +129,9 @@ UTF8_from_PyObj (char **const utf8, PyOb
else if (PyString_Check (obj)) {
const char *ret;
PyObject *unicodeobj = PyUnicode_FromEncodedObject (obj, NULL, NULL);
+ if (unicodeobj == NULL)
+ return NULL;
+
ret = UTF8_from_PyObj (utf8, unicodeobj);
Py_DECREF (unicodeobj);
return ret;

177
SOURCES/python-cups-uris.patch

@ -0,0 +1,177 @@ @@ -0,0 +1,177 @@
diff -U0 pycups-1.9.63/ChangeLog.uris pycups-1.9.63/ChangeLog
diff -up pycups-1.9.63/cupsconnection.c.uris pycups-1.9.63/cupsconnection.c
--- pycups-1.9.63/cupsconnection.c.uris 2013-03-20 13:28:37.000000000 +0000
+++ pycups-1.9.63/cupsconnection.c 2013-04-11 15:27:49.036679360 +0100
@@ -138,6 +138,40 @@ UTF8_from_PyObj (char **const utf8, PyOb
return NULL;
}
+static void
+construct_uri (char *buffer, size_t buflen, const char *base, const char *value)
+{
+ char *d = buffer;
+ const unsigned char *s = (const unsigned char *) value;
+ if (strlen (base) < buflen) {
+ strcpy (buffer, base);
+ d += strlen (base);
+ } else {
+ strncpy (buffer, base, buflen);
+ d += buflen;
+ }
+
+ while (*s && d < buffer + buflen) {
+ if (isalpha (*s) || isdigit (*s) || *s == '-')
+ *d++ = *s++;
+ else if (*s == ' ') {
+ *d++ = '+';
+ s++;
+ } else {
+ if (d + 2 < buffer + buflen) {
+ *d++ = '%';
+ *d++ = "0123456789ABCDEF"[((*s) & 0xf0) >> 4];
+ *d++ = "0123456789ABCDEF"[((*s) & 0x0f)];
+ s++;
+ } else
+ break;
+ }
+ }
+
+ if (d < buffer + buflen)
+ *d = '\0';
+}
+
////////////////
// Connection //
////////////////
@@ -446,7 +480,7 @@ do_printer_request (Connection *self, Py
debugprintf ("-> do_printer_request(op:%d, name:%s)\n", (int) op, name);
request = ippNewRequest (op);
- snprintf (uri, sizeof (uri), "ipp://localhost/printers/%s", name);
+ construct_uri (uri, sizeof (uri), "ipp://localhost/printers/", name);
free (name);
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
@@ -1749,7 +1783,8 @@ Connection_cancelAllJobs (Connection *se
debugprintf ("-> Connection_cancelAllJobs(%s, my_jobs=%d, purge_jobs=%d)\n",
nameobj ? name : uri, my_jobs, purge_jobs);
if (nameobj) {
- snprintf (consuri, sizeof (consuri), "ipp://localhost/printers/%s", name);
+ construct_uri (consuri, sizeof (consuri),
+ "ipp://localhost/printers/", name);
uri = consuri;
}
@@ -1776,7 +1811,8 @@ Connection_cancelAllJobs (Connection *se
break;
// Perhaps it's a class, not a printer.
- snprintf (consuri, sizeof (consuri), "ipp://localhost/classes/%s", name);
+ construct_uri (consuri, sizeof (consuri),
+ "ipp://localhost/classes/", name);
} else break;
}
@@ -2125,7 +2161,7 @@ add_modify_printer_request (const char *
{
char uri[HTTP_MAX_URI];
ipp_t *request = ippNewRequest (CUPS_ADD_MODIFY_PRINTER);
- snprintf (uri, sizeof (uri), "ipp://localhost/printers/%s", name);
+ construct_uri (uri, sizeof (uri), "ipp://localhost/printers/", name);
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
return request;
@@ -2136,7 +2172,7 @@ add_modify_class_request (const char *na
{
char uri[HTTP_MAX_URI];
ipp_t *request = ippNewRequest (CUPS_ADD_MODIFY_CLASS);
- snprintf (uri, sizeof (uri), "ipp://localhost/classes/%s", name);
+ construct_uri (uri, sizeof (uri), "ipp://localhost/classes/", name);
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
return request;
@@ -3012,7 +3048,8 @@ Connection_getPrinterAttributes (Connect
nameobj ? name : uri);
if (nameobj) {
- snprintf (consuri, sizeof (consuri), "ipp://localhost/printers/%s", name);
+ construct_uri (consuri, sizeof (consuri),
+ "ipp://localhost/printers/", name);
uri = consuri;
}
@@ -3034,7 +3071,8 @@ Connection_getPrinterAttributes (Connect
break;
// Perhaps it's a class, not a printer.
- snprintf (consuri, sizeof (consuri), "ipp://localhost/classes/%s", name);
+ construct_uri (consuri, sizeof (consuri),
+ "ipp://localhost/classes/", name);
} else break;
}
@@ -3179,8 +3217,9 @@ Connection_addPrinterToClass (Connection
// Does the class exist, and is the printer already in it?
request = ippNewRequest (IPP_GET_PRINTER_ATTRIBUTES);
- snprintf (classuri, sizeof (classuri),
- "ipp://localhost/classes/%s", classname);
+ construct_uri (classuri, sizeof (classuri),
+ "ipp://localhost/classes/", classname);
+
free (classname);
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, classuri);
@@ -3206,8 +3245,8 @@ Connection_addPrinterToClass (Connection
request = ippNewRequest (CUPS_ADD_CLASS);
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, classuri);
- snprintf (printeruri, sizeof (printeruri),
- "ipp://localhost/printers/%s", printername);
+ construct_uri (printeruri, sizeof (printeruri),
+ "ipp://localhost/printers/", printername);
free (printername);
if (answer) {
ipp_attribute_t *printers;
@@ -3283,8 +3322,8 @@ Connection_deletePrinterFromClass (Conne
// Does the class exist, and is the printer in it?
request = ippNewRequest (IPP_GET_PRINTER_ATTRIBUTES);
- snprintf (classuri, sizeof (classuri),
- "ipp://localhost/classes/%s", classname);
+ construct_uri (classuri, sizeof (classuri),
+ "ipp://localhost/classes/", classname);
free (classname);
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, classuri);
@@ -3379,8 +3418,8 @@ Connection_deleteClass (Connection *self
return NULL;
request = ippNewRequest (CUPS_DELETE_CLASS);
- snprintf (classuri, sizeof (classuri),
- "ipp://localhost/classes/%s", classname);
+ construct_uri (classuri, sizeof (classuri),
+ "ipp://localhost/classes/", classname);
free (classname);
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, classuri);
@@ -3659,7 +3698,8 @@ Connection_printTestPage (Connection *se
if (!userobj)
user = (char *) cupsUser();
- snprintf (uri, sizeof (uri), "ipp://localhost/printers/%s", printer);
+ construct_uri (uri, sizeof (uri),
+ "ipp://localhost/printers/", printer);
resource = uri + strlen ("ipp://localhost");
for (i = 0; i < 2; i++) {
request = ippNewRequest (IPP_PRINT_JOB);
@@ -3679,7 +3719,8 @@ Connection_printTestPage (Connection *se
if (answer && ippGetStatusCode (answer) == IPP_NOT_POSSIBLE) {
ippDelete (answer);
// Perhaps it's a class, not a printer.
- snprintf (uri, sizeof (uri), "ipp://localhost/classes/%s", printer);
+ construct_uri (uri, sizeof (uri),
+ "ipp://localhost/classes/", printer);
} else break;
}

139
SPECS/python-cups.spec

@ -0,0 +1,139 @@ @@ -0,0 +1,139 @@
%{?filter_setup:
%filter_provides_in %{python_sitearch}/.*\.so$
%filter_setup
}

Summary: Python bindings for CUPS
Name: python-cups
Version: 1.9.63
Release: 6%{?dist}
URL: http://cyberelk.net/tim/software/pycups/
Source: http://cyberelk.net/tim/data/pycups/pycups-%{version}.tar.bz2
Patch1: python-cups-uris.patch
Patch2: python-cups-decoding.patch
Patch3: python-cups-booleans.patch
License: GPLv2+
Group: Development/Languages
BuildRequires: cups-devel
BuildRequires: python2-devel
BuildRequires: epydoc

%description
This package provides Python bindings for the CUPS API,
known as pycups. It was written for use with
system-config-printer, but can be put to other uses as well.

%package doc
Summary: Documentation for python-cups
Group: Documentation

%description doc
Documentation for python-cups.

%prep
%setup -q -n pycups-%{version}

# Encode generated URIs correctly (patch from upstream) (bug #950162).
%patch1 -p1 -b .uris

# Propagate UTF-8 decoding errors.
%patch2 -p1 -b .decoding

# Fix getting of booleans.
%patch3 -p1 -b .booleans

%build
make CFLAGS="%{optflags} -fno-strict-aliasing"
make doc

%install
make install DESTDIR="%{buildroot}"

%files
%doc COPYING ChangeLog README NEWS TODO
%{python_sitearch}/cups.so
%{python_sitearch}/pycups*.egg-info
%{_rpmconfigdir}/fileattrs/psdriver.attr
%{_rpmconfigdir}/postscriptdriver.prov

%files doc
%doc examples html

%changelog
* Fri Jan 24 2014 Daniel Mach <dmach@redhat.com> - 1.9.63-6
- Mass rebuild 2014-01-24

* Fri Dec 27 2013 Daniel Mach <dmach@redhat.com> - 1.9.63-5
- Mass rebuild 2013-12-27

* Wed Jul 31 2013 Jiri Popelka <jpopelka@redhat.com> - 1.9.63-4
- Fix getting of booleans.

* Fri Apr 12 2013 Tim Waugh <twaugh@redhat.com> - 1.9.63-3
- Propagate UTF-8 decoding errors.

* Thu Apr 11 2013 Tim Waugh <twaugh@redhat.com> - 1.9.63-2
- Encode generated URIs correctly (bug #950162).

* Wed Mar 20 2013 Tim Waugh <twaugh@redhat.com> - 1.9.63-1
- 1.9.63.

* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.9.62-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Thu Sep 27 2012 Jiri Popelka <jpopelka@redhat.com> - 1.9.62-2
- Remove unused statements.

* Wed Aug 1 2012 Tim Waugh <twaugh@redhat.com> - 1.9.62-1
- 1.9.62, including fixes for building against newer versions of CUPS.

* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.9.61-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Tue Apr 10 2012 Tim Waugh <twaugh@redhat.com> - 1.9.61-2
- Apply upstream patch to fix crash on loading invalid PPDs (bug #811159).

* Tue Mar 6 2012 Tim Waugh <twaugh@redhat.com> - 1.9.61-1
- 1.9.61, fixing ref-counting bugs (bug #800143).

* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.9.60-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Tue Oct 11 2011 Tim Waugh <twaugh@redhat.com> - 1.9.60-1
- 1.9.60. Constants from CUPS 1.5.0.

* Mon Oct 3 2011 Tim Waugh <twaugh@redhat.com> - 1.9.59-1
- 1.9.59. Fixes auth loops with CUPS 1.5.0 (bug #734247).

* Thu Jun 9 2011 Tim Waugh <twaugh@redhat.com> - 1.9.57-1
- 1.9.57. Fixes rpm provides script (bug #712027).

* Sun Mar 20 2011 Tim Waugh <twaugh@redhat.com> - 1.9.55-1
- 1.9.55. Support for IPP "resolution" type.

* Wed Feb 23 2011 Tim Waugh <twaugh@redhat.com> - 1.9.54-1
- 1.9.54. The rpm hook is now upstream.

* Wed Feb 23 2011 Tim Waugh <twaugh@redhat.com> - 1.9.53-5
- Use rpmconfigdir macro throughout.

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.9.53-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Tue Jan 25 2011 Tim Waugh <twaugh@redhat.com> - 1.9.53-3
- Fixed typo in psdriver.attr that prevented PPD files from being
scanned when generating postscriptdriver tags.

* Thu Jan 20 2011 Tim Waugh <twaugh@redhat.com> - 1.9.53-2
- Moved postscriptdriver RPM tagging machinery here. Fixed
leading/trailing whitespace in tags as well.

* Wed Dec 15 2010 Tim Waugh <twaugh@redhat.com> - 1.9.53-1
- 1.9.53 fixing a thread-local storage issue (bug #662805).

* Wed Nov 17 2010 Jiri Popelka <jpopelka@redhat.com> - 1.9.52-2
- Fixed rpmlint errors/warnings (#648986)
- doc subpackage

* Mon Nov 01 2010 Jiri Popelka <jpopelka@redhat.com> - 1.9.52-1
- Initial RPM spec file
Loading…
Cancel
Save