Add ebuild for k3b-2.0.0.
[overlay.git] / net-print / cups / cups-1.4.2-r1.ebuild
1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/net-print/cups/cups-1.4.2-r1.ebuild,v 1.1 2009/11/30 22:00:56 tgurr Exp $
4
5 EAPI="2"
6
7 inherit eutils flag-o-matic multilib pam versionator
8
9 MY_P=${P/_}
10
11 DESCRIPTION="The Common Unix Printing System."
12 HOMEPAGE="http://www.cups.org/"
13 SRC_URI="mirror://easysw/${PN}/${PV}/${MY_P}-source.tar.bz2"
14
15 LICENSE="GPL-2"
16 SLOT="0"
17 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~sparc-fbsd ~x86 ~x86-fbsd"
18 IUSE="acl dbus debug gnutls java +jpeg kerberos ldap pam perl php +png python samba slp +ssl static +tiff X xinetd"
19
20 COMMON_DEPEND="acl? ( kernel_linux? ( sys-apps/acl sys-apps/attr ) )
21         dbus? ( sys-apps/dbus )
22         gnutls? ( net-libs/gnutls )
23         java? ( >=virtual/jre-1.4 )
24         jpeg? ( >=media-libs/jpeg-6b )
25         kerberos? ( virtual/krb5 )
26         ldap? ( net-nds/openldap )
27         pam? ( virtual/pam )
28         perl? ( dev-lang/perl )
29         php? ( dev-lang/php )
30         png? ( >=media-libs/libpng-1.2.1 )
31         python? ( dev-lang/python )
32         slp? ( >=net-libs/openslp-1.0.4 )
33         ssl? ( !gnutls? ( >=dev-libs/openssl-0.9.8g ) )
34         tiff? ( >=media-libs/tiff-3.5.5 )
35         xinetd? ( sys-apps/xinetd )
36         app-text/libpaper
37         virtual/poppler-utils
38         dev-libs/libgcrypt
39         dev-libs/libusb
40         !net-print/cupsddk"
41
42 DEPEND="${COMMON_DEPEND}"
43
44 RDEPEND="${COMMON_DEPEND}
45         !virtual/lpr
46         X? ( x11-misc/xdg-utils )"
47
48 PDEPEND="|| ( app-text/ghostscript-gpl[cups] app-text/ghostscript-gnu[cups] )"
49
50 PROVIDE="virtual/lpr"
51
52 # upstream includes an interactive test which is a nono for gentoo.
53 # therefore, since the printing herd has bigger fish to fry, for now,
54 # we just leave it out, even if FEATURES=test
55 RESTRICT="test"
56
57 S="${WORKDIR}/${MY_P}"
58
59 LANGS="da de es eu fi fr it ja ko nl no pl pt pt_BR ru sv zh zh_TW"
60 for X in ${LANGS} ; do
61         IUSE="${IUSE} linguas_${X}"
62 done
63
64 pkg_setup() {
65         enewgroup lp
66         enewuser lp -1 -1 -1 lp
67         enewgroup lpadmin 106
68 }
69
70 src_prepare() {
71         # create a missing symlink to allow https printing via IPP, bug #217293
72         epatch "${FILESDIR}/${PN}-1.4.0-backend-https.patch"
73
74         # CVE-2009-3553: Use-after-free (crash) due improper reference counting
75         # in abstract file descriptors handling interface
76         # upstream bug STR #3200
77         epatch "${FILESDIR}/${PN}-1.4.2-str3200.patch"
78 }
79
80 src_configure() {
81         # locale support
82         strip-linguas ${LANGS}
83         if [ -z "${LINGUAS}" ] ; then
84                 export LINGUAS=none
85         fi
86
87         local myconf
88         if use ssl || use gnutls ; then
89                 myconf="${myconf} \
90                         $(use_enable gnutls) \
91                         $(use_enable !gnutls openssl)"
92         else
93                 myconf="${myconf} \
94                         --disable-gnutls \
95                         --disable-openssl"
96         fi
97
98         econf \
99                 --libdir=/usr/$(get_libdir) \
100                 --localstatedir=/var \
101                 --with-cups-user=lp \
102                 --with-cups-group=lp \
103                 --with-docdir=/usr/share/cups/html \
104                 --with-languages="${LINGUAS}" \
105                 --with-pdftops=pdftops \
106                 --with-system-groups=lpadmin \
107                 $(use_enable acl) \
108                 $(use_enable dbus) \
109                 $(use_enable debug) \
110                 $(use_enable debug debug-guards) \
111                 $(use_enable jpeg) \
112                 $(use_enable kerberos gssapi) \
113                 $(use_enable ldap) \
114                 $(use_enable pam) \
115                 $(use_enable png) \
116                 $(use_enable slp) \
117                 $(use_enable static) \
118                 $(use_enable tiff) \
119                 $(use_enable xinetd xinetd /etc/xinetd.d) \
120                 $(use_with java) \
121                 $(use_with perl) \
122                 $(use_with php) \
123                 $(use_with python) \
124                 --enable-libpaper \
125                 --enable-libusb \
126                 --enable-threads \
127                 --enable-pdftops \
128                 --disable-dnssd \
129                 ${myconf}
130
131         # install in /usr/libexec always, instead of using /usr/lib/cups, as that
132         # makes more sense when facing multilib support.
133         sed -i -e 's:SERVERBIN.*:SERVERBIN = "$(BUILDROOT)"/usr/libexec/cups:' Makedefs
134         sed -i -e 's:#define CUPS_SERVERBIN.*:#define CUPS_SERVERBIN "/usr/libexec/cups":' config.h
135         sed -i -e 's:cups_serverbin=.*:cups_serverbin=/usr/libexec/cups:' cups-config
136 }
137
138 src_install() {
139         emake BUILDROOT="${D}" install || die "emake install failed"
140         dodoc {CHANGES,CREDITS,README}.txt || die "dodoc install failed"
141
142         # clean out cups init scripts
143         rm -rf "${D}"/etc/{init.d/cups,rc*,pam.d/cups}
144
145         # install our init script
146         local neededservices
147         use dbus && neededservices="$neededservices dbus"
148         [[ -n ${neededservices} ]] && neededservices="need${neededservices}"
149         sed -e "s/@neededservices@/$neededservices/" "${FILESDIR}"/cupsd.init.d > "${T}"/cupsd
150         doinitd "${T}"/cupsd || die "doinitd failed"
151
152         # install our pam script
153         pamd_mimic_system cups auth account
154
155         if use xinetd ; then
156                 # correct path
157                 sed -i -e "s:server = .*:server = /usr/libexec/cups/daemon/cups-lpd:" "${D}"/etc/xinetd.d/cups-lpd
158                 # it is safer to disable this by default, bug #137130
159                 grep -w 'disable' "${D}"/etc/xinetd.d/cups-lpd || \
160                         sed -i -e "s:}:\tdisable = yes\n}:" "${D}"/etc/xinetd.d/cups-lpd
161         else
162                 rm -rf "${D}"/etc/xinetd.d
163         fi
164
165         keepdir /usr/libexec/cups/driver /usr/share/cups/{model,profiles} \
166                 /var/cache/cups /var/cache/cups/rss /var/log/cups /var/run/cups/certs \
167                 /var/spool/cups/tmp
168
169         keepdir /etc/cups/{interfaces,ppd,ssl}
170
171         use X || rm -r "${D}"/usr/share/applications
172
173         # create /etc/cups/client.conf, bug #196967 and #266678
174         echo "ServerName /var/run/cups/cups.sock" >> "${D}"/etc/cups/client.conf
175 }
176
177 pkg_postinst() {
178         echo
179         elog "For information about installing a printer and general cups setup"
180         elog "take a look at: http://www.gentoo.org/doc/en/printing-howto.xml"
181         echo
182 }