%define ver 0.9
Summary: Enlightened terminal emulator
Summary(ja): Enlightened 端末エミュレータ
Name: Eterm
Version: %{ver}
Release: 1%{?_dist_release}
License: BSD
Group: User Interface/X
URL: http://www.eterm.org/
#Source0: ftp://ftp.eterm.org/pub/Eterm/Eterm-%{ver}.tar.gz
#Source1: ftp://ftp.eterm.org/pub/Eterm/Eterm-bg-%{ver}.tar.gz
Source0: http://www.eterm.org/download/Eterm-%{ver}.tar.gz
Source1: http://www.eterm.org/download/Eterm-bg-%{ver}.tar.gz
#patch for vine
Patch100: Eterm-0.9-compoundtext.patch
Patch101: Eterm-0.9-vinefont.patch
Patch102: Eterm-0.9-ja_nls.patch
Patch103: Eterm-0.9-mbwrap.patch
Patch200: Eterm-0.9-config.sub.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
Requires: xorg-x11-libs
Requires: imlib >= 1.9.6
Requires: libpng
Requires: libtiff
Requires: libungif
Requires: zlib
BuildRequires: xorg-x11-devel
BuildRequires: imlib-devel >= 1.9.6
BuildRequires: libpng-devel
BuildRequires: libtiff-devel
BuildRequires: libungif-devel
BuildRequires: zlib-devel
BuildRequires: desktop-file-utils

%description
Eterm is a color vt102 terminal emulator with enhanced graphical
capabilities.  Eterm is intended to be a replacement for xterm for
Enlightenment window manager users, but it can also be used as a
replacement for xterm by users without Enlightenment.  Eterm supports
various themes and is very configurable, in keeping with the
philosophy of Enlightenment. If you install Eterm, you'll also need to
have the Imlib library installed.

%description -l ja
Etermは先進的なグラフィカル機能を持ったvt102カラー端末エミュレータです。
Etermは、 Enlightenment ウィンドウマネージャ用に、xtermの代替を目的とし
ていますが、 Enlightenmentなしでも、 代替xtermとして利用することもでき
ます。Etermはさまざまなテーマをサポートしており、 Enlightenmentの哲学に
従って 自由に設定することができます。 Etermをインストールするなら、
Imlibライブラリもインストールする必要があります。

%package backgrounds
Summary: Backgrounds for Eterm
Summary(ja): Eterm用背景画像集
Group: User Interface/X
Requires: Eterm = %{ver}

%description backgrounds
Install this package if you want additional backgrounds for Eterm

%description backgrounds -l ja
Eterm用の追加背景画像が欲しい場合、これをインストールしてください。

%prep
%setup -q -n Eterm-%{ver} 1
%patch100 -p1 -b .compoundtext
%patch101 -p1 -b .vinefont
%patch102 -p1 -b .ja_nls
%patch103 -p1
%patch200 -p1 -b .config.sub

find . -type f -size 0 -print | xargs rm -f

%build
%configure \
	--target=%{_arch}-pc-linux-gnu \
	--enable-multi-charset \
	--enable-trans \
	--enable-xim \
	--without-sense-of-humor

make


%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications
cat > $RPM_BUILD_ROOT%{_datadir}/applications/Eterm.desktop <<EOF
[Desktop Entry]
Encoding=UTF-8
Name=Eterm
Name[ja]=Eterm 日本語端末
Comment=Enlightened Terminal
Comment[ja]=Enlightened 端末エミュレータ
TryExec=Eterm
Exec=Eterm
Icon=gnome-eterm
Terminal=false
Type=Application
Categories=Utility;TerminalEmulator;
EOF
chmod 0644 $RPM_BUILD_ROOT%{_datadir}/applications/Eterm.desktop
desktop-file-validate $RPM_BUILD_ROOT%{_datadir}/applications/Eterm.desktop

mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/X11/wmconfig/
cat > $RPM_BUILD_ROOT%{_sysconfdir}/X11/wmconfig/Eterm <<EOF
Eterm name "Eterm"
Eterm description "A featureful, themeable X11 terminal emulator."
Eterm exec "Eterm &"
Eterm group Utilities/Shells
EOF
chmod 0644 $RPM_BUILD_ROOT%{_sysconfdir}/X11/wmconfig/Eterm

%makeinstall

( cd $RPM_BUILD_ROOT
  mv .%{_bindir}/Eterm .%{_bindir}/Eterm-%{ver}
  cd $RPM_BUILD_ROOT%{_bindir}
  ln -sf Eterm-%{ver} Eterm
  cd $RPM_BUILD_ROOT
  chmod +x .%{_libdir}/lib*so* ||:
)

(cd $RPM_BUILD_ROOT%{_datadir}/Eterm/pix/ ; \
 for i in tiled-pixmaps.list scaled-pixmaps.list pixmaps.list ; do \
  mv $i $i.base ; done)

tar -zxvf %{SOURCE1}

make -C bg all
%makeinstall -C bg

#get the package listing for Eterm-backgrounds
echo "%defattr(-,root,root)" > rpm-Eterm-bg-files
cat > rpm-Eterm-bg-files <<EOF
%defattr(-,root,root)
%{_datadir}/Eterm/pix/tiled-pixmaps.list
%{_datadir}/Eterm/pix/scaled-pixmaps.list
%{_datadir}/Eterm/pix/pixmaps.list
EOF
find ./bg/ -type f -not -name '*.list' -not -name 'Makefile*' \
       -not -name 'README*' -not -name 014.jpg \
        -not -name 40.jpg -not -name blackstone.jpg -not -name backwave.jpg \
        -not -name circuit.jpg -not -name nebula.jpg \
        -not -name fourthday.jpg -not -name gaia.jpg \
        -not -name galleon.jpg -not -name night_of_the_dragon.jpg \
        | sed "s#^\./bg/[scati]*le#%{_datadir}/Eterm/pix#g" >> rpm-Eterm-bg-files

# remove *.la files
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la


%post
/sbin/ldconfig
update-desktop-database %{_datadir}/applications

(cd %{_datadir}/Eterm/pix;
if [ -f tiled-pixmaps.list.base ] ; then
	for i in tiled-pixmaps.list scaled-pixmaps.list pixmaps.list; do mv -f $i.base $i ; done
else
  exit 0
fi
)


%preun
for i in tiled-pixmaps.list scaled-pixmaps.list pixmaps.list ; do \
  rm -f %{_datadir}/Eterm/pix/$i* ; done

%postun
/sbin/ldconfig
update-desktop-database %{_datadir}/applications


%pre backgrounds
for i in tiled-pixmaps.list scaled-pixmaps.list pixmaps.list ; do \
    mv -f %{_datadir}/Eterm/pix/$i %{_datadir}/Eterm/pix/$i.base; done

%preun backgrounds
for i in tiled-pixmaps.list scaled-pixmaps.list pixmaps.list ; do \
    mv -f %{_datadir}/Eterm/pix/$i.base %{_datadir}/Eterm/pix/$i ; done

