Summary: Extension for creating pdf-Files with CUPS
Summary(ja): CUPS を用いた仮想 PDF プリンター
Name: cups-pdf
Version: 2.5.1
Release: 1%{?_dist_release}
Source0: http://www.cups-pdf.de/src/%{name}_%{version}.tar.gz
Source1: INSTALL.cups-pdf
Patch0: cups-pdf-conf-vine.patch
Patch2: cups-pdf-desktop.patch
Patch10: http://archive.ubuntu.com/ubuntu/pool/universe/c/cups-pdf/cups-pdf_2.5.0-4.diff.gz
## Modified 70_cups-pdf_support-pdf-workflow.patch 
## including cups-pdf_2.5.0-4.diff.gz
Patch11: cups-2.5.1-70_cups-pdf_support-pdf-workflow.patch
License: GPLv2+
Group: Applications/Publishing
URL: http://www.cups-pdf.de/

Requires: ghostscript, cups
#Requires: perl-MIME-tools, perl-MailTools
BuildRequires: gcc
BuildRoot: %{_tmppath}/%{name}-%{version}-root

# These are the defaults paths defined in config.h
# CUPS-PDF spool directory
%define CPSPOOL /var/spool/cups-pdf/SPOOL

# CUPS-PDF output directory
%define CPOUT /var/spool/cups-pdf

# CUPS-PDF log directory
%define CPLOG /var/log/cups

# CUPS-PDF cups-pdf.conf config file
%define ETCCUPS /etc/cups

# Additional path to backend directory
%define CPBACKEND %{_libdir}/cups/backend


