File opensuse-startup_ja.spec of Package opensuse-startup_ja

#
# spec file for package opensuse-startup_ja
#
# Copyright (c) 2013 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:           opensuse-startup_ja
%define my_lang ja
%define my_book opensuse-startup
Version:        13.1
Release:        0
#BREQ
Provides:       opensuse-manuals_ja = %{version}
Provides:       locale(desktop-data-openSUSE:ja)
#OBS
Source:         opensuse-startup_ja_src_set.tar.bz2
#SOURCES
Source901:      doc_pre_checkin.sh
Source903:      attributes
Patch0:         entity_opensuse_only.patch
Patch1:         fop_config_removepath.patch
BuildRequires:  daps
BuildRequires:  fdupes
BuildRequires:  suse-xsl-stylesheets >= 1.9.18
# 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
# BEGIN - Japanese environment
BuildRequires:  IPAGothic
BuildRequires:  IPAGothic_Bold
BuildRequires:  IPAGothic_BoldItalic
BuildRequires:  IPAGothic_Italic
BuildRequires:  IPAPGothic
BuildRequires:  IPAPGothic_Bold
BuildRequires:  IPAPGothic_BoldItalic
BuildRequires:  IPAPGothic_Italic
# END - Japanese environment
%if 0%{?suse_version} == 1315
%if 0%{?sle_version} >= 120200
# novdoc was separated
BuildRequires:  novdoc
%endif
%endif
%if 0%{?suse_version} > 1320
# novdoc was separated
BuildRequires:  novdoc
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
Summary:        openSUSE manual: Start-Up (HTML, Japanese)
License:        GFDL-1.2
Group:          Documentation/SUSE
Url:            http://doc.opensuse.org
%define _defaultdocdir %{_datadir}/doc/manual
%define _docdir %{_datadir}/doc/manual

Obsoletes:      opensuse-manuals_ja-pdf < 13.1

%description
Guides you through the installation and basic configuration of your
system. For newcomers, the manual also introduces basic Linux concepts
such as the file system, the user concept and access permissions and
gives an overview of the features the system offers to support
mobile computing. Provides help and advice in troubleshooting.

%package -n opensuse-startup_ja-pdf
Summary:        openSUSE manual: Start-Up (PDF, Japanese)
Group:          Documentation/SUSE
#Provides:    locale(desktop-data-openSUSE:ja)
###PDFOBS

%description -n opensuse-startup_ja-pdf
Guides you through the installation and basic configuration of your
system. For newcomers, the manual also introduces basic Linux concepts
such as the file system, the user concept and access permissions and
gives an overview of the features the system offers to support
mobile computing. Provides help and advice in troubleshooting.

%prep
#%%setup -c -q
%setup -c -q -n %{name}-%{version}/opensuse-startup
#PREP
%setup -c -q -T -D -n %{name}-%{version}
find -name '*.png' -o -name '*.svg' | xargs chmod 644 || :
#PDFPREP
%if 0%{?suse_version} == 1315
%if 0%{?sle_version} >= 120200
# openSUSE only
%patch0
%patch1
%endif
%endif
%if 0%{?suse_version} > 1320
# openSUSE only
%patch0
%patch1
%endif

%build
%define my_all_dir  %{_builddir}/%{name}-%{version}/opensuse-startup
cd %{my_all_dir}
# e.g., /usr/share/help/C/gnome-help/opensuse-manuals.page
# Produce .document files for HTML
package_dir=$(daps -d DC-opensuse-startup package-html --documentfiles --pagefiles)
if [ 0%{?suse_version} -ge 1315 ]; then
  tar xvf $package_dir/book.opensuse.startup_%{my_lang}-html.tar.bz2
  echo book.opensuse.startup > %{name}.filelist
else
  tar xvf $package_dir/opensuse-startup_%{my_lang}-html.tar.bz2
  echo opensuse-startup > %{name}.filelist
