%bcond_with     cinepaint

Summary:	Utility for digital camera raw images
Summary(ja): 	デジタルカメラの RAW 画像ユーティリティ
Name:		ufraw
Version:	0.22
Release: 	2%{?_dist_release}

License:	GPLv2
Group:		Applications/Graphics
URL:		http://ufraw.sourceforge.net/

Source0:	%{name}-%{version}.tar.gz
# added Japanese comment
Source10:       %{name}.desktop

BuildRoot:	%{_tmppath}/%{name}-%{version}-root
BuildRequires:  cfitsio-devel
BuildRequires:  exiv2-devel
BuildRequires:  gimp-devel
BuildRequires:  glib2-devel >= 2.12
BuildRequires:	gtk2-devel >= 2.12
BuildRequires:  gtkimageview-devel >= 1.6.1
BuildRequires:	lcms2-devel
BuildRequires:  lensfun-devel >= 0.2.5
BuildRequires:	libexif-devel
BuildRequires:	libjpeg-devel
BuildRequires:  libpng-devel
BuildRequires:	libtiff-devel
BuildRequires:	perl
BuildRequires:	zlib-devel
%if %{with cinepaint}
BuildRequires: cinepaint-devel >= 0.22
%define cinepaintplugindir %(pkg-config --variable=programplugindir cinepaint-gtk)/plug-ins
%endif
Requires(post): GConf2, shared-mime-info, desktop-file-utils
Requires(postun): shared-mime-info, desktop-file-utils
Requires(pre): GConf2
Requires(preun): GConf2

%description
Application allowed to read and manipulate raw images from digital
cameras. Takes care of the color management, handles the Nikon curve
formats and has editor for the tone curves. It allows easy process more
images in a batch on command-line.

%description -l ja
デジタルカメラから RAW 画像を読み込み、操作するためのアプリケーション
です。カラーマネージメント機能を持ち、Nikon のカーブフォーマットの読み
込みやトーンカーブの編集が可能です。また大量のファイルをコマンドライン
から簡単にバッチ処理できます。

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

%package gimp
Summary:        Raw image loader plugin for The GIMP
Summary(ja):	GIMP 用の RAW 画像読み込みプラグイン
Group:		Applications/Graphics
Requires:       gimp

%description gimp
ufraw-gimp is a GIMP plug-in to read and manipulate raw images from 
digital cameras.

%description gimp -l ja
ufraw-gimp はデジタルカメラの RAW 画像を読み込み、操作するための GIMP プラグインです。

#---------------------------------------------------------------------------
%if %{with cinepaint}
%package cinepaint
Summary:        CinePaint plugin to retrieve raw image data from digital cameras
Group:          Applications/Multimedia
Requires:       ufraw = %{version}-%{release}
Requires:       cinepaint

%description cinepaint
The ufraw-cinepaint package contains a CinePaint plugin for opening raw format
images of digital cameras.
%endif
#---------------------------------------------------------------------------
	
%prep
%setup -q

cp -p %{SOURCE10} .

%build
%configure --enable-mime --enable-extras --with-gimp DESTDIR=$RPM_BUILD_ROOT
make schemasdir=%{_sysconfdir}/gconf/schemas

%install
rm -rf $RPM_BUILD_ROOT

make install DESTDIR=$RPM_BUILD_ROOT

# don't ship dcraw binary
rm -f $RPM_BUILD_ROOT%{_bindir}/dcraw

# install schemas to sysconfdir manually.
%{__install} -d $RPM_BUILD_ROOT%{_sysconfdir}/gconf/schemas
./generate_schemas.sh %{_prefix} $RPM_BUILD_ROOT%{_sysconfdir}/gconf/schemas/ufraw.schemas
mv $RPM_BUILD_ROOT%{_datadir}/gconf/schemas/ufraw.schemas $RPM_BUILD_ROOT%{_sysconfdir}/gconf/schemas
rm -rf $RPM_BUILD_ROOT%{_datadir}/gconf/schemas

