# %define python_platlib %(python -c 'from distutils.sysconfig import get_python_lib; print get_python_lib(1)')
Summary:	HP printer drivers & utilities for Linux
Summary(ja): 	HP プリンタ用の Linux 向けドライバとユーティリティ
Name:		hplip
Version:	3.9.4b
Release: 	3%{?_dist_release}
Source0:	%{name}-%{version}.tar.gz
Source1:	hplip.desktop.vine
Patch0:		hplip-3.9.4b-gksu.patch
License:	GPL/MIT
Group:		Applications/Publishing
URL:		http://hplipopensource.com/hplip-web/index.html

Requires:	ghostscript, cups, foomatic, openssl
Requires:	libjpeg, python-imaging, hal, dbus
Requires:	%{name}-libs = %{version}-%{release}
Requires:	gksu
BuildRequires:	python-devel >= 2.3 , cups-devel, libusb-devel
BuildRequires:	net-snmp-devel, libjpeg-devel, sane-devel
BuildRequires:	dbus-devel
BuildRoot:	%{_tmppath}/%{name}-%{version}-root

Packager:	kazutaka

# When below files are included in %files section,
# find-requires shows strange error. 
#  %{_datadir}/hplip/base/kirbybase.py and pexpect.py
# So, below option is added to aboid this.
AutoReq:	False

%description
HPLIP is an HP developed solution for printing, scanning, and
faxing with HP inkjet and laser based printers in Linux.

The HPLIP project provides printing support for 1,151 printer
models, including Deskjet, Officejet, Photosmart, PSC (Print Scan
Copy), Business Inkjet, LaserJet, Edgeline MFP, and LaserJet MFP.

%description -l ja
HPLIP は HP が開発した HP インクジェット及びレーザープリンタ向けの、
プリンタ/スキャナ/FAX 機能を Linux 上で利用する為のソリューション
です。

HPLIP プロジェクトでは1,151種類のプリンタをサポートしています。
これには Deskjet、 Officejet、 Photosmart、 PSC (Print Scan Copy)、
Business Inkjet、 LaserJet、 Edgeline MFP 及び LaserJet MFP が
含まれます。

#---------------------------------------------------------------------

%package libs
Summary:	HPLIP libraries
Summary(ja):	HPLIP ライブラリ
Group:		System Environment/Libraries
License:	GPL/MIT

%description libs
Libraries needed by HPLIP.

%description libs -l ja
HPLIP 用のライブラリです。

#---------------------------------------------------------------------

%package gui
Summary:	HPLIP graphical tools
Summary(ja):	HPLIP 用 GUI ツール
Group:		Applications/System
License:	GPL/MIT
Requires:	PyQt, %{name} = %{version}-%{release}

%description gui
HP Device manager (toolbox) is a graphical utility including 
maintenance tools, supplies levels, and status information.

%description gui -l ja
HP デバイスマネージャ (toolbox) は、各種設定やインクや紙の残量確
認、ステータス情報の確認が行える HPLIP 用の GUI ユーティリティです。

#---------------------------------------------------------------------

%package -n libsane-hpaio
Summary:	SANE driver for scanners in HP's multi-function devices
Summary(ja):	HP 複合機のスキャナ用 SANE ドライバ
Group:		System Environment/Libraries
License:	GPL/MIT
Requires:	%{name}-libs = %{version}-%{release}, sane

%description -n libsane-hpaio
SANE driver for scanners in HP inkjet and laser based multi-function 
printers.

%description -n libsane-hpaio -l ja
HP インクジェット及びレーザープリンタ複合機のスキャナ機能を利用する
為の SANE ドライバです。

#---------------------------------------------------------------------

%prep
%setup -q
%patch0 -p1 -b .gksu

%build
%configure --enable-doc-build \
           --enable-network-build \
           --disable-pp-build \
           --enable-scan-build \
           --enable-gui-build \
           --enable-fax-build \
           --enable-dbus-build \
           --enable-qt3 \
           --disable-qt4 \
           --disable-foomatic-ppd-install \
           --disable-foomatic-xml-install \
           --with-cupsbackenddir=%{_libdir}/cups/backend \
           --with-cupsfilterdir=%{_libdir}/cups/filter \
           --with-hpppddir=%{_datadir}/cups/model/foomatic
