File kde4-l10n.spec.in of Package kde4-l10n

#
# spec file for package kde4-l10n (Version 4.5.90)
#
# Copyright (c) 2010 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
# icecream 0

Name:           kde4-l10n
BuildRequires:  cmake libkde4-devel recode update-desktop-files
%if %suse_version > 1020
BuildRequires:  fdupes
%endif
Url:            http://l10n.kde.org/
License:        GPL v2 or later
Group:          System/Localization
Summary:        English translations for KDE
Version:        4.6.0
Release:        1
%define kdepim_version %version
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
#@SOURCES@
Source100:      COPYING
Source101:      texts
Source102:      update_spec.pl
Source103:      pre_checkin.sh
Source104:      kde-l10n-kdepim-4.4.5.tar.bz2
%define build_languages @LANGUAGES@
%define split_languages @SPLITLANGS@
%define kdepim44 1

%description
All the requirements for a translated desktop. This package 
contains application translations, help files, and screenshots.

#@PACKAGES@

%prep
mkdir %name-%version
%setup -q @SETUP_LIST@ -b 104
#@EXTRACT@
%if 0
#I assume this is no longer needed as that kdepim trunk is used
for i in %build_languages; do
   cd ../kde-l10n-$i-%version || exit 1
   if test "%{kdepim_version}" != "%version"; then
     for skip in koffice kdepim; do
       rm -rf */$skip
       for c in */CMakeLists.txt; do
         sed -i -e "s,add_subdirectory( *$skip *),," $c
       done
     done
     for d in data docs messages; do
       for m in kdepimlibs kdepim; do
         if test -d ../kde-l10n-$i-%{kdepim_version}/$d/$m ; then
           rm -rf $d/$m
           mv ../kde-l10n-$i-%{kdepim_version}/$d/$m $d/$m
           fgrep -q "($m)" $d/CMakeLists.txt || echo "add_subdirectory($m)" >> $d/CMakeLists.txt
         fi
       done
     done
   fi
done
%endif

# adds kdepim 4.4.5 translations  
%if %kdepim44 == 1  
 for l in ../kde-l10n-*4.4.5; do  
  k=`echo $l | sed 's/4.4.5/%version/g'`  
  if [ -d $k/messages ] && [ -d $l/messages/kdepim ] ; then  
   cp -R $l/messages/* $k/messages/  
   sed -i -e '/add_subdirectory(kdepimlibs)/ i\add_subdirectory(kdepim)' $k/messages/CMakeLists.txt  
  fi  
 done
%endif

%build
for i in %build_languages; do
  pushd ../kde-l10n-$i-%version
    %cmake_kde4
    %make_jobs
  popd
done

%install
for i in %build_languages; do
  pushd ../kde-l10n-$i-%version
    make DESTDIR=%{buildroot} install/fast
  popd
  mkdir -p $RPM_BUILD_ROOT/usr/share/doc/packages/kde4-l10n-$i
  install -m 644 %{SOURCE100} $RPM_BUILD_ROOT/usr/share/doc/packages/kde4-l10n-$i
done

for i in %split_languages; do
  mkdir -p $RPM_BUILD_ROOT/usr/share/doc/packages/kde4-l10n-$i-doc
  install -m 644 %{SOURCE100} $RPM_BUILD_ROOT/usr/share/doc/packages/kde4-l10n-$i-doc

  mkdir -p $RPM_BUILD_ROOT/usr/share/doc/packages/kde4-l10n-$i-data
  install -m 644 %{SOURCE100} $RPM_BUILD_ROOT/usr/share/doc/packages/kde4-l10n-$i-data
done


# hacks
rm -f $RPM_BUILD_ROOT/usr/share/locale/*/flag.png
rm -f $RPM_BUILD_ROOT/usr/share/locale/*/charset
rm -f $RPM_BUILD_ROOT/usr/share/locale/*/index.lokalize

#
# convert man-pages from xml to utf-8:
#
for i in $RPM_BUILD_ROOT/usr/share/man/*/*/*.[0-9].gz
do
    if [ -f $i ] ; then
          gunzip $i;
    fi
done
for i in $RPM_BUILD_ROOT/usr/share/man/*/*/*.[0-9]
do
    if [ ! -f $i ]; then
        break
    fi
    if iconv -s -c -f ascii -t ascii >/dev/null ; then
        # it is ascii, conversion from xml to utf-8 is safe
        recode xml..utf-8 $i
    else
        if iconv -s -c -f utf-8 -t utf-8 >/dev/null ; then
            # it is already utf-8, do nothing
            :
        else
            # it is iso-8859-1, conversion from xml to utf-8 is safe
            recode xml..utf-8 $i
        fi
    fi
done

