add ldap draft support

git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/mds@867 6952d904-891a-0410-993b-d76249ca496b
This commit is contained in:
geos_one 2009-03-13 22:03:41 +00:00
parent cb8b07475d
commit 4333ad47b1
10 changed files with 2226 additions and 0 deletions

1398
net-print/cups/ChangeLog Normal file

File diff suppressed because it is too large Load Diff

10
net-print/cups/Manifest Normal file
View File

@ -0,0 +1,10 @@
AUX cups-1.3.0-configure.patch 651 RMD160 e4c7f45d7ddc28157433bf025c7f946c7e3b6d6a SHA1 101bf1893b56640d9fa82078e29319fbbd1449c7 SHA256 d6e5e60a982a3c093c0d0f89cf865e2b4c36290f5b1e188b7bf305d210070736
AUX cups-1.3.7-backend-https.patch 450 RMD160 9a1ad48d2be40c89510ccc512649f0a2eb5543b0 SHA1 d3dd55fcdee47855d6b7c1443adb6c2b3d8c9cdb SHA256 060f929ae3eae5dc411ce6352a0d50c3296b013974f034fc2ad8d6bb0c81b45a
AUX cups-1.3.9-CVE-2008-5286.patch 761 RMD160 7abe5d746cc2c8135e946de492b767137204345a SHA1 1e904c63e5bb2ef2e6f9792e3b2c3bcb89cdc6e8 SHA256 e85dc13164dd1c7b7fa978aeb5b6df886d9595319aab5fadde57e35d0259aee3
AUX cups-1.3.9-ldap-draft-1.patch 3443 RMD160 a8d6cdc180c7a3dc4747e91d2b0b662978d613f4 SHA1 a1ad1ebc6258044cc5068153995a5f1415904a6c SHA256 096440d1fc5f18c65338a45699648c89f43b802721f51b91428df8446d77a582
AUX cupsd.init.d 293 RMD160 19fbef21cee7e472e7028f3101b680baa0089c54 SHA1 e6b27b2638fec258fe2f55c926c2530e909ca3d2 SHA256 b4268a6bae95e96b6af21c3716ecc905073736ce7dc33be1489d574a447f3c48
AUX pdftops-1.20.gentoo 10412 RMD160 16e229662c47e03af1d1f4cb5764a76d17a66642 SHA1 6afb8a655b6ff013a2c8c8cbfb615ba1e561503b SHA256 ac5fa01ca776d75bd7cef62eef9f6b0c3945ee87e8950b40ca9f9f3ff46a16c1
DIST cups-1.3.9-source.tar.bz2 3993875 RMD160 ec8bd9fc6ee45648b6eb22949f44fc4cf2defd4e SHA1 c1a596b355201320456b393446286fe3947bce16 SHA256 38856ab4b8bcf51be2bed1f554cd8089c1f2448a6979c055762b49eda82a6b6b
EBUILD cups-1.3.9-r1.ebuild 8724 RMD160 2fadb7b929fa65fad0aab8df9e23a59f47843424 SHA1 9c3d039bb8941370f280915dded0c2467b573509 SHA256 823b083c2c1670f3dc069c70b07d408d96e92e567822106dac4e3613ed0b1588
MISC ChangeLog 50821 RMD160 40b896dd3fe2e308420adf8dedad90a47f7a066c SHA1 6928b3b72f18deda401537d2563aee8943769add SHA256 b825113915ff055c699aa09561538d9e21b8de21d770c06db46f5953b71bf6b3
MISC metadata.xml 161 RMD160 1e5b1e42553c8869b93c4a5448e9a2a2ed9fe525 SHA1 209c6a46e4cdd891980115e42ba419e3799f8088 SHA256 7c85e6739a71f5bb23e8de36c88677d772946e61f7285892f7554e37bd2bca76

View File