%{__make}


%install
%{__rm} -rf ${RPM_BUILD_ROOT}
%{__make} install DESTDIR=${RPM_BUILD_ROOT}

# install modified .desktop
%{__install} -m 644 %{SOURCE1} ${RPM_BUILD_ROOT}/%{_datadir}/applications/hplip.desktop

# remove hpijs.
%{__rm} -rf ${RPM_BUILD_ROOT}/%{_bindir}/hpijs
%{__rm} -rf ${RPM_BUILD_ROOT}/%{_libdir}/cups/filter/hplipjs
%{__rm} -rf ${RPM_BUILD_ROOT}/%{_datadir}/cups/drv/hp/hpijs.drv

# remove unpacked files.
%{__rm} -rf ${RPM_BUILD_ROOT}%{_datadir}/cups/model/foomatic/hp-*
%{__rm} -rf ${RPM_BUILD_ROOT}%{_libdir}/libhpip.so

# remove unnecessary files.
%{__rm} -rf ${RPM_BUILD_ROOT}/%{_libdir}/libhpip.la
%{__rm} -rf ${RPM_BUILD_ROOT}/%{_libdir}/libhpmud.la
%{__rm} -rf ${RPM_BUILD_ROOT}/%{python_sitearch}/cupsext.la
%{__rm} -rf ${RPM_BUILD_ROOT}/%{python_sitearch}/hpmudext.la
%{__rm} -rf ${RPM_BUILD_ROOT}/%{python_sitearch}/pcardext.la
%{__rm} -rf ${RPM_BUILD_ROOT}/%{python_sitearch}/scanext.la
%{__rm} -rf ${RPM_BUILD_ROOT}/%{_libdir}/sane/libsane-hpaio.la
%{__rm} -rf ${RPM_BUILD_ROOT}/%{_sysconfdir}/sane.d

%clean
%__rm -rf ${RPM_BUILD_ROOT}


%post
/sbin/ldconfig

%post gui
/usr/bin/update-desktop-database &>/dev/null ||:

%postun gui
/usr/bin/update-desktop-database &>/dev/null ||:

%post -n libsane-hpaio
/sbin/ldconfig
if [ -f /etc/sane.d/dll.conf ] && \
   ! grep ^hpaio /etc/sane.d/dll.conf >/dev/null 2>/dev/null ; then \
        echo hpaio >> /etc/sane.d/dll.conf; \
fi