%description
"cups-pdf" is a backend script for use with CUPS - 
the "Common UNIX Printing System" (see more for CUPS under 
http://www.cups.org/). "cups-pdf" uses the ghostscript pdfwrite
device to produce PDF Files.

%description -l ja
cups-pdf は CUPS (Common UNIX Printing System, http://www.cups.org/) 
を用いたいわゆる仮想 PDF プリンタのためのバックエンドスクリプトです。
cups-pdf は PDF ファイルを生成するために Ghostscript の 
pdfwrite デバイスを使います。

CUPS が動作しているときに %{name} をインストールすると、
自動的に "CUPS-PDF Printer" として CUPS の設定を行います。


%prep
%setup -n %{name}-%{version}
%patch0 -p1 -b .vine
%patch2 -p0

##%patch10 -p1
##patch -p0 -i debian/patches/60_cups-pdf_remove-contrib-SELinux-HOWTO-bashisms.patch
##patch -p1 -i debian/patches/70_cups-pdf_support-pdf-workflow.patch
%patch11 -p1

%build
pushd src
%{__cc} $RPM_OPT_FLAGS -o cups-pdf cups-pdf.c
popd

# Avoid perl dependencies
%{__chmod} -x contrib/pstitleiconv-0.2/pstitleiconv
%{__chmod} -x contrib/cups-pdf-dispatch-0.1/cups-pdf-dispatch
%{__chmod} -x contrib/SELinux-HOWTO/update-module

%install
%__rm -rf ${RPM_BUILD_ROOT}

%__mkdir_p $RPM_BUILD_ROOT%{CPBACKEND}
%__mkdir_p $RPM_BUILD_ROOT%{CPSPOOL}
%__mkdir_p $RPM_BUILD_ROOT%{CPOUT}
%__mkdir_p $RPM_BUILD_ROOT%{CPLOG}
%__mkdir_p $RPM_BUILD_ROOT%{CPBACKEND}
%__mkdir_p $RPM_BUILD_ROOT%{ETCCUPS}
%__mkdir_p $RPM_BUILD_ROOT%{_datadir}/cups/model/
%__install -m644 extra/CUPS-PDF.ppd $RPM_BUILD_ROOT%{_datadir}/cups/model/
%__install -m644 extra/cups-pdf.conf $RPM_BUILD_ROOT%{ETCCUPS}/cups-pdf.conf
%__install -m755 src/cups-pdf $RPM_BUILD_ROOT%{CPBACKEND}


%clean
[ "%{buildroot}" != "/" ] && %__rm -rf %{buildroot}


%post
# First install : create the printer if cupsd is running
if [ "$1" -eq "1" -a -f "%{_var}/run/cupsd.pid" ]
then
    /sbin/service cups condrestart
    if [ -d /proc/$(cat %{_var}/run/cupsd.pid) ]
    then
	echo "Install CUPS-PDF Printer ... "
        /usr/sbin/lpadmin -p Cups-PDF -v cups-pdf:/ -m CUPS-PDF.ppd -E || :
    fi
fi

%postun
if [ "$1" -eq "0" ]; then
    # Delete the printer
    echo "Remove CUPS-PDF Printer ... "
    /usr/sbin/lpadmin -x Cups-PDF || :
fi


%files
%defattr(-,root,root)
%doc ChangeLog COPYING README contrib/
%dir %{CPSPOOL}
%dir %{CPOUT}
%attr(700, root, root) %{CPBACKEND}/cups-pdf
%{_datadir}/cups/model/CUPS-PDF.ppd
%config(noreplace) %{ETCCUPS}/cups-pdf.conf


%changelog
* Fri Feb 25 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2.5.1-1
- new upstream release
- fixed %%description -l ja

* Sun Jul 26 2009 Munehiro Yamamoto <munepi@vinelinux.org> 2.5.0-4
- rename Patch0 to cups-pdf-conf-vine.patch
- updated cups-pdf-conf-vine.patch
  - set Truncate 256
- change cups-pdf.conf to %%config(noreplace) in %%files section

* Wed Jul 08 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 2.5.0-3
- updated cups-pdf.conf.vl.patch: set DecodeHexStrings 1 (Experimental)

* Tue Jul 07 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 2.5.0-2
- added cups-pdf_2.5.0-4.diff.gz from Ubuntu
  - applied 60_cups-pdf_remove-contrib-SELinux-HOWTO-bashisms.patch
  - applied 70_cups-pdf_support-pdf-workflow.patch
- added some comments in %%description -l ja
- added echo "install/remove CUPS-PDF Printer" in %%post and %%postun
- removed INSTALL and added README in %%doc

* Sat Feb 14 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 2.5.0-1
- new upstream release
- updated the URL tag
- correct the License tag

* Tue Dec 30 2008 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 2.4.8-2
- fixed typo in spec

* Wed Oct 29 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.8-1
- new upstream release

* Sun Sep 21 2008 Shu KONNO <owa@bg.wakwak.com> 2.4.6-1vl5
- applied new versioning policy, spec in utf-8

* Thu Jun 28 2007 Munehiro Yamamoto <myamamoto@g.math.s.chiba-u.ac.jp> 2.4.6-0vl2
- rebuld for VineSeed

* Thu Jun 28 2007 Munehiro Yamamoto <myamamoto@g.math.s.chiba-u.ac.jp> 2.4.6-0vl1
- source update
- delete -dNOKANJI option of Ghostscript

* Sun Mar 25 2007 Munehiro Yamamoto <myamamoto@g.math.s.chiba-u.ac.jp> 2.4.5-0vl1
- initial build for Vine Linux 4.1

* Mon Sep 26 2005	Christian Ellsworth C. <k.ellsworth@gmail.com>
- adapted to fit the new runtime config file of version 2.0

* Sat Mar 05 2005	Christian Ellsworth C. <k.ellsworth@gmail.com>
- adapted to cups-pdf 1.7.0
- added auto configure a cups-pdf printer

* Tue Feb 22 2005	Christian Ellsworth C. <k.ellsworth@gmail.com>
- adapted to cups-pdf 1.6.6

* Thu Aug 12 2004	Volker Behr <vrbehr@cip.physik.uni-wuerzburg.de>
- adapted to cups-pdf 1.5.2 

* Sat Jan 31 2004	Volker Behr <vrbehr@cip.physik.uni-wuerzburg.de>
- adapetd to cups-pdf 1.4.0 and new building environment

* Wed Jan 14 2004	Mark Lane <harddata.com>
- fixed the specfile so that x86_64 version installs the filter
- in /usr/lib64 instead of /usr/lib

* Sun Nov 02 2003	Volker Behr <vrbehr@cip.physik.uni-wuerzburg.de>
- third release of cups-pdf, RPM-Edition for cups-pdf 1.3

* Tue Sep 09 2003	Dirk Schwier <rpms@raumhochdrei.de>
- second Release of cups-pdf, RPM-Edition for cups-pdf 1.1

* Tue May 27 2003	Dirk Schwier <rpms@raumhochdrei.de>
- we're proud to present the first version of cups-pdf, RPM-Edition

# end of file
