File cups-pdf.spec of Package cups-pdf

# spec file for package cups-pdf
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

Name:		cups-pdf
Version:	2.6.1
Release:	1.0
License:	GPL-2.0
Group:		System/Printing
# URL for Source0:
# URL for MD5 for Source0:
# MD5 for Source0: 65f3fd525c4a9b1d736b91594b3166d5
Source0:	cups-pdf_%{version}.tar.gz
BuildRoot:	%{_tmppath}/%{name}-%{version}-build
Requires:	cups-client
Summary:	Virtual PDF printer for CUPS

CUPS-PDF is a PDF writer backend for CUPS.
It provides a virtual CUPS-PDF printer which produces PDF files
so that application programs which have no built-in support
to "Save as PDF" could print to CUPS-PDF to get a PDF file. 
For details see /usr/share/doc/packages/cups-pdf/README

%setup -q

cd src
%{__cc} $RPM_OPT_FLAGS -o cups-pdf cups-pdf.c  

%__install -Dm644 extra/CUPS-PDF.ppd %{buildroot}%{_datadir}/cups/model/CUPS-PDF.ppd
%__install -Dm644 extra/cups-pdf.conf %{buildroot}/etc/cups/cups-pdf.conf 
%__install -Dm700 src/cups-pdf %{buildroot}/usr/lib/cups/backend/cups-pdf
%__install -dm755 %{buildroot}/var/spool/cups-pdf

test "%{buildroot}" != "/" && %__rm -rf %{buildroot}

# Add a symbolic link if /usr/lib64/cups/backend/ exists:
if test -d /usr/lib64/cups/backend
then ln -s /usr/lib/cups/backend/cups-pdf /usr/lib64/cups/backend/cups-pdf || :
# Add a "CUPS-PDF" queue if the package is installed (but not when the package is updated):
if test "$1" -eq "1"
then /usr/sbin/lpadmin -h localhost -p CUPS-PDF -v cups-pdf:/ -m CUPS-PDF.ppd -E || :
# Exit successfully in any case:
exit 0

# Only if the package is erased (but not when it is replaced with an update package):
if test "$1" -eq "0"
then # Remove the "CUPS-PDF" queue (be silent if it does not exist):
     /usr/sbin/lpadmin -h localhost -x CUPS-PDF 2>/dev/null || :
     # Remove the symbolic link (ignore if it does not exist):
     rm -f /usr/lib64/cups/backend/cups-pdf || :
# Exit successfully in any case:
exit 0

%config(noreplace) /etc/cups/cups-pdf.conf
%dir /usr/lib/cups
%dir /usr/lib/cups/backend
%attr(700, root, root) /usr/lib/cups/backend/cups-pdf
%dir %{_datadir}/cups
%dir %{_datadir}/cups/model
%dir /var/spool/cups-pdf