%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%global	python_module_name cdemu

Summary: A simple command-line client to control CDEmu daemon
Summary(ja): CDEmu デーモンを制御するシンプルなコマンドラインクライアント
Name: cdemu-client
Version: 3.1.0
Release: 1%{?_dist_release}
License: GPLv2+
Group: Applications/Accessories
URL: http://cdemu.sourceforge.net
Source: http://downloads.sourceforge.net/cdemu/%{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildArch: noarch

BuildRequires: cmake >= 2.8.5
BuildRequires: gettext >= 0.15
BuildRequires: intltool >= 0.21
BuildRequires: desktop-file-utils

%description
This is cdemu-client, a simple command-line client for controlling CDEmu daemon.
It is part of the userspace-cdemu suite, a free, GPL CD/DVD-ROM device emulator 
for linux.

It provides a way to perform the key tasks related to controlling the CDEmu
daemon, such as loading and unloading devices, displaying devices' status and
retrieving/setting devices' debug masks.

%prep
%setup -q

%build
%cmake \
  -DPOST_INSTALL_HOOKS=OFF \
  .
%{__make} %{?_smp_mflags}

%install
%{__rm} -rf %{buildroot}

%{__mkdir_p} %{buildroot}%{_bindir}
%{__install} -m0755 src/cdemu %{buildroot}%{_bindir}

%{__mkdir_p} %{buildroot}%{_mandir}/man1
%{__install} -m0644 man/cdemu.1 %{buildroot}%{_mandir}/man1

%{__mkdir_p} %{buildroot}%{_sysconfdir}/bash_completion.d
%{__install} -m0644 data/cdemu-bash-completion.sh %{buildroot}%{_sysconfdir}/bash_completion.d

%{__mkdir_p} %{buildroot}%{_datadir}/pixmaps
%{__install} -m0644 data/cdemu-client.svg %{buildroot}%{_datadir}/pixmaps

%{__mkdir_p} %{buildroot}/%{_datadir}/applications
%{_bindir}/desktop-file-install --dir=%{buildroot}/%{_datadir}/applications %{name}.desktop

LANG_FILES=$(find . -maxdepth 1 -type f -name "*.gmo" | cut -d"/" -f2 | cut -d"." -f1)
langs=`echo $LANG_FILES`

for lang in ${langs[@]};do
   %{__mkdir_p} %{buildroot}%{_localedir}/${lang}/LC_MESSAGES
   %{__install} -m0644 ${lang}.gmo %{buildroot}%{_localedir}/${lang}/LC_MESSAGES/cdemu.mo
done

%find_lang cdemu

%check
%{_bindir}/desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}.desktop

%clean
%{__rm} -rf %{buildroot}

%post
if [ -x %{_bindir}/update-desktop-database ] ; then
%{_bindir}/update-desktop-database %{_datadir}/applications
fi

%postun
if [ -x %{_bindir}/update-desktop-database ] ; then
%{_bindir}/update-desktop-database %{_datadir}/applications
fi

%files -f cdemu.lang
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
%config(noreplace) %{_sysconfdir}/bash_completion.d/cdemu-bash-completion.sh
%{_bindir}/*
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/%{name}.svg
%{_mandir}/man1/*


%changelog
* Tue Jan 23 2018 IWAI, Masaharu <iwaim.sub@gmail.com> - 3.1.0-1
- update to 3.1.0

* Sat Feb 25 2017 IWAI, Masaharu <iwaim.sub@gmail.com> - 3.0.3-1
- update to 3.0.3
- update BuildRequires
- add post and postun scripts

* Sat May 05 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> - 1.5.0-1
- new upstream release
- changed atchive type gzip to bzip2
- dropt BuildRequires: python-devel

* Sat Dec 24 2011 Toshiharu Kudoh <toshi.kd2@gmail.com> - 1.4.0-1
- new upstream release

* Thu Sep 2 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 1.3.0-1
- new upstream release

* Sat Sep 26 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> - 1.2.0-1
- initial build for VineSeed

* Sat Jun 28 2008 Rok Mandeljc <rok.mandeljc@email.si> - 1.1.0-1
- Updated to 1.1.0

* Thu Dec 20 2007 Rok Mandeljc <rok.mandeljc@email.si> - 1.0.0-1
- Initial RPM release.
