File sled-manuals_ja.spec of Package sled-manuals_ja

#
# spec file for package sled-manuals_ja
#
# Copyright (c) 2014 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/
#


%bcond_without PDF
Name:           sled-manuals_ja
%define my_lang ja
%define my_book SLED-html
Version:        12
Release:        0
# Commented--we now use in IBS prjconf (outdated!):
# Substitute: xmlgraphics-fop agfa-fonts xep xep-license xmlgraphics-fop
# agfa-fonts is only needed when building with xep
# BuildRequires: agfa-fonts
# BuildRequires: xep xep-license
Provides:       locale(desktop-data-SLE:ja)
#OBS
Source:         SLED-html_ja_src_set.tar.bz2
#SOURCES
Source901:      doc_pre_checkin.sh
Source903:      attributes
BuildRequires:  daps
BuildRequires:  fdupes
BuildRequires:  ipa-pgothic-fonts
BuildRequires:  ipa-pmincho-fonts
BuildRequires:  nanum-fonts
BuildRequires:  suse-xsl-stylesheets >= 1.9.18
BuildRequires:  wqy-microhei-fonts
# Also buildrequire tools that susedoc does not pull in automatically ATM
# BuildRequires:  python-xml
# BuildRequires:  python-lxml
# BuildRequires:  poppler-tools
BuildRequires:  update-desktop-files
# BuildRequires:  xerces-j2
# %%if 0%%{?suse_version} >= 1140
# BuildRequires:  xmlgraphics-fop
# %%else
# BuildRequires:  fop
# %%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
Summary:        SLED Manuals (Japanese)
License:        GFDL-1.2
Group:          Documentation/SUSE
Url:            https://www.suse.com/documentation/sled11/
%define _defaultdocdir %{_datadir}/doc/manual
%define _docdir %{_datadir}/doc/manual

%description
The SUSE Linux Enterprise Desktop Manuals (Japanese).

%package -n sled-installquick_ja-pdf
Summary:        SLED Installation Quick Start (Japanese)
Group:          Documentation/SUSE
#Provides:    locale(desktop-data-openSUSE:ja)
###PDFOBS

%description -n sled-installquick_ja-pdf
The SUSE Linux Enterprise Server Installation Quick Start
(Japanese).

%package -n sled-gnomeuser_ja-pdf
Summary:        SLED GNOME User Guide (Japanese)
Group:          Documentation/SUSE
#Provides:    locale(desktop-data-openSUSE:ja)
###PDFOBS

%description -n sled-gnomeuser_ja-pdf
The SUSE Linux Enterprise Desktop GNOME User Guide (Japanese).

%package -n sled-admin_ja-pdf
Summary:        SLED Adminguide (Japanese)
Group:          Documentation/SUSE
#Provides:    locale(desktop-data-openSUSE:ja)
###PDFOBS

%description -n sled-admin_ja-pdf
The SUSE Linux Enterprise Desktop Administration Guide (Japanese).

%prep
#%%setup -c -q
%setup -c -q -n %{name}-%{version}/SLED-html
#PREP
%setup -c -q -T -D -n %{name}-%{version}
find -name '*.png' -o -name '*.svg' | xargs chmod 644 || :
#PDFPREP