# install mime-info manually. (But this has been included in shared-mime-info >= 0.21)
%{__install} -d $RPM_BUILD_ROOT%{_datadir}/mime/packages
%{__install} -m 644 ufraw-mime.xml $RPM_BUILD_ROOT%{_datadir}/mime/packages

%find_lang %{name}


%clean
%{__rm} -rf ${RPM_BUILD_ROOT}


%post
update-mime-database %{_datadir}/mime >& /dev/null ||:
export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/ufraw.schemas > /dev/null ||:
update-desktop-database %{_datadir}/applications >& /dev/null ||:

%pre
if [ "$1" -gt 1 ]; then
    export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
    gconftool-2 --makefile-uninstall-rule \
	%{_sysconfdir}/gconf/schemas/ufraw.schemas > /dev/null ||:
fi

%preun
if [ "$1" -eq 0 ]; then
    export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
    gconftool-2 --makefile-uninstall-rule \
	%{_sysconfdir}/gconf/schemas/ufraw.schemas > /dev/null ||:
fi

%postun
update-mime-database %{_datadir}/mime >& /dev/null ||:
update-desktop-database %{_datadir}/applications >& /dev/null ||:


%files -f %{name}.lang
%defattr(-,root,root)
%doc COPYING MANIFEST README TODO
%{_bindir}/ufraw
%{_bindir}/ufraw-batch
#{_bindir}/dcraw
%{_bindir}/nikon-curve
%{_sysconfdir}/gconf/schemas/ufraw.schemas
%{_datadir}/appdata/%{name}.appdata.xml
%{_datadir}/applications/ufraw.desktop
%{_datadir}/mime/packages/ufraw-mime.xml
%{_datadir}/pixmaps/ufraw.png
%{_mandir}/man1/ufraw.1*

%files gimp
%defattr(-,root,root)
%{_libdir}/gimp/2.0/plug-ins/ufraw-gimp

%if %{with cinepaint}
%files cinepaint
%defattr(-, root, root, -)
%{cinepaintplugindir}/ufraw-cinepaint
%endif

%changelog
* Sat Sep 03 2016 Toshiaki Ara <ara_t@384.jp> 0.22-2
- rebuild with gcc-5.4.0

* Mon Nov 09 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.22-1
- new upstream release

* Tue Mar 10 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 0.21-1
- updated to 0.21
- removed %{_bindir}/dcraw to avoid conflicting with dcraw package
- added BR: lensfun-devel
- added BR: lcms2-devel instead of lcms-devel

* Wed Feb 25 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 0.18-6
- rebuilt with cfitsio 3.370

* Wed Jan 14 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.18-5
- rebuild with libpng-1.6.12

* Wed Dec 11 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.18-4
- rebuild with exiv2-0.23

* Sun Jul 29 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.18-3
- rebuild with exiv2-0.23

* Mon May 07 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.18-2
- rebuild with exiv2-0.22

* Sun Jul 31 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.18-1
- new upstream release
- built with exiv2-0.21.1
- added BR: cfitsio-devel, libtiff-devel

* Wed May  5 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.17-1
- new upstream release
- built with exiv2-0.19

* Sun Apr 12 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.15-1
- new upstream release

* Sun Oct  5 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.13-1vl5
- new upstream release

* Thu Sep 25 2008 Shu KONNO <owa@bg.wakwak.com> 0.12.1-1vl5
- applied new versioning policy, spec in utf-8
- built with exiv2

* Fri Aug 17 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.12.1-0vl1
- new upstream release.
- add Requires(post, postun)

* Tue Aug 07 2007 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 0.12-0vl1
- new upstream release.
- add BuildRequires gtkimageview-devel >= 1.3.0

* Mon Jun 11 2007 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 0.11-0vl1
- initial build for Vine Linux
