# Browser plugin doesn't work with stripped binaries/libs
%define         debug_package %{nil}

Name:           acrobat-reader
Version:        5.0.8
Release:        0.fdr.1
Epoch:          0
ExclusiveArch:	i386
Summary:        Adobe Acrobat Reader.
Group:         	Applications/Publishing
License:        Commercial
URL:            http://www.adobe.com
Source0:        ftp://ftp.adobe.com/pub/adobe/acrobatreader/unix/5.x/linux-508.tar.gz
Source1:	acroread.desktop
Source2:	acroread.png
Patch1:		acroread-lang.patch
Patch2:		acroread-appdefaults.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires:       XFree86
BuildRequires:	sed

%description
Adobe Acrobat Reader.

%package 	plugin
Summary:	Acrobat Reader browser plugin.
Group:		Applications/Internet
Requires:	%{name} = %{epoch}:%{version}-%{release}

%description	plugin
Acrobat Reader browser plugin. Works with Mozilla and derivates,
as well as Netscape and Konqueror.

%prep
%setup -c -q 

%build

%install
rm -rf $RPM_BUILD_ROOT

# The guts
mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{name}
tar -C $RPM_BUILD_ROOT%{_libdir}/%{name} -xf COMMON.TAR
tar -C $RPM_BUILD_ROOT%{_libdir}/%{name} -xf LINUXRDR.TAR

# Startup script
mkdir -p $RPM_BUILD_ROOT%{_bindir}
# Insert installation dir into startup script and
# add workaround for missing UTF-8 support
sed 's/REPLACE_ME/\%{_prefix}\/lib\/%{name}\/Reader\nLANG=C/g' < \
	$RPM_BUILD_ROOT%{_libdir}/%{name}/bin/acroread.sh \
	> $RPM_BUILD_ROOT%{_bindir}/acroread
# Make executable
chmod 755 $RPM_BUILD_ROOT%{_bindir}/acroread 

# Patch Xresources to make it look a little better and
# fix version string in window title
patch -p0 $RPM_BUILD_ROOT%{_libdir}/%{name}/Reader/intellinux/app-defaults/AcroRead < %{PATCH2}

# Install browser plugin
mkdir -p $RPM_BUILD_ROOT%{_libdir}/mozilla/plugins
install -m755 $RPM_BUILD_ROOT%{_libdir}/%{name}/Browsers/intellinux/nppdf.so \
	$RPM_BUILD_ROOT%{_libdir}/mozilla/plugins

# Move documentation
mv $RPM_BUILD_ROOT%{_libdir}/%{name}/Reader/license.txt .
mv $RPM_BUILD_ROOT%{_libdir}/%{name}/Resource/LICFONT.TXT .

# Clean up unused files
rm -fr $RPM_BUILD_ROOT%{_libdir}/%{name}/bin 
rm -fr $RPM_BUILD_ROOT%{_libdir}/%{name}/Browsers
rm -fr $RPM_BUILD_ROOT%{_infodir}/dir

# Desktop file
mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications
desktop-file-install --vendor fedora \
        --dir $RPM_BUILD_ROOT/%{_datadir}/applications  \
        --add-category X-Fedora                     \
        --add-category Application                  \
	--add-category Graphics \
	%{SOURCE1}

# Icon
mkdir -p $RPM_BUILD_ROOT%{_datadir}/pixmaps
install -m644 %{SOURCE2} $RPM_BUILD_ROOT%{_datadir}/pixmaps

# Fix permissions. FIXME: Is this really needed?
find $RPM_BUILD_ROOT%{_libdir}/%{name} -type d -exec chmod 755 {} \;
find $RPM_BUILD_ROOT%{_libdir}/%{name} -name "*.so.*" -exec chmod 755 {} \;

%clean
rm -rf $RPM_BUILD_ROOT

%files 
%defattr(-,root,root,-)
%doc README license.txt LICFONT.TXT
%{_bindir}/*
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/*
%{_datadir}/applications/*
%{_datadir}/pixmaps/*

%files plugin
%defattr(-,root,root,-)
%{_libdir}/mozilla/plugins/*

%changelog
* Fri May 03 2003 Your Name <you[AT]your.domain> - epoch:version-release
- Initial RPM release.