%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root)
%doc doc/Eterm_reference.html doc/Eterm.1.html
%doc COPYING README ChangeLog
%config %{_sysconfdir}/X11/wmconfig/Eterm
%config(missingok) %{_datadir}/Eterm/pix/*.list.base
%config %{_datadir}/applications/Eterm.desktop
%{_bindir}/*
%{_libdir}/*.so
%{_libdir}/*.a
%{_mandir}/man1/*
%dir %{_datadir}/Eterm
%{_datadir}/Eterm/themes
%dir %{_datadir}/Eterm/pix
%{_datadir}/Eterm/pix/014.jpg
%{_datadir}/Eterm/pix/40.jpg
%{_datadir}/Eterm/pix/blackstone.jpg
%{_datadir}/Eterm/pix/backwave.jpg
%{_datadir}/Eterm/pix/circuit.jpg
%{_datadir}/Eterm/pix/nebula.jpg
%{_datadir}/Eterm/pix/fourthday.jpg
%{_datadir}/Eterm/pix/gaia.jpg
%{_datadir}/Eterm/pix/galleon.jpg
%{_datadir}/Eterm/pix/night_of_the_dragon.jpg
%{_datadir}/Eterm/pix/bar_horizontal_[123].png
%{_datadir}/Eterm/pix/bar_vertical_[123].png
%{_datadir}/Eterm/pix/button_arrow_up_[123].png
%{_datadir}/Eterm/pix/button_arrow_down_[123].png
%{_datadir}/Eterm/pix/menu[123].png

%files backgrounds -f rpm-Eterm-bg-files


%changelog
* Sat Aug 16 2008 Shu KONNO <owa@bg.wakwak.com> 0.9-1vl5
- applied new versioning policy and spec in utf-8
- added BuildRequires: xorg-x11-devel desktop-file-utils
- removed %{_libdir}/*.la in %%files
- moved Eterm.desktop to %%{_datadir}/applications/

* Sat Sep 01 2007 Shu KONNO <owa@bg.wakwak.com> 0.9-0vl8
- added Patch200: Eterm-0.9-config.sub.patch

* Thu Oct  7 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.9-0vl7
- fixed Requires: and BuildRequires:
- fixed post and pre scriptlet
- added /etc/X11/applnk/Utilities/Eterm.desktop

* Thu Sep 30 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.9-0vl6
- rebuild with new toolchains
- s/Copyright/License/

* Fri Nov 30 2001 MATUBARA Kazuyuki <matubara@mb.asmnet.ne.jp> 0.9-0vl5
- fixed a bug of multi byte character wrap
  used rpm macros

* Tue Jul 11 2000 Yasuyuki Furukawa <furukawa@vinelinux.org>
- added ja_nls patch for menu.

* Tue Feb 15 2000 Yasuyuki Furukawa <furukawa@vinelinux.org>
- modify compoundtext patch to fix a bug to write CUT_BUEFFER without COMPOUND_TEXT.

* Sat Jan 29 2000 Yasuyuki Furukawa <furukawa@vinelinux.org>
- making noarch rpm for Eterm-backgrounds
- added vinefont and compoundtext patches

* Fri Dec 10 1999 Michael Jennings <mej@eterm.org>
- Added Tim's spec file to CVS as Eterm.spec.in for 0.9

* Wed Dec 8 1999 Tim Powers <timp@redhat.com>
- using unified patch for utempter and themes from Michael Jennings

* Tue Dec 7 1999 Tim Powers <timp@redhat.com>
- added wmconfig entry
- split up into 2 packages, Eterm proper, and Eterm-backgrounds
- thanks to ewt, we no longer have to make Eterm suid root, uses utempter
        instead

* Mon Dec 6 1999 Tim Powers <timp@redhat.com>
- updated to 0.8.10
- patched so that Eterm finds pix/themes in the right place
- new version fixes problems with utmp, conforms to Eterm docs.
- added RedHat.Eterm_suid which includes instructions on how to run Eterm in
        order to have it seen by "w" and "who" as a regular user

* Fri Aug 20 1999 Tim Powers <timp@redhat.com>
- fixed roblem with removing all files when uninstalling Eterm.

* Tue Jul 27 1999 Tim Powers <timp@redhat.com>
- updated version to 0.8.9
- cleaned up spec
- updated patch
- includes new backgrounds
- built for 6.1

* Mon Apr 05 1999 Michael Maher <mike@redhat.com>
- update to 0.8.8

* Fri Oct 23 1998 Jeff Johnson <jbj@redhat.com>
- update to 0.8.7.

* Fri Oct 08 1998 Michael Maher <mike@redhat.com>
- built eterm