#
# remove unwanted files
#
rm -rf ${RPM_BUILD_ROOT}/usr/share/kde4/apps/koffice
rm -f  ${RPM_BUILD_ROOT}/opt/kde3/share/locale/*/charset
find ${RPM_BUILD_ROOT}/usr/share/doc/kde/HTML/ -type l -name common -print0 | xargs -0 rm 
#
rm -f files.* files.data.* files.doc.*

for i in %build_languages sr@latin sr@ijekavian sr@ijekavianlatin; do
   turtlelang=$i
   l=$i
   case $i in
	de)
	   turtlelang=de_DE
	   ;;
	mk)
           turtlelang=mk_MK
	   ;;
        fr)
	   turtlelang=fr_FR
	   ;;
	sr@latin)
          l=sr
          ;;
	sr@ijekavian)
          l=sr
          ;;
	sr@ijekavianlatin)
          l=sr
          ;;
   esac
   {
   echo "%defattr(-,root,root)"
   if test -d $RPM_BUILD_ROOT/usr/share/locale/$i; then
	echo "%lang($l) /usr/share/locale/$i/LC_MESSAGES/*.mo"
   fi
   if test -d $RPM_BUILD_ROOT/usr/share/locale/$i/LC_SCRIPTS; then
	echo "%lang($l) /usr/share/locale/$i/LC_SCRIPTS/*"
	echo "%dir /usr/share/locale/$i/LC_SCRIPTS"
   fi
   if test -f $RPM_BUILD_ROOT/usr/share/locale/$i/entry.desktop; then
	echo "%lang($l) /usr/share/locale/$i/entry.desktop"
   fi
   if test -d $RPM_BUILD_ROOT/usr/share/man/$i; then
	echo "%lang($l) /usr/share/man/$i"
   fi
   for d in $RPM_BUILD_ROOT/usr/share/icons/*/*/*/l10n/$i $RPM_BUILD_ROOT/usr/share/icons/*/scalable/*/*/*/l10n/$i; do
     if test -d $d; then
       echo "%lang($l) ${d##$RPM_BUILD_ROOT}"
       echo "%dir ${d##$RPM_BUILD_ROOT}/../"
     fi
   done

   echo "/usr/share/doc/packages/kde4-l10n-$l" 

   if test "$i" = "hne" -a %suse_version -lt 1120; then
       echo "%dir /usr/share/locale/hne"
       echo "%dir /usr/share/locale/hne/LC_MESSAGES"
   fi

   #if [ "$i" == sr ] && [ "%suse_version" == 1140 ] ; then
       #echo "%dir /usr/share/locale/sr@ijekavian"
       #echo "%dir /usr/share/locale/sr@ijekavian/LC_MESSAGES"
       #echo "%dir /usr/share/locale/sr@ijekavianlatin"
       #echo "%dir /usr/share/locale/sr@ijekavianlatin/LC_MESSAGES"
   #fi

   } >> files.$l
   {
   echo "%defattr(-,root,root)"
   if test -d $RPM_BUILD_ROOT%{_kde_share_dir}/apps/khangman/data/$i; then
	echo "%lang($l) %{_kde_share_dir}/apps/khangman/data/$i"
	echo "%dir %{_kde_share_dir}/apps/khangman"
	echo "%dir %{_kde_share_dir}/apps/khangman/data"
   fi
   if test -d $RPM_BUILD_ROOT%{_kde_share_dir}/apps/kanagram/data/$i; then
	echo "%lang($l) %{_kde_share_dir}/apps/kanagram/data/$i"
	echo "%dir %{_kde_share_dir}/apps/kanagram"
	echo "%dir %{_kde_share_dir}/apps/kanagram/data"
   fi
   if test -f $RPM_BUILD_ROOT%{_kde_share_dir}/apps/step/objinfo/l10n/$i/Box.html; then
        echo "%dir %{_kde_share_dir}/apps/step"
        echo "%dir %{_kde_share_dir}/apps/step/objinfo"
        echo "%dir %{_kde_share_dir}/apps/step/objinfo/l10n"
        echo "%dir %{_kde_share_dir}/apps/step/objinfo/l10n/$i"
        echo "%lang($l) %{_kde_share_dir}/apps/step/objinfo/l10n/$i/*"
   fi
   if test -f $RPM_BUILD_ROOT%{_kde_share_dir}/apps/khangman/$i.txt; then
	echo "%dir %{_kde_share_dir}/apps/khangman"
	echo "%lang($l) %{_kde_share_dir}/apps/khangman/$i.txt"
   fi
   if test -f $RPM_BUILD_ROOT%{_kde_share_dir}/apps/katepart/syntax/logohighlightstyle.$turtlelang.xml; then
	echo "%lang($l) %{_kde_share_dir}/apps/katepart/syntax/logohighlightstyle.$turtlelang.xml"
        echo "%dir %{_kde_share_dir}/apps/katepart/syntax"
	echo "%dir %{_kde_share_dir}/apps/katepart"
   fi
   kturtle=0
   if test -f $RPM_BUILD_ROOT%{_kde_share_dir}/apps/kturtle/data/logokeywords.$turtlelang.xml; then
	echo "%lang($l) %{_kde_share_dir}/apps/kturtle/data/logokeywords.$turtlelang.xml"
	echo "%dir %{_kde_share_dir}/apps/kturtle/data"
	echo "%dir %{_kde_share_dir}/apps/kturtle"
	kturtle=1
   fi
   if test -d $RPM_BUILD_ROOT%{_kde_share_dir}/apps/kturtle/examples/$turtlelang; then
	echo "%lang($l) %{_kde_share_dir}/apps/kturtle/examples/$turtlelang"
	echo "%dir %{_kde_share_dir}/apps/kturtle/examples"
	if test "$kturtle" = 0; then
	   echo "%dir %{_kde_share_dir}/apps/kturtle"
        fi
   fi
   if test -d $RPM_BUILD_ROOT%{_kde_share_dir}/apps/klettres/$i; then
	echo "%lang($l) %{_kde_share_dir}/apps/klettres/$i"
	echo "%dir %{_kde_share_dir}/apps/klettres"
   fi
   if test -f $RPM_BUILD_ROOT%{_kde_share_dir}/apps/ktuberling/sounds/$i.soundtheme; then
	echo "%lang($l) %{_kde_share_dir}/apps/ktuberling/sounds/$i.soundtheme"
   fi
   if test -d $RPM_BUILD_ROOT%{_kde_share_dir}/apps/ktuberling/sounds/$i; then
	echo "%lang($l) %{_kde_share_dir}/apps/ktuberling/sounds/$i"
	echo "%dir %{_kde_share_dir}/apps/ktuberling"
	echo "%dir %{_kde_share_dir}/apps/ktuberling/sounds"
   fi
   if test -d $RPM_BUILD_ROOT%{_kde_share_dir}/apps/ksplash/Themes/Default/*/l10n/$i; then
	echo "%lang($l) %{_kde_share_dir}/apps/ksplash/Themes/Default/*/l10n/$i"
	echo "%dir %{_kde_share_dir}/apps/ksplash/Themes/Default/*/l10n"
	echo "%dir %{_kde_share_dir}/apps/ksplash/Themes/Default/*"
	echo "%dir %{_kde_share_dir}/apps/ksplash/Themes/Default"
	echo "%dir %{_kde_share_dir}/apps/ksplash/Themes"
	echo "%dir %{_kde_share_dir}/apps/ksplash"
   fi
   if test -d $RPM_BUILD_ROOT%{_kde_share_dir}/apps/kvtml/$i; then
	echo "%lang($l) %{_kde_share_dir}/apps/kvtml/$i"
	echo "%dir %{_kde_share_dir}/apps/kvtml"
   fi
   for d in $RPM_BUILD_ROOT%{_kde_share_dir}/apps/desktoptheme/*/widgets/l10n/$i; do
       if test -d $d; then
           echo "%lang($l) %{_kde_share_dir}/apps/desktoptheme/*/widgets/l10n/$i"
           echo "%dir %{_kde_share_dir}/apps/desktoptheme/*/widgets/l10n"
           echo "%dir %{_kde_share_dir}/apps/desktoptheme/*/widgets"
           echo "%dir %{_kde_share_dir}/apps/desktoptheme/*"
           echo "%dir %{_kde_share_dir}/apps/desktoptheme"
       fi
   done
   for d in $RPM_BUILD_ROOT%{_kde_share_dir}/apps/desktoptheme/*/icons/l10n/$i; do
       if test -d $d; then
           echo "%lang($l) %{_kde_share_dir}/apps/desktoptheme/*/icons/l10n/$i"
           echo "%dir %{_kde_share_dir}/apps/desktoptheme/*/icons/l10n"
           echo "%dir %{_kde_share_dir}/apps/desktoptheme/*/icons"
           echo "%dir %{_kde_share_dir}/apps/desktoptheme/*"
           echo "%dir %{_kde_share_dir}/apps/desktoptheme"
       fi
   done

  if test -d $RPM_BUILD_ROOT/usr/share/doc/packages/kde4-l10n-$i-data; then
        echo "/usr/share/doc/packages/kde4-l10n-$i-data"
   fi
   } >> files.data.$l

   {
   echo "%defattr(-,root,root)"
   if test -d $RPM_BUILD_ROOT%_kde_html_dir/$i; then
	echo "%lang($l) %doc %_kde_html_dir/$i"
   fi

   if test -d $RPM_BUILD_ROOT/usr/share/doc/packages/kde4-l10n-$i-doc ; then
        echo "/usr/share/doc/packages/kde4-l10n-$i-doc"
   fi
   } >> files.doc.$l
   cat files.$l files.data.$l files.doc.$l >files.all.$l
done

%if %suse_version > 1020
%fdupes $RPM_BUILD_ROOT
%endif

for file in $RPM_BUILD_ROOT/usr/share/locale/*/entry.desktop; do
   grep -q "X-SuSE-translate" "$file" || %suse_update_desktop_file $file
done

#@FILES@

%clean
rm -rf $RPM_BUILD_ROOT

%changelog -n kde4-l10n