OBS User unknown 2008-04-09 19:07:39 +00:00 committed by Git OBS Bridge
parent 7972500c88
commit 6766997b7e
7 changed files with 622 additions and 4 deletions

314
cups-1.4svn-pdftops.c Normal file
View File

@ -0,0 +1,314 @@
/*
* "$Id: pdftops.c 7391 2008-03-21 21:24:18Z mike $"
*
* PDF to PostScript filter front-end for the Common UNIX Printing
* System (CUPS).
*
* Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
* property of Apple Inc. and are protected by Federal copyright
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
* which should have been included with this file. If this file is
* file is missing or damaged, see the license at "http://www.cups.org/".
*
* Contents:
*
* main() - Main entry for filter...
* cancel_job() - Flag the job as canceled.
*/
/*
* Include necessary headers...
*/
#include <cups/cups.h>
#include <cups/string.h>
#include <cups/i18n.h>
#include <signal.h>
#include <sys/wait.h>
/*
* Local functions...
*/
static void cancel_job(int sig);
/*
* 'main()' - Main entry for filter...
*/
int /* O - Exit status */
main(int argc, /* I - Number of command-line args */
char *argv[]) /* I - Command-line arguments */
{
int fd; /* Copy file descriptor */
char *filename, /* PDF file to convert */
tempfile[1024]; /* Temporary file */
char buffer[8192]; /* Copy buffer */
int bytes; /* Bytes copied */
int num_options; /* Number of options */
cups_option_t *options; /* Options */
const char *val; /* Option value */
int orientation; /* Output orientation */
ppd_file_t *ppd; /* PPD file */
ppd_size_t *size; /* Current page size */
int pdfpid, /* Process ID for pdftops */
pdfstatus, /* Status from pdftops */
pdfargc; /* Number of args for pdftops */
char *pdfargv[100], /* Arguments for pdftops */
pdfwidth[255], /* Paper width */
pdfheight[255]; /* Paper height */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
/*
* Make sure status messages are not buffered...
*/
setbuf(stderr, NULL);
/*
* Make sure we have the right number of arguments for CUPS!
*/
if (argc < 6 || argc > 7)
{
_cupsLangPrintf(stderr,
_("Usage: %s job user title copies options [filename]\n"),
argv[0]);
return (1);
}
/*
* Register a signal handler to cleanly cancel a job.
*/
#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
sigset(SIGTERM, cancel_job);
#elif defined(HAVE_SIGACTION)
memset(&action, 0, sizeof(action));
sigemptyset(&action.sa_mask);
action.sa_handler = cancel_job;
sigaction(SIGTERM, &action, NULL);
#else
signal(SIGTERM, cancel_job);
#endif /* HAVE_SIGSET */
/*
* Copy stdin if needed...
*/
if (argc == 6)
{
/*
* Copy stdin to a temp file...
*/
if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
{
_cupsLangPrintError(_("ERROR: Unable to copy PDF file"));
return (1);
}
fprintf(stderr, "DEBUG: pdftops - copying to temp print file \"%s\"\n",
tempfile);
while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0)
write(fd, buffer, bytes);
close(fd);
filename = tempfile;
}
else
{
/*
* Use the filename on the command-line...
*/
filename = argv[6];
tempfile[0] = '\0';
}
/*
* Load the PPD file and mark options...
*/
ppd = ppdOpenFile(getenv("PPD"));
num_options = cupsParseOptions(argv[5], 0, &options);
ppdMarkDefaults(ppd);
cupsMarkOptions(ppd, num_options, options);
/*
* Build the command-line for the pdftops filter...
*/
pdfargv[0] = (char *)"pdftops";
pdfargc = 1;
if (ppd)
{
/*
* Set language level and TrueType font handling...
*/
if (ppd->language_level == 1)
{
pdfargv[pdfargc++] = (char *)"-level1";
pdfargv[pdfargc++] = (char *)"-noembtt";
}
else if (ppd->language_level == 2)
{
pdfargv[pdfargc++] = (char *)"-level2";
if (!ppd->ttrasterizer)
pdfargv[pdfargc++] = (char *)"-noembtt";
}
else
pdfargv[pdfargc++] = (char *)"-level3";
/*
* Set output page size...
*/
size = ppdPageSize(ppd, NULL);
if (size)
{
/*
* Got the size, now get the orientation...
*/
orientation = 0;
if ((val = cupsGetOption("landscape", num_options, options)) != NULL)
{
if (strcasecmp(val, "no") != 0 && strcasecmp(val, "off") != 0 &&
strcasecmp(val, "false") != 0)
orientation = 1;
}
else if ((val = cupsGetOption("orientation-requested", num_options, options)) != NULL)
{
/*
* Map IPP orientation values to 0 to 3:
*
* 3 = 0 degrees = 0
* 4 = 90 degrees = 1
* 5 = -90 degrees = 3
* 6 = 180 degrees = 2
*/
orientation = atoi(val) - 3;
if (orientation >= 2)
orientation ^= 1;
}
if (orientation & 1)
{
snprintf(pdfwidth, sizeof(pdfwidth), "%.0f", size->length);
snprintf(pdfheight, sizeof(pdfheight), "%.0f", size->width);
}
else
{
snprintf(pdfwidth, sizeof(pdfwidth), "%.0f", size->width);
snprintf(pdfheight, sizeof(pdfheight), "%.0f", size->length);
}
pdfargv[pdfargc++] = (char *)"-paperw";
pdfargv[pdfargc++] = pdfwidth;
pdfargv[pdfargc++] = (char *)"-paperh";
pdfargv[pdfargc++] = pdfheight;
}
}
if ((val = cupsGetOption("fitplot", num_options, options)) != NULL &&
strcasecmp(val, "no") && strcasecmp(val, "off") &&
strcasecmp(val, "false"))
pdfargv[pdfargc++] = (char *)"-expand";
pdfargv[pdfargc++] = filename;
pdfargv[pdfargc++] = (char *)"-";
pdfargv[pdfargc] = NULL;
if ((pdfpid = fork()) == 0)
{
/*
* Child comes here...
*/
execv(CUPS_PDFTOPS, pdfargv);
_cupsLangPrintError(_("ERROR: Unable to execute pdftops filter"));
exit(1);
}
else if (pdfpid < 0)
{
/*
* Unable to fork!
*/
_cupsLangPrintError(_("ERROR: Unable to execute pdftops filter"));
pdfstatus = 1;
}
else
{
/*
* Parent comes here...
*/
if (wait(&pdfstatus) != pdfpid)
{
kill(pdfpid, SIGTERM);
pdfstatus = 1;
}
else if (pdfstatus)
{
if (WIFEXITED(pdfstatus))
{
pdfstatus = WEXITSTATUS(pdfstatus);
_cupsLangPrintf(stderr,
_("ERROR: pdftops filter exited with status %d!\n"),
pdfstatus);
}
else
{
pdfstatus = WTERMSIG(pdfstatus);
_cupsLangPrintf(stderr,
_("ERROR: pdftops filter crashed on signal %d!\n"),
pdfstatus);
}
}
}
/*
* Cleanup and exit...
*/
if (tempfile[0])
unlink(tempfile);
return (pdfstatus);
}
/*
* 'cancel_job()' - Flag the job as canceled.
*/
static void
cancel_job(int sig) /* I - Signal number (unused) */
{
(void)sig;
}
/*
* End of "$Id: pdftops.c 7391 2008-03-21 21:24:18Z mike $".
*/