fi
# ls -l build/%my_book/package
document_files_dir=$package_dir
# copy .page file
cp $document_files_dir/*.page %name.page
[ -f $document_files_dir/index.html.document ]\
  || mv $document_files_dir/*.document $document_files_dir/index.html.document
sed -i "
s|@PATH@|file://%{_docdir}/%{name}|
s|^\(Name.*=.*\)|\1 (%{my_lang})|
" $document_files_dir/index.html.document
mkdir yelp desktop
sed "
# remove useless comments and search settings
/^Comment/d
/^X-DOC-Search/d
/^Categories=/d
/^DocPath=/d
/^Name *=/i\
DocPath=file://%{_defaultdocdir}/%{name}/index.html\n\
# for KDE:\n\
X-DocPath=file://%{_docdir}/%{name}/index.html\n\
DocType=text/html\n\
DocLang=%{my_lang}\n\
Icon=document2\n\
Categories=System;Core;Translation;Documentation
s/^X-DOC-Identifier=/DocIdentifier=com.suse./
s/^X-DOC-Weight/DocWeight/
" $document_files_dir/index.html.document > desktop/%{name}.desktop 
# FIXME: check whether it is still needed (move to daps?)
sed "s/^[Desktop Entry]/[Document]/" desktop/%{name}.desktop \
  > yelp/%{name}.document
{ echo desktop/%{name}.desktop; echo yelp/%{name}.document; } >> %{name}.filelist

#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
#     # bnc#778567
#     daps -v -d DC-${1} pdf-color --xsltparam "'--param hyphenate.verbatim 0'"
#   else
#     daps -v -d DC-${1} pdf-color --formatter=$formatter
#   fi
  # pdf-color-name does not support --formatter
  # pdfname=$(daps -d DC-${1} pdf-color-name | sed /^Hint.*/d)
  # echo "$pdfname" > ${1}_ja-pdf.filelist
  if [ $formatter = fopx -a 0%{?suse_version} -lt 1320 ]; then
    # bnc#778567
    # right now, daps 1.1.2 does not support --xsltparam
    # FIXME: Tut so naed -- ask Magic
    pkg_pdf=$(daps -d DC-${1} package-pdf --formatter=$formatter --documentfiles XSLTPARAM='\\\"--param hyphenate.verbatim 0\\\"')
  else
    daps -d DC-${1} package-pdf --formatter=$formatter
    pkg_pdf=$(daps -d DC-${1} package-pdf --formatter=$formatter --documentfiles)
  fi
  pdfname=$(find $pkg_pdf -name '*.pdf')
  docname=$(find $pkg_pdf -name '*.document' -a \! -name 'index.html.document')
  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
%else
: say build --with PDF
%endif
}
all_pdf_docs=" opensuse-startup"
[ -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/opensuse-startup
install -d %{buildroot}%{gnome_dir}
#
cp -a --dereference $(head -n 1 %{name}.filelist) \
  %{buildroot}/%{_defaultdocdir}/%{name}
mkdir -p %{buildroot}/%{_datadir}/kde4/apps/khelpcenter/plugins
cp desktop/%{name}.desktop \
  %{buildroot}/%{_datadir}/kde4/apps/khelpcenter/plugins
%suse_update_desktop_file '%{name}'
if [ %{my_lang} = en ]; then
  yelp_document_dir=%{_datadir}/help
  yelp_link_dir=$yelp_document_dir/C
  gnome_help_dir=%{_datadir}/help/C/gnome-help
  {
    echo "%dir $yelp_document_dir"
    echo "%dir $yelp_link_dir"
    echo "$yelp_link_dir/%my_book"
    echo "%dir $gnome_help_dir"
  } > %name.filelist
else
  yelp_document_dir=%{_datadir}/help/LOCALE/%{my_lang}
  yelp_link_dir=$yelp_document_dir
  gnome_help_dir=%{_datadir}/help/LOCALE/%{my_lang}/gnome-help
  {
    echo "%dir %{_datadir}/help/LOCALE"
    echo "%dir %{_datadir}/help/LOCALE/%{my_lang}"
    echo "%dir $yelp_document_dir"
    echo "$yelp_link_dir/%my_book"
    echo "%dir $gnome_help_dir"
  } > %name.filelist
fi
mkdir -p %{buildroot}$yelp_document_dir
cp yelp/%{name}.document %{buildroot}$yelp_document_dir
mkdir -p %{buildroot}$yelp_link_dir
pushd %{buildroot}$yelp_link_dir
ln -sf %{_defaultdocdir}/%name %my_book
popd
mkdir -p %{buildroot}$gnome_help_dir
cp %name.page %{buildroot}$gnome_help_dir/%name.page
{
  echo "$yelp_document_dir/%{name}.document"
  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
  # now .document
  doc=$(head -n 1 $f)
  cp $doc  %{buildroot}/%{_datadir}/help
  sed -i 1d $f
  echo "%{_datadir}/help/${doc##*/}" >> $f
  #PDFHTML_LIST
done
%endif

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

%if %{with PDF}
#PDFINST

%endif

#PDFXXX

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

#PDFFILES

%files -f %{my_book}/%{name}.filelist
%defattr(-, root, root)
%dir %{_defaultdocdir}
%{_defaultdocdir}/%{name}
#GNOME
#KDE4
%dir %{_datadir}/kde4/apps/khelpcenter/plugins
%dir %{_datadir}/kde4/apps/khelpcenter
%dir %{_datadir}/kde4/apps
%dir %{_datadir}/kde4
%{_datadir}/kde4/apps/khelpcenter/plugins/%{name}.desktop

%changelog