File bundle-lang.spec.in of Package bundle-lang-common

#
# spec file for package bundle-lang-@SPEC@
#
# Copyright (c) 2011 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/
#

Name:           bundle-lang-@SPEC@
# @BREQUIRES@
BuildRequires:  fdupes
#!BuildIgnore:  xorg-x11-driver-input
#!BuildIgnore:  NetworkManager-openvpn
#!BuildIgnore:  NetworkManager-pptp
#!BuildIgnore:  NetworkManager-vpnc
#!BuildIgnore:  NetworkManager-openconnect
#!BuildIgnore:  virtualbox-host-kmp-default
#!BuildIgnore:  typelib-1_0-WebKit-1_0
#!BuildIgnore:  typelib-1_0-Vte-0_0
#!BuildIgnore: gimp-unstable
#!BuildIgnore: gnuchess
License:        license
Group:          group
Version:        13.1
Release:        1
Summary:        summary
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
Source0:        bundle.sh
Source1:        list_langs.sh
Source2:        packages.txt
Source3:        attributes
Source4:        update_spec.pl
Source5:        update-list.sh

%description
summary

#LANGUAGES

%prep

%build

%install
mkdir -p $RPM_BUILD_ROOT
cp %SOURCE1 .
packages=""
# @PACKAGES@
bash %SOURCE0 $packages

if test @SPEC@ = kde; then
  # pretty evil hack to keep the symlinks working
  langs=`cd $RPM_BUILD_ROOT/usr/share/doc-bundle/kde/HTML && ls -1d *`
  for lang in $langs; do
    ln -s /usr/share/doc/kde/HTML/$lang/common $RPM_BUILD_ROOT/usr/share/doc-bundle/kde/HTML/$lang/common
    echo /usr/share/doc-bundle/kde/HTML/$lang/common >> filelist.$lang
    # we don't need the ../common symlinks (bnc#394343)
    files=`cd $RPM_BUILD_ROOT && ls -1 /usr/share/doc-bundle/kde/HTML/$lang/*/common 2>/dev/null || true`
    for f in $files; do 
       if test -L $RPM_BUILD_ROOT/$f; then
         rm $RPM_BUILD_ROOT/$f
         for i in filelist*; do
           grep -v $f $i > $i.new || true
           mv $i.new $i
         done
       fi
    done
  done
fi
if test @SPEC@ = gnome -o @SPEC@ = gnome-extras; then
  # pretty evil hack to keep symlinks for localized help (usually, figures
  # that are unchanged and are shipped with the app itself)
  for file in `find %{buildroot}%{_datadir}/gnome/help-bundle %{buildroot}%{_datadir}/help-bundle`; do
    if test -L "${file}"; then
      target=`readlink --canonicalize-missing ${file}`
      if test ! -f "${target}" -a ! -f "${target#%{buildroot}}"; then
        target=`echo "${target#%{buildroot}}" | sed "s:help-bundle:help:"`
        echo ${target} | grep -qE "%{_datadir}/gnome/help/[^/]*/C/|%{_datadir}/help/C/[^/]*/"
        if test $? -eq 0; then
          ln -sf "${target}" "${file}"
          echo ln -sf "${target}" "${file}"
        fi
      fi
    fi
  done
fi
taken_languages="@TAKEN_LANGUAGES@"
for suffix in CN TW; do 
   cat filelist.zh_$suffix >> filelist.zh
   rm -f filelist.zh_$suffix
done
cat filelist.pt_BR >> filelist.pt
rm -f filelist.pt_BR
for lang in $taken_languages; do
  echo "%defattr(-,root,root,755)" > taken.$lang
  cat filelist.$lang >> taken.$lang
  rm filelist.$lang
done
# special hack for a special problem (I hope)
if test -f $RPM_BUILD_ROOT/usr/share/gnome/help-bundle/dia/eu/graphics/line_props.png; then
  rm $RPM_BUILD_ROOT/usr/share/gnome/help-bundle/dia/pl/graphics/line_props.png
  cp $RPM_BUILD_ROOT/usr/share/gnome/help-bundle/dia/eu/graphics/line_props.png $RPM_BUILD_ROOT/usr/share/gnome/help-bundle/dia/pl/graphics/line_props.png
fi

# make sure there are no file symlinks in taken languages
# fdupes at the end fixes duplicates
for file in taken.*; do
  grep -v %dir $file | sed -e "s,.*lang[^ ]* ,,; s,%doc *,," | while read f; do
    if readlink $RPM_BUILD_ROOT$f; then
      s="`readlink $RPM_BUILD_ROOT$f`"
      if   [ -f $RPM_BUILD_ROOT`dirname $f`/$s ]; then
        rm $RPM_BUILD_ROOT$f
        cp $RPM_BUILD_ROOT`dirname $f`/$s $RPM_BUILD_ROOT$f
      fi
    fi
  done
done

for file in filelist.*; do
  grep -v %dir $file | sed -e "s,.*lang[^ ]* ,,; s,%doc *,," | while read f; do rm -v $RPM_BUILD_ROOT$f; done
  rm $file
done

for i in $RPM_BUILD_ROOT/*; do
  %fdupes $i
done

for file in taken.*; do
  changed=1
  while test "$changed" = 1; do
    changed=0
    list=`grep %dir $file | sed -e "s,%dir,,; s,%lang[^ ]*,," | while read dir; do dirname "$dir"; done | sort -u`
    for dir in $list; do
      grep -q "$dir"\$ $file && continue
      rpm -qf $dir && continue
      changed=1
      echo "%dir $dir" >> $file
    done
  done
done

%clean
rm -rf $RPM_BUILD_ROOT

#LANGUAGE_FILES

%changelog
openSUSE Build Service is sponsored by