@ -0,0 +1,300 @@
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-print/cups/cups-1.3.9-r1.ebuild,v 1.11 2009/03/09 18:42:27 armin76 Exp $
inherit autotools eutils flag-o-matic multilib pam
MY_P=${P/_}
DESCRIPTION="The Common Unix Printing System"
HOMEPAGE="http://www.cups.org/"
SRC_URI="http://ftp.easysw.com/pub/cups/${PV}/${MY_P}-source.tar.bz2"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc ~sparc-fbsd x86 ~x86-fbsd"
IUSE="acl avahi dbus gnutls java jpeg kerberos ldap pam perl php png ppds python samba slp ssl static tiff X xinetd zeroconf"
COMMON_DEPEND="acl? ( kernel_linux? ( sys-apps/acl sys-apps/attr ) )
avahi? ( net-dns/avahi )
dbus? ( sys-apps/dbus )
gnutls? ( net-libs/gnutls )
java? ( >=virtual/jre-1.4 )
jpeg? ( >=media-libs/jpeg-6b )
kerberos? ( virtual/krb5 )
ldap? ( net-nds/openldap )
pam? ( virtual/pam )
perl? ( dev-lang/perl )
php? ( dev-lang/php )
png? ( >=media-libs/libpng-1.2.1 )
python? ( dev-lang/python )
slp? ( >=net-libs/openslp-1.0.4 )
ssl? ( !gnutls? ( >=dev-libs/openssl-0.9.8g ) )
tiff? ( >=media-libs/tiff-3.5.5 )
xinetd? ( sys-apps/xinetd )
zeroconf? ( !avahi? ( net-misc/mDNSResponder ) )
app-text/libpaper
dev-libs/libgcrypt"
DEPEND="${COMMON_DEPEND}
!<net-print/foomatic-filters-ppds-20070501
!<net-print/hplip-1.7.4a-r1"
RDEPEND="${COMMON_DEPEND}
!virtual/lpr
X? ( x11-misc/xdg-utils )
>=app-text/poppler-0.4.3-r1"
PDEPEND="
ppds? ( || (
(
net-print/foomatic-filters-ppds
net-print/foomatic-db-ppds
)
net-print/foomatic-filters-ppds
net-print/foomatic-db-ppds
net-print/hplip
net-print/gutenprint
net-print/foo2zjs
net-print/cups-pdf
) )
samba? ( >=net-fs/samba-3.0.8 )
virtual/ghostscript"
PROVIDE="virtual/lpr"
# upstream includes an interactive test which is a nono for gentoo.
# therefore, since the printing herd has bigger fish to fry, for now,
# we just leave it out, even if FEATURES=test
RESTRICT="test"
S="${WORKDIR}/${MY_P}"
LANGS="de en es et fr he id it ja pl sv zh_TW"
for X in ${LANGS} ; do
IUSE="${IUSE} linguas_${X}"
done
pkg_setup() {
if use avahi && ! built_with_use net-dns/avahi mdnsresponder-compat ; then
echo
eerror "In order to have cups working with avahi zeroconf support, you need"
eerror "to have net-dns/avahi emerged with \"mdnsresponder-compat\" in your USE"
eerror "flag. Please add that flag, re-emerge avahi, and then emerge cups again."
die "net-dns/avahi is missing the mdnsresponder-compat feature."
fi
enewgroup lp
enewuser lp -1 -1 -1 lp
enewgroup lpadmin 106
}
src_unpack() {
unpack ${A}
cd "${S}"
# disable configure automagic for acl/attr, upstream bug STR #2723
epatch "${FILESDIR}/${PN}-1.3.0-configure.patch"
# create a missing symlink to allow https printing via IPP, bug #217293
epatch "${FILESDIR}/${PN}-1.3.7-backend-https.patch"
# use the ldap schema of the ldap draft
epatch "${FILESDIR}/${PN}-1.3.9-ldap-draft-1.patch"
# security bug #249727
epatch "${FILESDIR}/${PN}-1.3.9-CVE-2008-5286.patch"
# cups does not use autotools "the usual way" and ship a static config.h.in
eaclocal
eautoconf
}
src_compile() {
# Fails to compile on SH
use sh && replace-flags -O? -O0
# needed to prevent ghostscript compile failures
use kerberos && strip-flags
# locale support
strip-linguas ${LANGS}
if [ -z "${LINGUAS}" ] ; then
export LINGUAS=all
fi
export DSOFLAGS="${LDFLAGS}"
if use ldap ; then
append-flags -DLDAP_DEPRECATED
fi
local myconf
if use avahi || use zeroconf ; then
myconf="${myconf} --enable-dnssd"
else
myconf="${myconf} --disable-dnssd"
fi
if use ssl || use gnutls ; then
myconf="${myconf} \
$(use_enable gnutls) \
$(use_enable !gnutls openssl)"
else
myconf="${myconf} \
--disable-gnutls \
--disable-openssl"
fi
econf \
--libdir=/usr/$(get_libdir) \
--localstatedir=/var \
--with-cups-user=lp \
--with-cups-group=lp \
--with-docdir=/usr/share/cups/html \
--with-languages=${LINGUAS} \
--with-system-groups=lpadmin \
--with-xinetd=/etc/xinetd.d \
$(use_enable acl) \
$(use_enable dbus) \
$(use_enable jpeg) \
$(use_enable kerberos gssapi) \
$(use_enable ldap) \
$(use_enable pam) \
$(use_enable png) \
$(use_enable slp) \
$(use_enable static) \
$(use_enable tiff) \
$(use_with java) \
$(use_with perl) \
$(use_with php) \
$(use_with python) \
--enable-libpaper \
--enable-threads \
--disable-pdftops \
${myconf}
# install in /usr/libexec always, instead of using /usr/lib/cups, as that
# makes more sense when facing multilib support.
sed -i -e 's:SERVERBIN.*:SERVERBIN = "$(BUILDROOT)"/usr/libexec/cups:' Makedefs
sed -i -e 's:#define CUPS_SERVERBIN.*:#define CUPS_SERVERBIN "/usr/libexec/cups":' config.h
sed -i -e 's:cups_serverbin=.*:cups_serverbin=/usr/libexec/cups:' cups-config
emake || die "emake failed"
}
src_install() {
emake BUILDROOT="${D}" install || die "emake install failed"
dodoc {CHANGES{,-1.{0,1}},CREDITS,README}.txt || die "dodoc install failed"
# clean out cups init scripts
rm -rf "${D}"/etc/{init.d/cups,rc*,pam.d/cups}
# install our init script
local neededservices
use avahi && neededservices="$neededservices avahi-daemon"
use dbus && neededservices="$neededservices dbus"
use zeroconf && ! use avahi && neededservices="$neededservices mDNSResponderPosix"
[[ -n ${neededservices} ]] && neededservices="need${neededservices}"
sed -e "s/@neededservices@/$neededservices/" "${FILESDIR}"/cupsd.init.d > "${T}"/cupsd
doinitd "${T}"/cupsd
# install our pam script
pamd_mimic_system cups auth account
if use xinetd ; then
# correct path
sed -i -e "s:server = .*:server = /usr/libexec/cups/daemon/cups-lpd:" "${D}"/etc/xinetd.d/cups-lpd
# it is safer to disable this by default, bug #137130
grep -w 'disable' "${D}"/etc/xinetd.d/cups-lpd || \
sed -i -e "s:}:\tdisable = yes\n}:" "${D}"/etc/xinetd.d/cups-lpd
else
rm -rf "${D}"/etc/xinetd.d
fi
# install pdftops filter
exeinto /usr/libexec/cups/filter/
newexe "${FILESDIR}"/pdftops-1.20.gentoo pdftops
# only for gs-esp this is correct, see bug #163897
if has_version app-text/ghostscript-gpl || has_version app-text/ghostscript-gnu ; then
sed -i -e "s:#application/vnd.cups-postscript:application/vnd.cups-postscript:" "${D}"/etc/cups/mime.convs
fi
keepdir /usr/share/cups/profiles /usr/libexec/cups/driver /var/log/cups \
/var/run/cups/certs /var/cache/cups /var/spool/cups/tmp /etc/cups/ssl
# .desktop handling. X useflag. xdg-open from freedesktop is preferred, upstream bug STR #2724.
if use X ; then
sed -i -e "s:htmlview:xdg-open:" "${D}"/usr/share/applications/cups.desktop
else
rm -r "${D}"/usr/share/applications
fi
# fix a symlink collision, see bug #172341
dodir /usr/share/ppd
dosym /usr/share/ppd /usr/share/cups/model/foomatic-ppds
# create RSS feed directory
diropts -m 0740 -o lp -g lp
dodir /var/cache/cups/rss
# create /etc/cups/client.conf, bug #196967
echo "ServerName localhost" >> "${D}"/etc/cups/client.conf
}
pkg_preinst() {
# cleanups
[ -n "${PN}" ] && rm -fR "${ROOT}"/usr/share/doc/"${PN}"-*
has_version "=${CATEGORY}/${PN}-1.2*"
upgrade_from_1_2=$?
}
pkg_postinst() {
echo
elog "For information about installing a printer and general cups setup"
elog "take a look at: http://www.gentoo.org/doc/en/printing-howto.xml"
echo
local good_gs=false
for x in app-text/ghostscript-gpl app-text/ghostscript-gnu app-text/ghostscript-esp ; do
if has_version ${x} && built_with_use ${x} cups ; then
good_gs=true
break
fi
done
if ! ${good_gs} ; then
echo
ewarn "You need to emerge ghostscript with the \"cups\" USE flag turned on."
echo
fi
if [[ $upgrade_from_1_2 = 0 ]] ; then
echo
ewarn "You have upgraded from an older cups version. Please make sure"
ewarn "to run \"etc-update\" and \"revdep-rebuild\" NOW."
echo
fi
if [ -e "${ROOT}"/usr/lib/cups ] ; then
echo
ewarn "/usr/lib/cups exists - You need to remerge every ebuild that"
ewarn "installed into /usr/lib/cups and /etc/cups, qfile is in portage-utils:"
ewarn "# FEATURES=-collision-protect emerge -va1 \$(qfile -qC /usr/lib/cups /etc/cups | sed \"s:net-print/cups$::\")"
echo
ewarn "FEATURES=-collision-protect is needed to overwrite the compatibility"
ewarn "symlinks installed by this package, it won't be needed on later merges."
ewarn "You should also run revdep-rebuild"
echo
# place symlinks to make the update smoothless
for i in "${ROOT}"/usr/lib/cups/{backend,filter}/* ; do
if [ "${i/\*}" == "${i}" ] && ! [ -e ${i/lib/libexec} ] ; then
ln -s ${i} ${i/lib/libexec}
fi
done
fi
}

View File

@ -0,0 +1,18 @@
diff -Naur cups-1.3.3/config-scripts/cups-common.m4 cups-1.3.3.new/config-scripts/cups-common.m4
--- cups-1.3.3/config-scripts/cups-common.m4 2007-09-28 22:40:03.000000000 +0200
+++ cups-1.3.3.new/config-scripts/cups-common.m4 2007-10-04 14:40:49.414154416 +0200
@@ -270,7 +270,12 @@
dnl See if we have POSIX ACL support...
SAVELIBS="$LIBS"
LIBS=""
-AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
+
+AC_ARG_ENABLE(acl, [ --enable-acl enable POSIX ACL support, default=auto])
+if test "x$enable_acl" != xno; then
+ AC_SEARCH_LIBS(acl_init, acl, AC_DEFINE(HAVE_ACL_INIT))
+fi
+
CUPSDLIBS="$CUPSDLIBS $LIBS"
LIBS="$SAVELIBS"

View File

@ -0,0 +1,11 @@
diff -Naur cups-1.3.7/backend/Makefile cups-1.3.7.new/backend/Makefile
--- cups-1.3.7/backend/Makefile 2007-08-08 21:27:51.000000000 +0200
+++ cups-1.3.7.new/backend/Makefile 2008-04-14 16:42:18.106785330 +0200
@@ -62,6 +62,7 @@
done
$(RM) $(SERVERBIN)/backend/http
$(LN) ipp $(SERVERBIN)/backend/http
+ $(LN) ipp $(SERVERBIN)/backend/https
if test "x$(SYMROOT)" != "x"; then \
$(INSTALL_DIR) $(SYMROOT); \
for file in $(TARGETS); do \

View File

@ -0,0 +1,22 @@
Index: filter/image-png.c
===================================================================
--- filter/image-png.c (revision 8062)
+++ filter/image-png.c (working copy)
@@ -178,7 +178,7 @@
{
bufsize = img->xsize * img->ysize;
- if ((bufsize / img->ysize) != img->xsize)
+ if ((bufsize / img->xsize) != img->ysize)
{
fprintf(stderr, "DEBUG: PNG image dimensions (%ux%u) too large!\n",
(unsigned)width, (unsigned)height);
@@ -190,7 +190,7 @@
{
bufsize = img->xsize * img->ysize * 3;
- if ((bufsize / (img->ysize * 3)) != img->xsize)
+ if ((bufsize / (img->xsize * 3)) != img->ysize)
{
fprintf(stderr, "DEBUG: PNG image dimensions (%ux%u) too large!\n",
(unsigned)width, (unsigned)height);

View File

@ -0,0 +1,102 @@
Submitted By: Mario Fetka (mario dot fetka at gmail dot com)
Date: 2009-03-13
Initial Package Version: 1.3.9
Origin: me
Upstream Status: unknown
Description: use the oids from the ldap ipp draft
https://datatracker.ietf.org/drafts/draft-ietf-ipp-ldap-printer-schema/
this patch also requres a migration addon schema
http://ftp.mars.arge.at/mds/printer-cups.schema
diff -Naur cups-1.3.9.orig/scheduler/dirsvc.c cups-1.3.9/scheduler/dirsvc.c
--- cups-1.3.9.orig/scheduler/dirsvc.c 2008-07-18 20:30:23.000000000 +0000
+++ cups-1.3.9/scheduler/dirsvc.c 2009-03-13 20:49:31.160730818 +0000
@@ -104,11 +104,11 @@
#ifdef HAVE_OPENLDAP
static const char * const ldap_attrs[] =/* CUPS LDAP attributes */
{
- "printerDescription",
- "printerLocation",
- "printerMakeAndModel",
- "printerType",
- "printerURI",
+ "printer-info",
+ "printer-location",
+ "printer-make-and-model",
+ "printer-type",
+ "printer-uri",
NULL
};
#endif /* HAVE_OPENLDAP */
@@ -1439,35 +1439,35 @@
*/
if ((value = ldap_get_values(BrowseLDAPHandle, e,
- "printerDescription")) == NULL)
+ "printer-info")) == NULL)
continue;
strlcpy(info, *value, sizeof(info));
ldap_value_free(value);
if ((value = ldap_get_values(BrowseLDAPHandle, e,
- "printerLocation")) == NULL)
+ "printer-location")) == NULL)
continue;
strlcpy(location, *value, sizeof(location));
ldap_value_free(value);
if ((value = ldap_get_values(BrowseLDAPHandle, e,
- "printerMakeAndModel")) == NULL)
+ "printer-make-and-model")) == NULL)
continue;
strlcpy(make_model, *value, sizeof(make_model));
ldap_value_free(value);
if ((value = ldap_get_values(BrowseLDAPHandle, e,
- "printerType")) == NULL)
+ "printer-type")) == NULL)
continue;
type = atoi(*value);
ldap_value_free(value);
if ((value = ldap_get_values(BrowseLDAPHandle, e,
- "printerURI")) == NULL)
+ "printer-uri")) == NULL)
continue;
strlcpy(uri, *value, sizeof(uri));
@@ -3004,7 +3004,7 @@
uri[1] = NULL;
snprintf(filter, sizeof(filter),
- "(&(objectclass=cupsPrinter)(printerURI=%s))", p->uri);
+ "(&(objectclass=cupsPrinter)(printer-uri=%s))", p->uri);
ldap_search_s(BrowseLDAPHandle, BrowseLDAPDN, LDAP_SCOPE_SUBTREE,
filter, (char **)ldap_attrs, 0, &res);
@@ -3013,15 +3013,15 @@
mods[0].mod_type = "cn";
mods[0].mod_values = cn_value;
- mods[1].mod_type = "printerDescription";
+ mods[1].mod_type = "printer-info";
mods[1].mod_values = info;
- mods[2].mod_type = "printerURI";
+ mods[2].mod_type = "printer-uri";
mods[2].mod_values = uri;
- mods[3].mod_type = "printerLocation";
+ mods[3].mod_type = "printer-location";
mods[3].mod_values = location;
- mods[4].mod_type = "printerMakeAndModel";
+ mods[4].mod_type = "printer-make-and-model";
mods[4].mod_values = make_model;
- mods[5].mod_type = "printerType";
+ mods[5].mod_type = "printer-type";
mods[5].mod_values = type;
mods[6].mod_type = "objectClass";
mods[6].mod_values = (char **)objectClass_values;

