File opensuse-kde3user_en.spec of Package opensuse-kde3user_en

#
# spec file for package opensuse-kde3user_en (Version 11.1)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild


Name:           opensuse-kde3user_en
%define my_lang en
%define my_book opensuse-kdeuser
Version:        11.1
Release:        1
Provides:       locale(kde3base-session:en)
#OBS
Source0:        opensuse-kdeuser_en-html.tar.bz2
Source1:        opensuse-kdeuser_en-desktop.tar.bz2
Source2:        opensuse-kdeuser_en.pdf
Source3:        opensuse-kdeuser_en-graphics.tar.bz2
Source4:        opensuse-kdeuser_en.tar.bz2
Source5:        LICENSE.txt
#SOURCES
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
BuildRequires:  update-desktop-files
Group:          Documentation/SUSE
License:        GNU Free Documentation License, Version 1.2 (GFDL 1.2)
Summary:        openSUSE KDE3 User Guide (English)
%define _defaultdocdir %{_datadir}/doc/manual
%define _docdir %{_datadir}/doc/manual
%define PDFDOC %{_defaultdocdir}/%{name}-pdf

%description
This package contains the openSUSE KDE3 User Guide (English).



%package pdf
Group:          Documentation/SUSE
License:        GNU Free Documentation License, Version 1.2 (GFDL 1.2)
Summary:        openSUSE KDE3 User Guide (English) as PDF
#Provides:     locale(desktop-data-openSUSE:en)
#PDFOBS

%description pdf
PDF of the openSUSE KDE3 User Guide (English).



%prep
#%setup -c -q
%setup -c -q -a 1
#PREP
find -name '*.png' -o -name '*.svg' | xargs chmod 644
cp %{S:2} .
#PDFPREP

%build
# make sure index.html exists
for f in $(find html -type f -name 'book.*'); do
  pushd ${f%/*}
  [ -f index.html -o -L index.html ] || ln -sf ${f##*/} index.html
  popd
done

%install
mkdir -p $RPM_BUILD_ROOT%{_defaultdocdir}
# is set for sles or sled as /sles or /sled
%define my_desktopdir /usr/share/susehelp/meta
echo %{my_desktopdir} | sed 's:\(\|xyzy\)::' >filelist
# mkdir -p  desktop/{startup,reference,application,apparmor-admin-guide}
###
install -d $RPM_BUILD_ROOT%{my_desktopdir}/%{name}
# product is name without language code
%define gnome_dir %{_datadir}/gnome/help/opensuse-kde3user
install -d $RPM_BUILD_ROOT%{gnome_dir}
#
if [ -d html/%my_book ]; then
mv html/%my_book html/manual
pushd desktop
# problem writing desktop files on 10.3
### CHECKIT: still necessary on 11.0?
if [ -d index.desktop ]; then
  for f in $(find index.desktop -mindepth 1 -maxdepth 1); do
    mv $f .
  done
  rmdir index.desktop
fi
### CHECKIT: can we fix this for 11.0?  Just avoid the subdir...
if [ ! -f .directory ]; then
  # stand-alone book, hidden in sub-directory
  dir=$(find . -maxdepth 1 -type d -name 'book_*')
  if [ -n "$dir" ]; then
    for f in $(find $dir -mindepth 1 -maxdepth 1); do
      mv $f .
    done
    rmdir $dir
  fi
fi
for f in $(find . -type f -name '*desktop'); do
    # /usr/share/doc/manual/suselinux-manual_en/manual
    sed -i "/^X-DOC-Identifier.*/d
s|@PATH@|%{_defaultdocdir}/%{name}/manual|
s/\[\]//" $f
    if ! grep -q -e '^Name *=' $f; then
    # requiered if no "Name=" is present
      sed -i "s|^Name\[.*\]\(=.*\)|Name\1\\
&|" $f
    fi
done
for d in $(find . -maxdepth 1 -type d -name 'book*'); do
  id=${d//\./}
  id=${id//\//}%{my_lang}
  pushd $d
  for f in $(find . -name '.directory'); do
    sed -i "s|@PATH@|%{_defaultdocdir}/%{name}/manual|
s/\[\]//
s|@id@|$id|" $f
    case $d in
      *_startup)
        [ $f = "./.directory" ] \
          && sed -i "s|^\(X-DOC-Weight\).*|\1=-10000|" $f ;;
    esac
  done
  popd
done
# Probably useful for stand-alone books
for f in $(find . -name '*.directory'); do
  id=%{name}
  id=${id//_/}
  sed -i "s|@PATH@|%{_defaultdocdir}/%{name}/manual|
s/\[\]//
s|@id@|$id|" $f
  # Fix the index.html reference
  if [ $f = ./.directory ]; then
    sed -i 's:\(^DocPath.*/\).*:\1index.html:
s/^\(Name\|Comment\)\(.*\)/\1\2 (%{my_lang})/' $f
  fi
  # make sure to sort startup guide first
  case %name in
    sles-startup*)
      [ $f = "./.directory" ] \
        && sed -i "s|^\(X-DOC-Weight\).*|\1=-2000|" $f ;;
  esac
done
cp -a . $RPM_BUILD_ROOT%{my_desktopdir}/%{name}
cp %{S:100} $RPM_BUILD_ROOT%{my_desktopdir}/.directory || :
popd
# Link it into the Gnome help system (must be found by calling
# susehelp help://suselinux-manual/
pushd $RPM_BUILD_ROOT%{gnome_dir}
if [ %{my_lang} = "en" ]; then
  target=$RPM_BUILD_ROOT%{_defaultdocdir}/%{name}/manual
  install -d $target
  ln -sf %{_defaultdocdir}/%{name}/manual C
else
  target=$RPM_BUILD_ROOT%{_defaultdocdir}/%{name}/manual
  install -d $target
  ln -sf %{_defaultdocdir}/%{name}/manual %{my_lang}
fi
popd
else
# PDF only books
install -d html/manual
echo PDF only > html/manual/%{name}
fi
%suse_update_desktop_file $RPM_BUILD_ROOT%{my_desktopdir}/%{name}/.directory

%clean
rm -fr ${RPM_BUILD_ROOT}

%files pdf
%defattr(-, root, root)
%dir %{_defaultdocdir}
%doc *.pdf

%files
%defattr(-, root, root)
%doc html/manual
%{my_desktopdir}
%dir %{_datadir}/susehelp
%{gnome_dir}
%dir /usr/share/gnome
%dir /usr/share/gnome/help
%changelog
* Tue Jul 29 2008 ke@suse.de
- Version update for 11.1.
* Fri May 16 2008 ke@suse.de
- Update text and image files for 11.0 RC1
- Fix locale provides (desktop-data-openSUSE instead of
  desktop-data-openS_u_SE); debugged by Stephan Kulow, bnc#391194.
* Tue May 13 2008 ke@suse.de
- New package (11.0).
openSUSE Build Service is sponsored by