%define with_my_japo 0

%define _kde4_bindir		%{_bindir}
%define _kde4_iconsdir 		%{_datadir}/icons
%define _kde4_datadir		%{_datadir}
%define _kde4_docdir		%{_datadir}/doc
%define _kde4_appsdir		%{_datadir}/kde4/apps

%define _qt4_qmake		%{_libdir}/qt4/bin/qmake

Name:    k9copy
Version: 2.3.8
Release: 1%{?_dist_release}
Summary: Video DVD backup and creation program
Summary(ja): ビデオDVDバックアップと作成プログラム
Group:   Applications/Multimedia
License: GPLv2+
URL:     http://k9copy.sourceforge.net/
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}-Source.tar.gz

## vine
%if %{with_my_japo}
Source100:      k9copy-2.3.5-ja.po
%endif

BuildRoot: %{_tmppath}/%{name}-%{version}-root

# upstreamable patches
#Patch51: k9copy-2.3.5-dso.patch
#Patch52: k9copy-2.3.5-mimetype.patch

BuildRequires: qt4-devel
BuildRequires: cmake
BuildRequires: desktop-file-utils
##BuildRequires: ffmpeg-devel
BuildRequires: gettext
BuildRequires: hal-devel
BuildRequires: kdelibs4-devel >= 4.4.3
BuildRequires: libdvdread-devel
##BuildRequires: libmpeg2-devel
BuildRequires: pkgconfig
BuildRequires: xine-lib-devel

Requires: dvd+rw-tools
Requires: dvdauthor
Requires: kdebase-runtime >= 4.4.3

### Optional, not *strictly* required:
##Requires(hint): mencoder
##Requires(hint): mplayer

# Vine
# BuildRequires: self-build-ffmpeg
# BuildRequires: self-build-libmpeg2
# Requires:      self-build-mplayer

Obsoletes:     self-build-k9copy < 2.0.0
Obsoletes:     k9copy < 2.0.0

%description
Video DVD backup and creation program, features include:
* Video stream compression for fit onto a single layer 4.7GB DVD
* DVD Burning
* Creation of ISO images
* Audio tracks and subtitle selection
* Video title preview
* Preservation of the original menus

%description -l ja
ビデオDVDバックアップと作成プログラム。
特徴は：
* 片面一層4.7GB DVDへ収めるためのビデオストリーム圧縮
* DVD書き込み
* ISOイメージの作成
* オーディオトラックとサブタイトル選択
* ビデオタイトルプレビュー
* オリジナルのメニューの保存


%prep
%setup -q  -n %{name}-%{version}-Source

#%patch51 -p1 -b .dso
#%patch52 -p1 -b .mimetype

# fixed *.desktop files
for x in *.desktop; do %__sed -i "s,^MimeTypes=,MimeType=," $x; done

%if %{with_my_japo}
## vine
%__install -m644 %{SOURCE100} po/ja.po
%endif


%build
%__mkdir -p %{_target_platform}
pushd %{_target_platform}
#unset QTDIR || : ; . /etc/profile.d/qt4.sh
%__cmake \
    -DCMAKE_BUILD_TYPE=release \
    -DCMAKE_INSTALL_PREFIX=%{_prefix} \
    -DDATA_INSTALL_DIR:PATH=%{_datadir}/kde4/apps \
    -DINCLUDE_INSTALL_DIR:PATH=%{_includedir}/kde4 \
    -DLIB_INSTALL_DIR:PATH=%{_libdir} \
    -DLIBEXEC_INSTALL_DIR:PATH=%{_libexecdir}/kde4 \
    -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \
    -DQT_QMAKE_EXECUTABLE=%_qt4_qmake \
    -DAVCODEC_INCLUDE_DIR=$(pkg-config libavcodec --variable=includedir) \
    -DAVFORMAT_INCLUDE_DIR=$(pkg-config libavformat --variable=includedir) \
    -DFFMPEGSCALE_INCLUDE_DIR=$(pkg-config libswscale --variable=includedir) \
    ..
popd

%__make %{?_smp_mflags} -C %{_target_platform}


%install
%__rm -rf %{buildroot}

%__make install/fast DESTDIR=%{buildroot} -C %{_target_platform}

%find_lang %{name}


%check
desktop-file-validate %{buildroot}%{_kde4_datadir}/applications/kde4/k9copy.desktop
desktop-file-validate %{buildroot}%{_kde4_datadir}/applications/kde4/k9copy_assistant.desktop


%clean
%__rm -rf %{buildroot}


%post
touch --no-create %{_kde4_iconsdir}/hicolor &> /dev/null ||:

%posttrans
gtk-update-icon-cache %{_kde4_iconsdir}/hicolor &> /dev/null ||:

%postun
if [ $1 -eq 0 ] ; then
  touch --no-create %{_kde4_iconsdir}/hicolor &> /dev/null ||:
  gtk-update-icon-cache %{_kde4_iconsdir}/hicolor &> /dev/null ||:
fi