View File

@ -0,0 +1,20 @@
#!/sbin/runscript
depend() {
use net
@neededservices@
before nfs
after logger
}
start() {
ebegin "Starting cupsd"
start-stop-daemon --start --quiet --exec /usr/sbin/cupsd
eend $?
}
stop() {
ebegin "Stopping cupsd"
start-stop-daemon --stop --quiet --exec /usr/sbin/cupsd
eend $?
}

View File

@ -0,0 +1,340 @@
#!/usr/bin/perl -w
# pdftops.pl - wrapper script for xpdf's pdftops utility to act as a CUPS filter
# ==============================================================================
# 1.00 - 2004-10-05/Bl
# Initial implementation
# 1.10 - 2006-09-27/Bl
# Alternatively, use Adobe Reader in place of Xpdf's pdftops
# 1.20 - 2007-12-03/Bl
# Safe temp file creation (fix gentoo bug # 201042)
#
# Copyright: Helge Blischke / SRZ Berlin 2004-2006
# This program is free seoftware and governed by the GNU Public License Version 2.
#
# Description:
# ------------
# This program wraps the pdftops utility from the xpdf 3.00 (and higher) suite
# to behave as a CUPS filter as a replacement for the original pdftops filter.
# As an alternative the Adobe Reader may be used.
#
# The main purpose of this approach is to keep the properties of a PDF to be
# printed as undesturbed as possible, especially with respect to page size,
# scaling, and positioning.
#
# The pdftops utility reads a configuration file 'pdftops.conf' or 'acroread.conf',
# respectively, in the CUPS_SERVERROOT directory, which must exist but may be empty.
# The sample configuration file accompanying this program sets the defaults which
# seem plausible to me with respect to high end production printers.
#
# To give the user highest possible flexibility, this program accepts and
# evaluates a set of job attributes special to this filter, which are
# described below:
#
# pdf-pages=<f>,<l>
# expands to the -f and -l options of pdftops
# or the -start and -end options of acroread, respectively
# to select a page range to process. This is independent
# of the page-ranges attribute and may significantly
# increase throughput when printing page ranges.
# Either of these numbers may be omitted.
#
# pdf-paper=<name>
# For pdftops, <name> may be one of "letter", "legal",
# "A4", "A3", or "match"; for acroread, the permetted values
# are "letter", "legal", "tabloid", "ledger", "executive",
# "a3", "a4", "a5", "b4", "b5", respectively (without the
# quotes; the names are treated case independent).
# In case of acroread, no paper specification is equivalent
# to pdsftops's "match".
# pdf-paper=<width>x<height>
# <name> may be one of letter, legal , A4, A3, or match;
# <width> and <height> are the paper width and height
# in printers points (1/72 inch). This expands to
# either the -paper or the -paperh and -paperw options
# of pdftops or the -size option of acroread.
#
# pdf-opw=<password>
# pdf-upw=<password>
# expand to the -opw and -upw options of pdftops,
# respectively and permit printing of password
# protected PDFs.
#
# pdf-<option> where <option> is one of
# level1, level1sep, level2, level2sep, level3, level3sep,
# opi, nocrop, expand, noshrink, nocenter.
# See the pdftops manpage for a detailed description of
# the respective options.
# In case of acroread, the options level1, level?sep, opi,
# nocrop, noshrink, and nocenter are silently ignored.
#
# All other pdftops commandline options are refused.
#
# The return code of the pdftops utility or acroread, if nonzero, is used as the exit code
# of this program; error messages of the pdftops utility are only visible
# if 'debug' is specified as LogLevel in cupsd.conf.
#
# NOTE:
# -----
# This wrapper script has been initially designed to use the original pdftops utility
# as a CUPS filter and now extended to alternately use acroread.
# But there are situations where you need to be able to select either variant, thus it
# is possible to configure the wrapper to both programs but select one of them by default;
# the other one then may be selected by command line option:
#
# use-pdftops selects pdftops
# use-acroread selects acroread
#
# if both are configured (by defining the appropriate configuration file).
#
#
# Site specific parameters - modify as needed
# ----------------------------------------------------------------------------------
$pdftops_path = "/usr/bin/pdftops"; # path to the xpdf utility
$acroread_path = "/opt/bin/acroread"; # path to Adobe Reader
$default_app = 'use-pdftops'; # the default if both are configured
$use_pdftops = 1; # default on gentoo and highly recommended
$use_acroread = 0; # not supported/working on gentoo yet, use at your own risk
# ----------------------------------------------------------------------------------
use File::Temp qw( tempfile );
#
# Check which app to use - pdftops or acroread
#
$rootdir = $ENV{CUPS_SERVERROOT} || die ("ERROR: CUPS server root directory undefined\n");
$use_both = $use_pdftops && $use_acroread;
#
# Check the arguments
#
die ("ERROR: wrong number of arguments\n") if (scalar @ARGV < 5);
$jobid = $username = $title = $copies = undef;
$jobid = shift; # Job ID
$username = shift; # Job requesting user name
$title = shift; # Job title
$copies = shift; # Number of requested copies
$options = shift; # Textual representation of job attributes
$pdffile = shift; # Pathname of PDF file to process
if (defined $use_both && $use_both)
{
my $optstr = " $options ";
my $to_use = '';
if ($optstr =~ /\s+(use-acroread|use-pdftops)\s+/)
{
$to_use = $1;
}
else
{
$to_use = $default_app;
}
if ($to_use eq 'use-acroread')
{
undef $use_pdftops;
}
elsif ($to_use eq 'use-pdftops')
{
undef $use_acroread;
}
else
{
die ("ERROR: cannot use both pdftops and acroread simultaneously\n");
}
}
if (defined $use_pdftops)
{
# If we are reading from STDIN, we must copy the input to a temporary file
# as the PDF consumer needs a seekable input.
if (! defined $pdffile)
{
my $template = "pdfinXXXXXX";
my $tmpdir = $ENV{TMPDIR};
my ($bytes, $buffer);
my ($tmpfh, $tmpfile) = tempfile ($template, OPEN => 1, DIR => $tmpdir, UNLINK => 0, SUFFIX => '.tmp');
while (($bytes = read (STDIN, $buffer, 1024)) > 0)
{
print $tmpfh "$buffer";
}
if ($bytes < 0)
{
close ($tmpfh);
unlink $tmpfile;
die ("ERROR: pdftops wrapper: $tmpfile: $!\n");
}
close ($tmpfh);
$pdffile = $tmpfile;
$delete_input = 1; # for deleting the temp file after converting
}
}
#
# Check the options string for options to modify the bahaviour of the pdftops utility:
#
@optarr = split (/\s+/, $options);
if (defined $use_pdftops)
{
$cmdopt = ""; # do not pass the -cfg argument to the poppler pdftops util
# The following are the (parameterless) command line options that may be used to change the
# defaults defiend by pdftops.conf
$simple = 'level1|level1sep|level2|level2sep|level3|level3sep|opi|nocrop|expand|noshrink|nocenter';
%papernames = (
'letter' => '-paper letter',
'tabloid' => '-paperw 792 -paperh 1224',
'ledger' => '-paperw 1224 -paperh 792',
'legal' => '-paper legal',
'executive' => '-paperw 756 -paperh 522',
'a3' => '-paper A3',
'a4' => '-paper A4',
'a5' => '-paperw 421 -paperh 595',
'b4' => '-paperw 709 -paperh 1002',
'b5' => '-paperw 501 -paperh 709',
'match' => '-paper match'
);
}
else
{
open (CFG, "<$rootdir/acroread.conf") || die ("ERROR: acroread.conf: $!\n");
$cmdopt = '-toPostScript';
while (<CFG>)
{
chomp;
next if (/^\s*#/); # skip comment lines
next if (/^\s*$/); # skip blank lines
s/^-\s*//; # discard leading '-' and white space, as it will be generated later
s/\s+$//; # discard trailing white space
$cmdopt .= " -$_";
}
close (CFG);
$simple = 'level1|level1sep|level2|level2sep|level3|level3sep|opi|nocrop|expand|noshrink|nocenter';
%papernames = (
'letter' => '-size letter',
'tabloid' => '-size tabloid',
'ledger' => '-size ledger',
'legal' => '-size legal',
'executive' => '-size executive',
'a3' => '-size a3',
'a4' => '-size a4',
'a5' => '-size a5',
'b4' => '-size b4',
'b5' => '-size b5',
'match' => '' # this is the default with acroread
);
}
foreach my $option (@optarr)
{
if ($option =~ /^pdf-(.+)$/)
{ # We assume this is an option to evaluate
my $optkey = $1; # possible pdftops option
if ($optkey =~ /^pages=(\d*),(\d*)$/)
{
# We do this hack here to avoid clashes with the page-ranges atrribute
# which is handled by the pstops filter. And we allow one of the numbers
# to be omitted.
my $first = $1;
my $lastp = $2;
if (defined $use_pdftops)
{
$cmdopt .= " -f $1" if ($1); # first page
$cmdopt .= " -l $2" if ($2); # last page
}
else
{
$cmdopt .= " -start $1" if ($1); # first page
$cmdopt .= " -end $2" if ($2); # last page
}
}
elsif ($optkey =~ /^paper=(letter|tabloid|ledger|legal|[Aa]3|[Aa]4|[Aa]5|[Bb]4|[Bb]5|match)$/)
{
# evaluate paper name
my $paper = $1;
$paper =~ tr/A-Z/a-z/;
my $value = $papernames{$paper};
$cmdopt .= " $value" if ($value);
}
elsif ($optkey =~ /^paper=(\d+)x(\d+)$/)
{
# evaluate paper dimensions
if (defined $use_pdftops)
{
$cmdopt .= " -paperw $1 -paperh $2";
}
else
{
$cmdopt .= " -size $1" . 'x' . "$2";
}
}
elsif ($optkey =~ /^(o|u)pw=(\S+)$/)
{
$cmdopt .= " $1" . 'pw ' . $2 if (defined $use_pdftops); # owner/user password
}
elsif ($optkey =~ /^($simple)$/)
{
my $thisopt = $1;
if (defined $use_pdftops)
{
$cmdopt .= ' -' . $1; # allowed simple options
}
else
{
$thisopt =~ s/sep$//; # ignore the ...sep suffix
if ($thisopt =~ /level1|opi|nocrop|nocenter/)
{
$thisopt = '';
}
elsif ($thisopt eq 'noshrink')
{
$thisopt = '';
$cmdopt =~ s/ -shrink//;
}
$cmdopt .= " -" . $thisopt if ($thisopt);
}
}
else
{
warn ("ERROR: pdftops wrapper: illegal attribute \"pdf-$optkey\"\n");
}
}
# All other attributes are processed elsewhere
}
#
# Complete the command
#
if (defined $use_pdftops)
{
warn ("ERROR: pdftops-options: $cmdopt\n");
}
else
{
warn ("ERROR: acroread-options: $cmdopt\n");
}
if (defined $use_pdftops)
{
$rc = system ("$pdftops_path $cmdopt $pdffile -");
}
else
{
if (defined $pdffile && $pdffile)
{
$rc = system ("$acroread_path $cmdopt < $pdffile")
}
else
{
$rc = system ("$acroread_path $cmdopt");
}
}
if ($rc)
{
$ir = $rc & 127;
$rc >>= 8;
my $temp = (defined $use_pdftops) ? $pdftops_path : $acroread_path;
warn ("ERROR: $temp exited with ", ($ir) ? "signal $ir, " : " exit code $rc", "\n");
exit $rc;
}
unlink ($pdffile) if (defined $delete_input); # Delete the temp file if any
exit 0;

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<herd>printing</herd>
</pkgmetadata>