%build
%define my_all_dir  %{_builddir}/%{name}-%{version}/SLED-html
cd %{my_all_dir}
# e.g., /usr/share/help/C/gnome-help/opensuse-manuals.page
# Produce .page files for HTML
package_dir=$(daps -d DC-SLED-html package-html --pagefiles)
my_ll=$(echo %{my_lang} | tr [:upper:] [:lower:])
tar xvf $package_dir/SLED-html_${my_ll}-html.tar.bz2
echo SLED-html > %{name}.filelist
# ls -l build/%my_book/package
cp $package_dir/*.page %name.page

#MAKE_DOC
export XEP_LICENSE=/etc/xep/license.xml
export XEP_HOME=/usr/share/xep
# see https://sourceforge.net/p/daps/tickets/107/
export XEP_OPTIONS="-valid"
# export FOP=fop
export FOP_STACK="-Xss2048K"
build_pdf () {
%if %{with PDF}
  book=$(echo ${1} | tr [:upper:] [:lower:])
  if [ -x /usr/bin/xep ]; then
    formatter=xep
  fi
  if [ -z "$formatter" ]; then
    formatter=$(daps -d DC-${1} showvariable VARIABLE=FORMATTER)
  fi
  if [ $formatter = fop ]; then
    # 2014-01-14: according to sknorr,
    # XSLTPARAM='\\\"--param hyphenate.verbatim=0\\\"' is no longer needed
    pkg_pdf=$(daps -d DC-${1} package-pdf --formatter=$formatter)
  else
    pkg_pdf=$(daps -d DC-${1} package-pdf --formatter=$formatter)
  fi
  pdfname=$(find $pkg_pdf -name '*.pdf')
# 2014-01-14: not sure whether we still need -pdf.document
#  docname=$(find $pkg_pdf -name '*-pdf.document')
#  if [ -z "$docname" ]; then
#    docname=$(find $pkg_pdf -name '*.document')
#    mv $docname ${docname%\.document}-pdf.document
#    docname=${docname%\.document}-pdf.document
#  fi
#  pwd
#  sed -i "
## remove useless comments and search settings
#/^Categories=/d
#/^DocPath=/d
#/^Name *=/i\
#Categories=System;Core;Translation;Documentation\n\
#DocPath=file://%{_defaultdocdir}/${1}_ja-pdf/${pdfname##*/}
#" $docname
#  {
#    echo $pdfname
#    echo $docname
#  } > ${book}_ja-pdf.filelist
  echo $pdfname > ${book}_ja-pdf.filelist

%else
: say build --with PDF
%endif
}
all_pdf_docs=" SLED-installquick SLED-gnomeuser SLED-admin"
[ -n "$all_pdf_docs" ] && for b in $all_pdf_docs; do build_pdf $b; done

%install
cd %{my_all_dir}
mkdir -p %{buildroot}%{_defaultdocdir}
# product is name without language code
%define gnome_dir %{_datadir}/gnome/help/sled-manuals
install -d %{buildroot}%{gnome_dir}
#
cp -a --dereference $(head -n 1 %{name}.filelist) \
  %{buildroot}/%{_defaultdocdir}/%{name}
mkdir -p %{buildroot}$gnome_help_dir
cp %name.page %{buildroot}$gnome_help_dir/%name.page
echo "$gnome_help_dir/%name.page" > %name.filelist

%if %{with PDF}
for f in *-pdf.filelist; do
  # cat $f
  mkdir %{buildroot}/%{_defaultdocdir}/${f%\.filelist}
  # PDF first
  cp -a --dereference $(head -n 1 $f) \
    %{buildroot}/%{_defaultdocdir}/${f%\.filelist}
  # remove first line and append the new location
  sed -i 1d $f
  echo "%{_defaultdocdir}/${f%\.filelist}" >> $f
  #PDFHTML_LIST
done
%endif

%fdupes '%{buildroot}%{_docdir}'

%if %{with PDF}
#PDFINST

%endif

#PDFXXX

%files -n sled-installquick_ja-pdf -f %{my_book}/sled-installquick_ja-pdf.filelist
%defattr(-, root, root)

%files -n sled-gnomeuser_ja-pdf -f %{my_book}/sled-gnomeuser_ja-pdf.filelist
%defattr(-, root, root)

%files -n sled-admin_ja-pdf -f %{my_book}/sled-admin_ja-pdf.filelist
%defattr(-, root, root)

#PDFFILES

%files -f %{my_book}/%{name}.filelist
%defattr(-, root, root)
%dir %{_defaultdocdir}
%{_defaultdocdir}/%{name}
#GNOME
#KDE4

%changelog