View File

@ -0,0 +1,141 @@
--- ./test/run-stp-tests.sh.orig 2008-04-01 23:30:44.000000000 +0200
+++ ./test/run-stp-tests.sh 2008-04-09 18:05:52.000000000 +0200
@@ -273,7 +273,7 @@
else
ln -s $root/filter/imagetops /tmp/cups-$user/bin/filter
ln -s $root/filter/imagetoraster /tmp/cups-$user/bin/filter
- ln -s $root/pdftops/pdftops /tmp/cups-$user/bin/filter
+ ln -s $root/filter/pdftops /tmp/cups-$user/bin/filter
fi
#
--- ./packaging/cups.list.in.orig 2008-02-15 22:32:52.000000000 +0100
+++ ./packaging/cups.list.in 2008-04-09 18:06:28.000000000 +0200
@@ -265,7 +265,7 @@
f 0755 root sys $SERVERBIN/filter/imagetoraster filter/imagetoraster
%endif
%if PDFTOPS
-f 0755 root sys $SERVERBIN/filter/pdftops pdftops/pdftops
+f 0755 root sys $SERVERBIN/filter/pdftops filter/pdftops
%endif
f 0755 root sys $SERVERBIN/filter/pstops filter/pstops
f 0755 root sys $SERVERBIN/filter/rastertolabel filter/rastertolabel
--- ./filter/Makefile.orig 2007-07-20 01:27:49.000000000 +0200
+++ ./filter/Makefile 2008-04-09 18:05:26.000000000 +0200
@@ -19,7 +19,7 @@
FILTERS = gziptoany hpgltops texttops pstops $(IMGFILTERS) \
- rastertolabel rastertoepson rastertohp
+ rastertolabel rastertoepson rastertohp pdftops
TARGETS = $(FILTERS) \
$(LIBCUPSIMAGE) \
libcupsimage.a \
@@ -41,7 +41,7 @@
OBJS = $(HPGLOBJS) $(IMAGEOBJS) $(FORMOBJS) \
gziptoany.o imagetops.o imagetoraster.o common.o pstops.o \
rasterbench.o rastertoepson.o rastertohp.o rastertolabel.o \
- testimage.o testraster.o textcommon.o texttops.o
+ testimage.o testraster.o textcommon.o texttops.o pdftops.o
#
@@ -322,6 +322,14 @@
echo Linking $@...
$(CC) $(LDFLAGS) -o $@ pstops.o common.o $(LIBS) -lm
+#
+# pdftops
+#
+
+pdftops: pdftops.o common.o ../cups/$(LIBCUPS)
+ echo Linking $@...
+ $(CC) $(LDFLAGS) -o $@ pdftops.o common.o $(LIBS)
+
#
# rastertolabel
--- cups-1.3.7/config-scripts/cups-pdf.m4.orig 2007-07-11 23:46:42.000000000 +0200
+++ cups-1.3.7/config-scripts/cups-pdf.m4 2008-04-09 18:21:35.000000000 +0200
@@ -18,12 +18,20 @@
PDFTOPS=""
if test "x$enable_pdftops" != xno; then
- AC_MSG_CHECKING(whether to build pdftops filter)
- if test "x$enable_pdftops" = xyes -o $uname != Darwin; then
- PDFTOPS="pdftops"
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
+ AC_PATH_PROG(CUPS_PDFTOPS, pdftops)
+ AC_DEFINE_UNQUOTED(CUPS_PDFTOPS, "$CUPS_PDFTOPS")
+
+ if test "x$CUPS_PDFTOPS" != x; then
+ AC_MSG_CHECKING(whether to build pdftops filter)
+ if test "x$enable_pdftops" = xyes -o $uname != Darwin; then
+ PDFTOPS="pdftops"
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ fi
+ elif test x$enable_pdftops = xyes; then
+ AC_MSG_ERROR(Unable to find pdftops program!)
+ exit 1
fi
fi
--- cups-1.3.7/config.h.in.orig 2008-01-07 19:26:57.000000000 +0100
+++ cups-1.3.7/config.h.in 2008-04-09 18:22:50.000000000 +0200
@@ -420,6 +420,12 @@
#undef HAVE_PYTHON
#define CUPS_PYTHON "/usr/bin/python"
+/*
+ * Location of the poppler/Xpdf pdftops program...
+ */
+
+#define CUPS_PDFTOPS "/usr/bin/pdftops"
+
/*
* Do we have Darwin's CoreFoundation and SystemConfiguration frameworks?
--- cups-1.3.7/filter/pdftops.c.orig 2008-04-09 18:23:35.000000000 +0200
+++ cups-1.3.7/filter/pdftops.c 2008-04-09 18:33:53.000000000 +0200
@@ -115,7 +115,7 @@
if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
{
- _cupsLangPrintError(_("ERROR: Unable to copy PDF file"));
+ perror(_("ERROR: Unable to copy PDF file"));
return (1);
}
@@ -245,7 +245,7 @@
*/
execv(CUPS_PDFTOPS, pdfargv);
- _cupsLangPrintError(_("ERROR: Unable to execute pdftops filter"));
+ perror(_("ERROR: Unable to execute pdftops filter"));
exit(1);
}
else if (pdfpid < 0)
@@ -254,7 +254,7 @@
* Unable to fork!
*/
- _cupsLangPrintError(_("ERROR: Unable to execute pdftops filter"));
+ perror(_("ERROR: Unable to execute pdftops filter"));
pdfstatus = 1;
}
else
--- cups-1.3.7/Makefile.orig 2008-02-16 00:26:51.000000000 +0100
+++ cups-1.3.7/Makefile 2008-04-09 19:08:39.000000000 +0200
@@ -20,7 +20,7 @@
#
DIRS = cups backend berkeley cgi-bin filter locale man monitor \
- notifier $(PDFTOPS) scheduler systemv test \
+ notifier scheduler systemv test \
$(PHPDIR) \
conf data doc $(FONTS) ppd templates

