File apparmor-admin_en.spec of Package apparmor-admin_en

#
# spec file for package apparmor-admin_en (Version 10.3)
#
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild


Name:           apparmor-admin_en
%define my_lang en
%define my_book APPARMOR-admin
Version:        10.3
Release:        82
#Provides:       locale(apparmor-docs:en)
#OBS
Source0:        APPARMOR-admin_en-html.tar.bz2
Source1:        APPARMOR-admin_en-desktop.tar.bz2
Source2:        APPARMOR-admin_en.pdf
Source3:        APPARMOR-admin_en-graphics.tar.bz2
Source4:        APPARMOR-admin_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:        AppArmor Admin Guide (English)
%define _defaultdocdir %{_datadir}/doc/manual
%define _docdir %{_datadir}/doc/manual
%define PDFDOC %{_defaultdocdir}/%{name}-pdf

%description
AppArmor Administration Guide (English).



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

%description pdf
PDF of the AppArmor Administration 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
find . -name CVS -o -name '.xvpics' -o -name '.cvsignore' \
  | xargs rm -fr
# 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
[ -d $RPM_BUILD_ROOT ] && rm -fvr $RPM_BUILD_ROOT
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
%if %suse_version < 1030
%define gnome_dir /opt/gnome/share/gnome/help/apparmor-admin
%else
%define gnome_dir %{_datadir}/gnome/help/apparmor-admin
%endif
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
if [ -d index.desktop ]; then
  for f in $(find index.desktop -mindepth 1 -maxdepth 1); do
    mv $f .
  done
  rmdir index.desktop
fi
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 "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 . -maxdepth 1 -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
done
# # remove the dots from the file names
# for f in $(find . -type f -name '*desktop'); do
#   d=${f%/*}
#   n=${f##*/}; n=${n/\.desktop}; n=${n//\./_}; n=${n}.desktop
#   [ $f = $d/$n ] || mv -v $f $d/$n
# done
# ren_dir () {
#   for d in $(find . -maxdepth $1 -mindepth $1 -type d); do
#     n=${d#*/}; n=${n//\./_}
#     [ $d = $n ] || mv -v $d $n
#   done
# }
# ren_dir 1
# ren_dir 2
# #
cp -a . $RPM_BUILD_ROOT%{my_desktopdir}/%{name}
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

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

%files
%defattr(-, root, root)
%doc html/manual
%{my_desktopdir}
%dir %{_datadir}/susehelp
%{gnome_dir}
%if %suse_version > 1020
%dir /usr/share/gnome
%dir /usr/share/gnome/help
%else
%dir /opt/gnome
%dir /opt/gnome/share
%dir /opt/gnome/share/gnome
%dir /opt/gnome/share/gnome/help
%endif

%changelog
* Thu Sep 06 2007 ke@suse.de
- On openSUSE, do not install it at all; apparmor docs on openSUSE are
  part of the opensuse-manual_en package.
* Thu Sep 06 2007 coolo@suse.de
- only install the admin guide if the other apparmor docs are wanted
* Thu Sep 06 2007 coolo@suse.de
- As discussed with Tanja and Jana: pdfs should not be installed by
  default
* Wed Aug 22 2007 ke@suse.de
- Prepare the .spec to make it build properly on SLE10.
* Mon Aug 20 2007 ke@suse.de
- Update current texts as a stand-alone package.
- Use new desktop files.
* Tue Feb 27 2007 ke@suse.de
- /opt/gnome -> /usr .
* Fri Jun 02 2006 ke@suse.de
- Update for SLE 10 RC3.
* Mon May 08 2006 ke@suse.de
- Update for RC1.
* Fri Apr 21 2006 ke@suse.de
- created package
openSUSE Build Service is sponsored by