%files
%defattr(-,root,root)
%doc %{_datadir}/doc/%{name}-%{version}
%{_bindir}/hp-align
%{_bindir}/hp-check
%{_bindir}/hp-clean
%{_bindir}/hp-colorcal
%{_bindir}/hp-devicesetup
%{_bindir}/hp-fab
%{_bindir}/hp-faxsetup
%{_bindir}/hp-firmware
%{_bindir}/hp-info
%{_bindir}/hp-levels
%{_bindir}/hp-linefeedcal
%{_bindir}/hp-makecopies
%{_bindir}/hp-makeuri
%{_bindir}/hp-mkuri
%{_bindir}/hp-plugin
%{_bindir}/hp-pqdiag
%{_bindir}/hp-pkservice
%{_bindir}/hp-printsettings
%{_bindir}/hp-probe
%{_bindir}/hp-query
%{_bindir}/hp-scan
%{_bindir}/hp-sendfax
%{_bindir}/hp-setup
%{_bindir}/hp-systray
%{_bindir}/hp-testpage
%{_bindir}/hp-timedate
%{_bindir}/hp-unload
%{_datadir}/hal/fdi/preprobe/10osvendor/20-hplip-devices.fdi
%{_datadir}/hplip/__init__.py
%{_datadir}/hplip/align.py
%{_datadir}/hplip/base
%{_datadir}/hplip/check.py
%{_datadir}/hplip/clean.py
%{_datadir}/hplip/colorcal.py
%{_datadir}/hplip/copier
%{_datadir}/hplip/data/ldl
%{_datadir}/hplip/data/models
%{_datadir}/hplip/data/pcl
%{_datadir}/hplip/data/ps
%{_datadir}/hplip/devicesetup.py
%{_datadir}/hplip/fax
%{_datadir}/hplip/faxsetup.py
%{_datadir}/hplip/firmware.py
%{_datadir}/hplip/hpdio.py
%{_datadir}/hplip/hpssd.py
%{_datadir}/hplip/info.py
%{_datadir}/hplip/installer
%{_datadir}/hplip/levels.py
%{_datadir}/hplip/linefeedcal.py
%{_datadir}/hplip/makecopies.py
%{_datadir}/hplip/makeuri.py
%{_datadir}/hplip/pcard
%{_datadir}/hplip/pkservice.py
%{_datadir}/hplip/plugin.py
%{_datadir}/hplip/pqdiag.py
%{_datadir}/hplip/printsettings.py
%{_datadir}/hplip/prnt
%{_datadir}/hplip/probe.py
%{_datadir}/hplip/query.py
%{_datadir}/hplip/scan
%{_datadir}/hplip/testpage.py
%{_datadir}/hplip/timedate.py
%{_datadir}/hplip/unload.py
%{_datadir}/cups/model/foomatic/HP-Fax-hplip.ppd.gz
%{_datadir}/cups/model/foomatic/HP-Fax2-hplip.ppd.gz
%{_libdir}/cups/backend/hp
%{_libdir}/cups/backend/hpfax
%{_libdir}/cups/filter/hpcups
%config(noreplace) %{_sysconfdir}/hp/hplip.conf
%{_sysconfdir}/udev/rules.d/55-hpmud.rules
%{_sysconfdir}/udev/rules.d/56-hpmud_support.rules
%{_localstatedir}/lib/hp

%files libs
%defattr(-,root,root)
%{_libdir}/libhpip.so.*
%{_libdir}/libhpmud.so*
%{python_sitearch}/cupsext.so
%{python_sitearch}/hpmudext.so
%{python_sitearch}/pcardext.so
%{python_sitearch}/scanext.so

%files gui
%defattr(-,root,root)
%{_bindir}/hp-fab
%{_bindir}/hp-print
%{_bindir}/hp-scan
%{_bindir}/hp-sendfax
%{_bindir}/hp-setup
%{_bindir}/hp-toolbox
%{_datadir}/hplip/data/images
%{_datadir}/hplip/data/localization
%{_datadir}/hplip/fab.py
%{_datadir}/hplip/print.py
%{_datadir}/hplip/scan.py
%{_datadir}/hplip/sendfax.py
%{_datadir}/hplip/setup.py
%{_datadir}/hplip/systray.py
%{_datadir}/hplip/toolbox.py
%{_datadir}/hplip/ui
%{_datadir}/hplip/plugins
%{_datadir}/applications/hplip.desktop
%{_sysconfdir}/xdg/autostart/hplip-systray.desktop

%files -n libsane-hpaio
%defattr(-,root,root)
%{_libdir}/sane/libsane-hpaio*


%changelog
* Fri Jul 24 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 3.9.4b-3
- add Patch0 to require root privilege (via gksu) when adding printer
- add Requires: gksu

* Mon Jun 08 2009 Shu KONNO <owa@bg.wakwak.com> 3.9.4b-2
- added --with-cupsfilterdir to configure option
- use python_sitearch macro instead of python_platlib

* Sun Jun 07 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 3.9.4b-1
- new upstream release
- split libraries to -libs sub package
- update configure option
  add --enable-dbus-build, --enable-qt3, --disable-qt4

* Mon Jul 21 2008 Shu KONNO <owa@bg.wakwak.com> 2.7.12-1vl5
- rebuilt with python-2.5.2
- added python_platlib macro
- applied new versioning policy and spec in utf-8

* Sun Jan  6 2008 Shu KONNO <owa@bg.wakwak.com> 2.7.12-0vl2
- added --with-cupsbackenddir=%%{_libdir}/cups/backend to configure

* Thu Jan  3 2008 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 2.7.12-0vl1
- new upstream release
- build with net-snmp-5.4.1

* Thu Jun 28 2007 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 2.7.6-0vl1
- initial build for Vine Linux