View File

@ -0,0 +1,40 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## pdftops-wait-eintr.dpatch by <mpitt@debian.org>
##
## DP: Handle EINTR in pdftops' wait() call.
@DPATCH@
diff -urNad trunk~/filter/pdftops.c trunk/filter/pdftops.c
--- trunk~/filter/pdftops.c 2008-04-02 02:54:45.000000000 +0200
+++ trunk/filter/pdftops.c 2008-04-02 02:54:59.000000000 +0200
@@ -28,6 +28,7 @@
#include <cups/i18n.h>
#include <signal.h>
#include <sys/wait.h>
+#include <errno.h>
/*
@@ -62,6 +63,7 @@
char *pdfargv[100], /* Arguments for pdftops */
pdfwidth[255], /* Paper width */
pdfheight[255]; /* Paper height */
+ pid_t child; /* wait() result */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
@@ -260,8 +262,13 @@
/*
* Parent comes here...
*/
+
+ do
+ {
+ child = wait(&pdfstatus);
+ } while (child < 0 && errno == EINTR);
- if (wait(&pdfstatus) != pdfpid)
+ if (child != pdfpid)
{
kill(pdfpid, SIGTERM);
pdfstatus = 1;

77
cups-client.conf Normal file
View File

@ -0,0 +1,77 @@
# Sample client configuration file for the Common UNIX Printing System
# (CUPS).
#
# Copyright 1997-2005 by Easy Software Products, all rights reserved.
# Klaus Singvogel <kssingvo@suse.de> modified it for SUSE distribution.
#
# These coded instructions, statements, and computer programs are the
# property of Easy Software Products and are protected by Federal
# copyright law. Distribution and use rights are outlined in the file
# "LICENSE.txt" which should have been included with this file. If this
# file is missing or damaged please contact Easy Software Products
# at:
#
# Attn: CUPS Licensing Information
# Easy Software Products
# 44141 Airport View Drive, Suite 204
# Hollywood, Maryland 20636 USA
#
# Voice: (301) 373-9600
# EMail: cups-info@cups.org
# WWW: http://www.cups.org
#
########################################################################
# #
# This is the CUPS client configuration file. This file is used to #
# define client-specific parameters, such as the default server or #
# default encryption settings. #
# #
# Put this file on /etc/cups/client.conf (system use) or #
# ~/.cups/client.conf (personal use). #
# #
# more information in the manual page client.conf(5)
########################################################################
#
# Encryption: directive specifies the default encryption settings for
# the client.
#
# Possible values:
#
# IfRequested
# Never
# Required
# Always
#
# The default value is "IfRequested".
# This parameter can also be set # using the CUPS_ENCRYPTION environment
# variable.
#
#Encryption IfRequested
#Encryption Never
#Encryption Required
#Encryption Always
#
# ServerName: directive specifies sets the remote server that is to be
# used for all client operations. That is, it redirects all client
# requests to the remote server.
#
# By default CUPS will use the domain socket /var/run/cups/cups.sock or
# local server ("localhost"), if so configured. The value can be
# overwritten by the CUPS_SERVER environment variable.
#
# The default port number is 631 but can be overridden by adding a colon
# followed by the desired port number to the value.
#
# ONLY ONE SERVER NAME MAY BE SPECIFIED AT A TIME. To use more than one
# server you must use a local scheduler with browsing and possibly
# polling.
#
#ServerName /domain/socket
#ServerName foo.bar.com
#ServerName 11.22.33.444
#ServerName foo.bar.com:8631

5
cups-krb5-config Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
unset CFLAGS
/usr/lib/mit/bin/krb5-config ${1+"$@"} | \
sed -r -e 's/-W[^[:blank:]]+//g' -e 's/-L[^[:blank:]]+//g'

View File

@ -1,3 +1,16 @@
-------------------------------------------------------------------
Wed Apr 9 19:38:27 CEST 2008 - kssingvo@suse.de
- pdftops uses now system command e.g. xpdf-tools (as in cups-1.4svn)
- due to requests: client.conf is back in /etc/cups
-------------------------------------------------------------------
Wed Apr 9 12:30:55 CEST 2008 - kssingvo@suse.de
- fix for buildsystem: added wrapper script for krb5-config as the
original output shows $CFLAGS $LIBDIR of cups.spec and rpath flags
(bugzilla#378270)
-------------------------------------------------------------------
Tue Apr 8 20:47:47 CEST 2008 - kssingvo@suse.de

View File

@ -22,7 +22,7 @@ License: GPL v2 or later
Group: Hardware/Printing
Summary: The Common UNIX Printing System
Version: 1.3.7
Release: 3
Release: 4
Requires: cups-libs = %{version}, cups-client = %{version}
Requires: ghostscript_any, ghostscript-fonts-std, foomatic-filters
Requires: util-linux
@ -45,6 +45,9 @@ Source16: PSLEVEL2.PPD.bz2
Source17: cups.SuSEfirewall2
Source18: http://download.sourceforge.net/cups-mailto/cups-pdf.ppd
Source19: http://download.sourceforge.net/cups-mailto/cups-pstopdf
Source20: cups-krb5-config
Source21: cups-client.conf
Source22: cups-1.4svn-pdftops.c
Patch1: cups-1.3.3-mime.patch
Patch2: cups-1.2.0-ppdsdat_generation.patch
Patch3: cups-1.2rc1-template.patch
@ -59,8 +62,18 @@ Patch14: cups-1.1.21-testppd_duplex.patch
Patch15: cups-1.2.11-testppd_filename.patch
Patch16: cups-1.2.5-desktop_file.patch
Patch17: cups-1.3.3-testppd_none.patch
Patch18: cups-1.4svn-pdftops_as_filter.patch
# next is found as http://www.cups.org/strfiles/2780/pdftops-wait-eintr.dpatch
Patch19: cups-1.4svn-pdftops_wait_eintr.patch
Patch100: cups-1.1.23-testpage.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} > 1030
Requires: poppler-tools
BuildRequires: poppler-tools
%else
Requires: xpdf-tools
BuildRequires: xpdf-tools
%endif
%description
The Common UNIX Printing System provides a portable printing layer for
@ -121,7 +134,7 @@ Authors:
License: GPL v2 or later
Summary: Development Environment for CUPS
Group: Development/Libraries/C and C++
Requires: %{name}-libs = %{version} openssl-devel glibc-devel
Requires: %{name}-libs = %{version} openssl-devel glibc-devel krb5-devel
%description devel
The Common UNIX Printing System provides a portable printing layer for
@ -138,6 +151,9 @@ Authors:
%prep
%setup -n %{name}-%{version}
%{INSTALL_DATA} %{SOURCE22} filter/pdftops.c
# just to make avoid misunderstandings...
mv pdftops pdftos.use_filter_pdftops_c
%patch1 -p1
%patch2 -p1
%patch3 -p1
@ -152,6 +168,8 @@ Authors:
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
if [ -f /.buildenv ]; then
. /.buildenv
else
@ -165,6 +183,7 @@ perl -pi -e 's|(CUPS_SERVERBIN=\")\$exec_prefix/lib|$1'%{_libdir}'|' \
config-scripts/cups-directories.m4
cp -a %{SOURCE9} .
cp -a %{SOURCE10} .
%{INSTALL_SCRIPT} %{SOURCE20} krb5-config
%build
%{?suse_update_config:%{suse_update_config -f . }}
@ -179,7 +198,7 @@ export CXXFLAGS="$CXXFLAGS $RPM_OPT_FLAGS -O2 -fno-strict-aliasing"
export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"
%endif
export CXX=g++
./configure \
KRB5CONFIG=${PWD}/krb5-config ./configure \
--mandir=%{_mandir} \
--sysconfdir=%{_sysconfdir} \
--libdir=%{_libdir} \
@ -239,6 +258,8 @@ mkdir -p $RPM_BUILD_ROOT/usr/share/ghostscript/fonts
ln -sf /usr/share/ghostscript/fonts $RPM_BUILD_ROOT/usr/share/cups/
# make directory for ssl files:
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/cups/ssl
# add old client.conf as reference:
%{INSTALL_DATA} %{SOURCE21} $RPM_BUILD_ROOT%{_sysconfdir}/cups/client.conf
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d
install -m 644 -D packaging/cups-dbus.conf $RPM_BUILD_ROOT%{_sysconfdir}/dbus-1/system.d/cups.conf
install -m 644 -D %{SOURCE14} $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d/cups-lpd
@ -396,13 +417,20 @@ rm -rf $RPM_BUILD_ROOT/usr/share/locale/no
%dir %attr(0710,root,lp) %{_var}/spool/cups
%dir %attr(1770,root,lp) %{_var}/spool/cups/tmp
%dir %attr(0755,lp,lp) %{_var}/log/cups/
# %config(noreplace) %{_sysconfdir}/cups/client.conf
%config(noreplace) %{_sysconfdir}/cups/client.conf
%config(noreplace) /etc/sysconfig/SuSEfirewall2.d/services/cups
%{_libdir}/libcups.so.*
%{_libdir}/libcupsimage.so.*
%{_datadir}/locale/*/cups_*
%changelog
* Wed Apr 09 2008 kssingvo@suse.de
- pdftops uses now system command e.g. xpdf-tools (as in cups-1.4svn)
- due to requests: client.conf is back in /etc/cups
* Wed Apr 09 2008 kssingvo@suse.de
- fix for buildsystem: added wrapper script for krb5-config as the
original output shows $CFLAGS $LIBDIR of cups.spec and rpath flags
(bugzilla#378270)
* Tue Apr 08 2008 kssingvo@suse.de
- added missing directory /var/cache/cups to %%files
- added pstopdf filter (from cups-mailto project at sourceforge.net)