File pre_checkin.sh of Package kde3-i18n

#! /bin/sh

nr="0"

# for i in `ls -1 *.tar.bz2 | sed -e "s,.tar.bz2,,"` ; do bunzip2 -c $i.tar.bz2 > $i.tar; tar xf $i.tar; find $i -name *.png | xargs -n1 optipng -o4; tar cf $i-new.tar $i; xdelta delta $i.tar $i-new.tar $i.xdelta; rm -rf $i; rm $i.tar $i-new.tar; done

cp kde3-i18n.spec.in kde3-i18n.spec

for lang in `ls -1 kde-i18n*tar.bz2 | sed -n 's,kde-i18n-\([^-]*\)-.*,\1,p'`; do
  languages="$languages $lang"
done

sed="s,@LANGUAGES@,$languages,"

for lang in $languages; do

 sed="$sed;s,#@SOURCES@,Source$nr: kde-i18n-$lang-%version.tar.bz2\n#@SOURCES@," 
 snr=$nr
 nr=$(( $nr + 1 ))
 if test -e kde-i18n-$lang-*.xdelta; then
   dnr=$nr
   nr=$(( $nr + 1 )) 
   sed="$sed;s,#@SOURCES@,Source$dnr: kde-i18n-$lang-%version.xdelta\n#@SOURCES@," 
   sed="$sed;s,#@EXTRACT@,bunzip2 -c %{S:$snr} > $lang.tar; md5sum $lang.tar; xdelta patch %{S:$dnr} $lang.tar $lang-new.tar; tar xf $lang-new.tar; rm $lang.tar $lang-new.tar\n#@EXTRACT@,"
 else
   sed="$sed;s,#@EXTRACT@,tar xf %{S:$snr}\n#@EXTRACT@,"
 fi

 plang=$lang
 if test "$lang" = "sr@Latn"; then
	lang=srLatn
	plang=sr
 fi
 if test "$lang" = "uz@cyrillic"; then
	lang=uzcyrillic
	plang=uz
 fi

 splitpackage=

 if test "$lang" = "foobar"; then
        splitpackage=true
 fi

 text="%package $lang\nSummary:Translations for $lang\nGroup:System/GUI/KDE\nProvides:kde-i18n-$lang locale(kdelibs3:$plang)\nRequires:kde3-i18n-$lang-base\n\n"
 if test "$lang" = "nn"; then
   text="$text""Provides:kde3-i18n-no_NY\nObsoletes:kde3-i18n-no_NY\n"
 fi
 if test "$lang" = "de"; then
   text="$text""Provides:kde3-i18n-de-data=3.5.10 kde3-i18n-de-doc=3.5.10\nObsoletes:kde3-i18n-de-data<=3.5.10 kde3-i18n-de-doc<=3.5.10\n"
 fi
 text="$text""%description $lang\n$lang localization\n\n"
 text="$text""%package $lang-base\nSummary:Translations for $lang-base\nGroup:System/GUI/KDE\nProvides:kde-i18n-$lang locale(kdelibs3:$plang) kde3-i18n-$lang:/opt/kde3/share/locale/$plang/LC_MESSAGES/kdelibs.mo\n\n"
 text="$text""%description $lang-base\n$lang base\n"

 if test $splitpackage; then
        text="$text\n%package $lang-doc\nSummary:Manuals for $lan\nGroup:System/GUI/KDE\nProvides:locale(kdelibs3:$plang)\nRequires:kde3-i18n-$lang-doc-base\n%description $lang-doc\n$lang\n"
        text="$text\n%package $lang-doc-base\nSummary:Base Manuals for $lang\nGroup:System/GUI/KDE\nProvides:locale(kdelibs3:$plang) kde3-i18n-$lang-doc:/opt/kde3/share/doc/HTML/$plang/common/kde-common.css\n%description $lang-doc-base\n$lang base manuals\n\n"
        text="$text%package $lang-data\nSummary:Application Data for $lang\nGroup:System/GUI/KDE\nProvides:locale(kdelibs3:$plang)\n%description $lang-data\n$lang application data\n\n"
 fi

 sed="$sed;s,#@PACKAGES@,$text\n#@PACKAGES@,"

 if test $splitpackage; then
        sed="$sed;s,#@FILES@,%files $lang -f ../files.$lang\n%files $lang-base -f ../files.base.$lang\n%files $lang-doc -f ../files.doc.$lang\n%files $lang-doc-base -f ../files.doc.base.$lang\n%files $lang-data -f ../files.data.$lang\n#@FILES@,"
 else
         sed="$sed;s,#@FILES@,%files $lang -f ../files.all.$lang\n%files $lang-base -f ../files.all.base.$lang\n#@FILES@,"
 fi

done

sed -e "$sed" kde3-i18n.spec > kde3-i18n.spec.tmp && mv kde3-i18n.spec.tmp kde3-i18n.spec

# prepare_spec kde3-i18n.spec > kde3-i18n.spec.temp && mv kde3-i18n.spec.temp kde3-i18n.spec

perl update_spec.pl kde3-i18n.spec attributes > new.spec
mv new.spec kde3-i18n.spec