# Option: Freetype Patch (FC3+)
%define freetype_fc3 1

%define desktop_file_utils_version 0.9

ExclusiveArch: i386 x86_64 ia64 ppc s390 s390x

Summary: Web Authoring System
Name: nvu
Version: 1.0
Release: 1asp
Epoch: 0
URL: http://nvu.com/
License: MPL/LGPL/GPL
Group: Applications/Internet
Source0: nvu-%{version}-sources.tar.bz2
Source1: %{name}_icons.tar
Source2: nvu.sh.in
Source10: mozconfig-nvu
Source20: nvu-ru-RU.jar
Source100: find-external-requires
Source101: ru_RU.tar.bz2
Source102: installed-chrome-ru.txt
Source103: mozilla-nvu.desktop

# build patches
Patch1:         firefox-0.7.3-freetype-compile.patch
Patch2:         firefox-1.0-prdtoa.patch
#Patch3:		nvu-0.70-domainfix.patch

# customization patches
Patch21:        firefox-0.7.3-default-plugin-less-annoying.patch
Patch22:        firefox-0.7.3-psfonts.patch

# local bugfixes
Patch40:        firefox-PR1-gnome-vfs-default-app.patch
Patch41:        firefox-PR1-stack-direction.patch

# backported patches
Patch90:        firefox-PR1-gtk-file-chooser-morefixes.patch

# official upstream patches
Patch101:       firefox-PR1-pkgconfig.patch
Patch102:       mozilla-1.7.3-xptcall-s390.patch
Patch103:       firefox-1.0-xptcall-s390.patch
Patch104:       firefox-1.0-nspr-s390.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: libpng-devel, libjpeg-devel
BuildRequires: zlib-devel, zip
BuildRequires: libIDL-devel
BuildRequires: desktop-file-utils
BuildRequires: gtk2-devel, gnome-vfs2-devel
BuildRequires: krb5-devel
BuildRequires: autoconf213
BuildRequires: xorg-x11-deprecated-libs-devel
BuildRequires: curl-devel
%if %{freetype_fc3}
BuildRequires:  freetype-devel >= 2.1.9
%else
BuildRequires:  freetype-devel
%endif

Requires:       desktop-file-utils >= %{desktop_file_utils_version}
Requires:	gtk2 >= 2.6.0

%define nvudir %{_libdir}/nvu-%{version}

AutoProv: 0
%define _use_internal_dependency_generator 0
%define __find_requires %{SOURCE100}

%description
Nvu (pronounced N-view, for a "new view") is a complete Web Authoring
System that combines web file management and easy-to-use WYSIWYG (What
You See Is What You Get) web page editing.  Nvu is designed to be
extremely easy to use, making it ideal for non-technical computer users
who want to create an attractive, professional-looking web site without
needing to know HTML or web coding.

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

%prep
%setup -q -n mozilla
%if %{freetype_fc3}
%patch1 -p0
%endif
#%patch3 -p0
%patch21 -p1
%patch40 -p1
%patch41 -p0
%patch90 -p0
%patch101 -p0
%patch102 -p0
%patch103 -p1
%patch104 -p0

%{__rm} -f .mozconfig
%{__cp} %{SOURCE10} .mozconfig


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

%build
autoconf-2.13

export RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS | sed s/-O2/-Os/`
export MOZILLA_OFFICIAL=1
export BUILD_OFFICIAL=1
MAKE="gmake %{?_smp_mflags}" make -f client.mk build

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

%install
%{__rm} -rf $RPM_BUILD_ROOT


mkdir -p $RPM_BUILD_ROOT{%{_libdir}/%{name}-%{version},%{_bindir},%{_datadir}/applications}
cp -r -L dist/bin/* $RPM_BUILD_ROOT/%{_libdir}/%{name}-%{version}

tar -xf %{SOURCE1} -C $RPM_BUILD_ROOT

desktop-file-install \
  --vendor mozilla \
  --dir $RPM_BUILD_ROOT%{_datadir}/applications \
  %{SOURCE103}

# set up the firefox start script
%{__cat} %{SOURCE2} | %{__sed} -e 's,NVUDIR,%{nvudir},g' -e 's,LIBDIR,%{_libdir},g' > \
  $RPM_BUILD_ROOT%{_bindir}/nvu
%{__chmod} 755 $RPM_BUILD_ROOT%{_bindir}/nvu

%{__chmod} 755 $RPM_BUILD_ROOT%{_libdir}/%{name}-%{version}/%{name}
%{__chmod} 755 $RPM_BUILD_ROOT%{_libdir}/%{name}-%{version}/%{name}-bin

%{__cp} %{SOURCE20} $RPM_BUILD_ROOT%{nvudir}/chrome/ru-RU.jar

cat %{SOURCE102} >> $RPM_BUILD_ROOT%{nvudir}/chrome/installed-chrome.txt

#cd %{buildroot}%{nvudir}/components/myspell/
#ln -s /usr/lib/ooo-1.1/share/dict/ooo/ru_RU.aff
#ln -s /usr/lib/ooo-1.1/share/dict/ooo/ru_RU.dic
tar xvfj %{SOURCE101} -C %{buildroot}%{nvudir}/components/myspell/

cd %{buildroot}%{nvudir}
export MOZ_DISABLE_GNOME=1
./nvu -register


%files
%defattr(-,root,root,-)
%{_bindir}/%{name}
%{_datadir}/applications/mozilla-%{name}.desktop
%{_datadir}/icons/*
%{_libdir}/%{name}-%{version}


%clean
/bin/rm -rf $RPM_BUILD_ROOT

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

# create extensions directory
%{nvudir}/nvu -register

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

%preun
# is it a final removal?
if [ $1 -eq 0 ]; then
  %{__rm} -rf %{nvudir}/chrome/overlayinfo
  %{__rm} -rf %{nvudir}/components
  %{__rm} -f  %{nvudir}/chrome/*.rdf
  %{__rm} -rf %{nvudir}/extensions
  %{__rm} -f %{nvudir}/components.ini
fi

%changelog
* Sat Jul  9 2005 Arkady L. Shane <shejn@msiu.ru> 1.0-1asp
- 1.0

* Mon Mar 28 2005 Arkady L. Shane <shejn@msiu.ru> 0.90-1asp
- fiexd .desktop icons

* Thu Mar 24 2005 Leonid Kanter <leon@asplinux.ru> 0.90-0.10.0asp
- spec cleanup, rebuilt for asplinux 10

* Fri Feb 11 2005 DenV <denissio@gmail.com> - 0.81-0.fc3
- Update to 0.81

* Sat Feb 05 2005 DenV <denissio@gmail.com> - 0.80-1.fc3
- Update to 0.80 russian tranlsation

* Wed Feb 02 2005 DenV <denissio@gmail.com> - 0.80-0.fc3
- Update to 0.80
- Update rusian translation to 0.80RC2

* Tue Jan 25 2005 DenV <den@nekto.com>
- Build nvu based on firefox spec-file
- Add russian interface
