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

#
# spec file for package bundle-lang-kde (Version 11.1)
#
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
#!BuildIgnore: gimp-unstable

# norootforbuild

Name:           bundle-lang-@SPEC@
BuildRequires:  @PACKAGES@
BuildRequires:  fdupes
License:        GNU General Public License (GPL)
Group:          System/GUI/Other
Version:        11.1
Release:        1
Summary:        Summary
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
Source0:        bundle.sh
Source1:        list_langs.sh
Source2:        packages.txt

%description

#LANGUAGES

%prep

%build

%install
mkdir -p $RPM_BUILD_ROOT
cp %SOURCE1 .
bash %SOURCE0 @PACKAGES@

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

if test @SPEC@ = kde; then
  # pretty evil hack to keep the symlinks working
  langs=`cd $RPM_BUILD_ROOT/opt/kde3/share/doc-bundle/HTML && ls -1d *`
  for lang in $langs; do
    ln -s /opt/kde3/share/doc/HTML/$lang/common $RPM_BUILD_ROOT/opt/kde3/share/doc-bundle/HTML/$lang/common
    echo /opt/kde3/share/doc-bundle/HTML/$lang/common >> filelist.$lang
    # we don't need the ../common symlinks (bnc#394343)
    files=`cd $RPM_BUILD_ROOT && ls -1 opt/kde3/share/doc-bundle/HTML/$lang/*/common 2>/dev/null`
    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
taken_languages="@TAKEN_LANGUAGES@"
for lang in $taken_languages; do
  echo "%defattr(-,root,root,755)" > taken.$lang
  cat filelist.$lang >> taken.$lang
  rm filelist.$lang
done
echo "%defattr(-,root,root,755)" > restfiles
for file in filelist.*; do
  cat $file >> restfiles
  rm $file
done

for file in taken.* restfiles; 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

%files -f restfiles

#LANGUAGE_FILES

%changelog
openSUSE Build Service is sponsored by