%define build_vine4 0
%if "%{?_dist_release}" == "vl4"
%define build_vine4 1
%endif

Summary: A GUI interface to write image files to USB Keys
Summary(ja): USBメモリにイメージファイルを書き込むためのGUIツール
Name: usb-imagewriter
Version: 0.1.3
Release: 3%{?_dist_release}
License: GPLv2
Group: Applications/System
URL: http://launchpad.net/usb-imagewriter

Source0: usb-imagewriter_0.1.3.orig.tar.gz
Source10: header-vine.png
Source11: usb-imagewriter-0.1.3-ja.po
Patch0: usb-imagewriter-0.1.3-support-removable.patch
Patch1: usb-imagewriter-0.1.3-ja.patch
Patch2: usb-imagewriter-0.1.3-gksu.patch
Patch3: usb-imagewriter-0.1.3-vine4.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: noarch
BuildRequires: desktop-file-utils

%description
A GUI tool to write image(.img) files to USB Keys.

%description -l ja
USBメモリにイメージファイル(.img)を書き込むためのGUIツールです。

%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%if %{build_vine4}
%patch3 -p1
%endif

cp -f %{SOURCE10} share/usb-imagewriter/header.png
cp -f %{SOURCE11} po/ja.po

%build
pushd po
./update_translations.sh
popd

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_prefix}/lib/imagewriter
mkdir -p %{buildroot}%{_datadir}/{applications,imagewriter}
install -m755 imagewriter %{buildroot}%{_bindir}
install -m644 share/applications/* %{buildroot}%{_datadir}/applications
install -m644 share/usb-imagewriter/* %{buildroot}%{_datadir}/imagewriter/
install -m755 lib/* %{buildroot}%{_prefix}/lib/imagewriter/

for l in ja de
do 
  mkdir -p %{buildroot}%{_datadir}/locale/${l}/LC_MESSAGES/
  install -m644 po/${l}/LC_MESSAGES/usb-imagewriter.mo \
                %{buildroot}%{_datadir}/locale/${l}/LC_MESSAGES/
done

desktop-file-install \
      --vendor="" --delete-original \
      --dir=%{buildroot}%{_datadir}/applications \
      --remove-category="Utility" \
      --add-category="System" \
      %{buildroot}%{_datadir}/applications/imagewriter.desktop

%find_lang %{name}

%clean
rm -rf $RPM_BUILD_ROOT

%files -f %{name}.lang
%defattr(-, root, root)
%doc COPYING
%{_bindir}/*
%{_datadir}/imagewriter
%{_datadir}/applications/*.desktop
%{_prefix}/lib/imagewriter


%changelog
* Sat Mar 24 2012 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.1.3-3
- rebuild

* Sun Aug 16 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.1.3-2
- add Patch3 for Vine Linux 4.x
- change BuildArch to noarch
- remove unneeded BR:

* Fri May 08 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.1.3-1
- initial build for Vine Linux