%files -f %{name}.lang
%defattr(-,root,root,-)
%doc COPYING
%{_kde4_bindir}/k9copy
%{_kde4_bindir}/k9play
%{_kde4_bindir}/k9xineplayer
%{_kde4_appsdir}/k9copy/
%{_kde4_appsdir}/solid/actions/*.desktop
%{_kde4_datadir}/applications/kde4/k9copy.desktop
%{_kde4_datadir}/applications/kde4/k9copy_assistant.desktop
%{_kde4_docdir}/HTML/en/k9copy/
%{_kde4_iconsdir}/hicolor/*/*/*


%changelog
* Tue Apr  3 2012 Munehiro Yamamoto <munepi@vinelinux.org> 2.3.8-1
- new upstream release
- dropped upstreamed/unused patches

* Sun May 08 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2.3.7-1
- new upstream release

* Sat Aug 21 2010 Munehiro Yamamoto <munepi@vinelinux.org> 2.3.6-1
- new upstream release

* Sat Jul 10 2010 Munehiro Yamamoto <munepi@vinelinux.org> 2.3.5-1
- new upstream release
- added Requires: kdebase-runtime
- added k9copy-2.3.5-ja.po

* Mon Apr 19 2010 Munehiro Yamamoto <munepi@vinelinux.org> 2.3.4-1
- built based on RPM Fusion development

* Wed Dec 23 2009 Rex Dieter <rdieter@fedoraproject.org> 2.3.4-1
- k9copy-2.3.4

* Sat Aug 29 2009 Rex Dieter <rdieter@fedoraproject.org> 2.3.3-1
- k9copy-2.3.3

* Wed May 27 2009 Rex Dieter <rdieter@fedoraproject.org> 2.3.2-1
- k9copy-2.3.2

* Mon Apr 06 2009 Rex Dieter <rdieter@fedoraproject.org> 2.3.1-1
- k9copy-2.3.1
- optimize scriptlets

* Sun Mar 29 2009 Thorsten Leemhuis <fedora [AT] leemhuis [DOT] info> - 2.3.0-2
- rebuild for new F11 features

* Thu Mar 12 2009 Rex Dieter <rdieter@fedoraproject.org> 2.3.0-1
- k9copy-2.3.0

* Fri Feb 20 2009 Rex Dieter <rdieter@fedoraproject.org> 2.2.0-1
- k9copy-2.2.0

* Thu Oct 30 2008 Rex Dieter <rdieter@fedoraproject.org> 2.1.0-2
- ExcludeArch: ppc ppc64 (still fails)

* Thu Oct 30 2008 Rex Dieter <rdieter@fedoraproject.org> 2.1.0-1
- k9copy-2.1.0

* Fri Sep 19 2008 Rex Dieter <rdieter@fedoraproject.org> 2.0.2-4
- drop Requires: libdvdcss

* Thu Sep 18 2008 Rex Dieter <rdieter@fedoraproject.org> 2.0.2-3
- use pkg-config to query ffmpeg includedir(s)

* Tue Sep 16 2008 Rex Dieter <rdieter@fedoraproject.org> 2.0.2-2
- ffmpeg patch 

* Mon Jun 16 2008 Rex Dieter <rdieter@fedoraproject.org> 2.0.2-1
- k9copy-2.0.2

* Sat Jun 14 2008 Rex Dieter <rdieter@fedoraproject.org> 2.0.1-1
- k9copy-2.0.1

* Fri Jun 06 2008 Rex Dieter <rdieter@fedoraproject.org> 2.0.0-5
- gcc43 patch (forward port malloc patch from fedoraforum)

* Fri Jun 06 2008 Rex Dieter <rdieter@fedoraproject.org> 2.0.0-4
- License: GPLv2+ , %%doc COPYING
- minor libdvdread dl'ing patch

* Tue Jun 03 2008 Rex Dieter <rdieter@fedoraproject.org> 2.0.0-3
- ExcludeArch: ppc ppc64

* Tue Jun 03 2008 Rex Dieter <rdieter@fedoraproject.org> 2.0.0-2
- use %%find_lang
- use %%_kde4_* macros

* Mon Jun 02 2008 Leigh Scott <leigh123linux@googlemail.com> 2.0.0-1
- bump to 2.0.0 release 

* Sun Jan 06 2008 Ian Chapman <packages[AT]amiga-hardware.com> 1.2.2-1
- Upgrade to 1.2.2
- Added patch to fix buffer overflows (Thanks to Gustavo Maciel Dias Vieira)

* Mon Nov 12 2007 Ian Chapman <packages[AT]amiga-hardware.com> 1.2.0-1
- Upgrade to 1.2.0

* Tue Oct 23 2007 Rex Dieter <rdieter[AT]fedoraproject.org> 1.1.3-2
- d-f-i: s/Mimetypes/MimeTypes/ typo

* Tue Oct 23 2007 Rex Dieter <rdieter[AT]fedoraproject.org> 1.1.3-1
- k9copy-1.1.3

* Sun Jul 08 2007 Ian Chapman <packages[AT]amiga-hardware.com> 1.1.1-2.rerel3
- Various minor fixes to the spec file
- Changed release to work around upstreams 'odd' suffix
- Use desktop-file-install for the desktop file

* Tue Jun 05 2007 Ian Chapman <packages[AT]amiga-hardware.com> 1.1.1-1
- Initial release
