214 lines
8.2 KiB
Bash
214 lines
8.2 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
# This program searches for packages that are not updated and extracts
|
||
|
# their translation updates to a separate tarball that can be used by
|
||
|
# translation-update package.
|
||
|
|
||
|
WORK_DIR=$PWD
|
||
|
|
||
|
set -o errexit
|
||
|
shopt -s nullglob
|
||
|
|
||
|
if ! test -f upstream-collect.domain-map ; then
|
||
|
echo "Missing generated files. Please make a full run of ./upstream-collect.sh first."
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
source ${0%translation-update-upstream-to-translation-update.sh}upstream-collect.conf
|
||
|
|
||
|
mkdir\
|
||
|
TRANSLATION_UPDATE TRANSLATION_UPDATE/translation-update TRANSLATION_UPDATE/TUU\
|
||
|
TRANSLATION_UPDATE/NOT_UPDATED TRANSLATION_UPDATE/NOT_UPDATED/po TRANSLATION_UPDATE/NOT_UPDATED/po-mandatory\
|
||
|
TRANSLATION_UPDATE/UPDATED TRANSLATION_UPDATE/UPDATED/po TRANSLATION_UPDATE/UPDATED/po-mandatory\
|
||
|
TRANSLATION_UPDATE/complete TRANSLATION_UPDATE/rebuilt
|
||
|
|
||
|
# more tarballs are available => use the latest one
|
||
|
# FIXME: Fix 20090213.10 < 20090213.9
|
||
|
# (but it should not happen for people who update and submit)
|
||
|
for ARCHIVE in translation-update-upstream-*.tar.bz2 ; do
|
||
|
:
|
||
|
done
|
||
|
tar -jtf $ARCHIVE >${0%.sh}-updates.lst
|
||
|
SNAPSHOT=${ARCHIVE%.tar.bz2}
|
||
|
SNAPSHOT=${SNAPSHOT#translation-update-upstream-}
|
||
|
for ARCHIVE in translation-update-mandatory-*.tar.bz2 ; do
|
||
|
:
|
||
|
done
|
||
|
MSNAPSHOT=${ARCHIVE%.tar.bz2}
|
||
|
MSNAPSHOT=${MSNAPSHOT#translation-update-mandatory-}
|
||
|
if [[ "$MSNAPSHOT" > "$SNAPSHOT" ]] ; then
|
||
|
SNAPSHOT=$MSNAPSHOT
|
||
|
fi
|
||
|
|
||
|
cd TRANSLATION_UPDATE/TUU
|
||
|
cp -a ../../po-mandatory-full po-mandatory
|
||
|
cp -a ../../po-full po
|
||
|
cd ../..
|
||
|
|
||
|
osc ${OSC_APIURL:+--apiurl=$OSC_APIURL} ls "${OSC_REPOSITORIES[1]}" >${0%.sh}-rebuilt.lst
|
||
|
osc ${OSC_APIURL:+--apiurl=$OSC_APIURL} ls "${OSC_REPOSITORIES[0]}" >${0%.sh}-outdated.lst
|
||
|
|
||
|
SERIAL=0
|
||
|
for TLST in *.tlst ; do
|
||
|
exec <$WORK_DIR/$TLST
|
||
|
|
||
|
while read PACKAGE DOMAIN METHOD REPO DIR BRANCH MANDATORY ; do
|
||
|
|
||
|
# Continue for empty lines and comments
|
||
|
if test "${PACKAGE###}" != "$PACKAGE" ; then
|
||
|
continue
|
||
|
fi
|
||
|
if test -z "$PACKAGE" ; then
|
||
|
continue
|
||
|
fi
|
||
|
|
||
|
echo "$(tput setf 3)Processing: package=$PACKAGE domain=$DOMAIN method=$METHOD repository=$REPO directory=$DIR branch=${BRANCH:-(default)} mandatory=$MANDATORY$(tput init)"
|
||
|
PACKAGE_REBUILT_UP_TO_DATE=false
|
||
|
if grep -q "^$PACKAGE\$" ${0%.sh}-rebuilt.lst ; then
|
||
|
if grep -q "^$PACKAGE\$" ${0%.sh}-outdated.lst ; then
|
||
|
echo " is rebuilt in the distro, but has pending translation related update, adding"
|
||
|
else
|
||
|
PACKAGE_REBUILT_UP_TO_DATE=true
|
||
|
echo " is rebuilt in the distro, not adding"
|
||
|
fi
|
||
|
else
|
||
|
echo " not rebuilt in the distro, adding"
|
||
|
fi
|
||
|
|
||
|
if $PACKAGE_REBUILT_UP_TO_DATE ; then
|
||
|
cat ${0%translation-update-upstream-to-translation-update.sh}upstream-collect.domain-map |
|
||
|
while read PACKAGE_ REAL_DOMAIN STATUS ; do
|
||
|
if test "$PACKAGE" = "$PACKAGE_" ; then
|
||
|
case $STATUS in
|
||
|
OK*)
|
||
|
echo " domain $REAL_DOMAIN is correctly updated, OK"
|
||
|
if test -d TRANSLATION_UPDATE/TUU/po/$REAL_DOMAIN ; then
|
||
|
mv TRANSLATION_UPDATE/TUU/po/$REAL_DOMAIN TRANSLATION_UPDATE/UPDATED/po/
|
||
|
fi
|
||
|
if test -d TRANSLATION_UPDATE/TUU/po-mandatory/$REAL_DOMAIN ; then
|
||
|
mv TRANSLATION_UPDATE/TUU/po-mandatory/$REAL_DOMAIN TRANSLATION_UPDATE/UPDATED/po-mandatory/
|
||
|
fi
|
||
|
;;
|
||
|
*)
|
||
|
echo " domain $REAL_DOMAIN is not correctly updated, needs to be added"
|
||
|
if test -d TRANSLATION_UPDATE/TUU/po/$REAL_DOMAIN ; then
|
||
|
mv TRANSLATION_UPDATE/TUU/po/$REAL_DOMAIN TRANSLATION_UPDATE/NOT_UPDATED/po/
|
||
|
fi
|
||
|
if test -d TRANSLATION_UPDATE/TUU/po-mandatory/$REAL_DOMAIN ; then
|
||
|
mv TRANSLATION_UPDATE/TUU/po-mandatory/$REAL_DOMAIN TRANSLATION_UPDATE/NOT_UPDATED/po-mandatory/
|
||
|
fi
|
||
|
;;
|
||
|
esac
|
||
|
fi
|
||
|
done
|
||
|
else
|
||
|
cat ${0%translation-update-upstream-to-translation-update.sh}upstream-collect.domain-map |
|
||
|
while read PACKAGE_ REAL_DOMAIN STATUS ; do
|
||
|
if test "$PACKAGE" = "$PACKAGE_" ; then
|
||
|
if test -d TRANSLATION_UPDATE/TUU/po/$REAL_DOMAIN ; then
|
||
|
mv TRANSLATION_UPDATE/TUU/po/$REAL_DOMAIN TRANSLATION_UPDATE/NOT_UPDATED/po/
|
||
|
fi
|
||
|
if test -d TRANSLATION_UPDATE/TUU/po-mandatory/$REAL_DOMAIN ; then
|
||
|
mv TRANSLATION_UPDATE/TUU/po-mandatory/$REAL_DOMAIN TRANSLATION_UPDATE/NOT_UPDATED/po-mandatory/
|
||
|
fi
|
||
|
fi
|
||
|
done
|
||
|
fi
|
||
|
echo
|
||
|
done
|
||
|
done
|
||
|
|
||
|
# If files remain in TUU, there is something wrong. Move them to NOT_UPDATED and hope that domain is correct.
|
||
|
# It can happen when domain mapping process failed.
|
||
|
cd TRANSLATION_UPDATE/TUU
|
||
|
for DIR in */* ; do
|
||
|
if test "${DIR%/*}" = "po" ; then
|
||
|
MANDATORY=false
|
||
|
else
|
||
|
MANDATORY=true
|
||
|
fi
|
||
|
echo "$(tput setf 4)Something went wrong, domain=${DIR#*/} mandatory=$MANDATORY was not listed and processed$(tput init)"
|
||
|
echo " assuming that it was not updated"
|
||
|
mv $DIR ../NOT_UPDATED/$DIR
|
||
|
done
|
||
|
|
||
|
cd ../../TRANSLATION_UPDATE/NOT_UPDATED/po
|
||
|
for PO in */*.po ; do
|
||
|
LNG=${PO##*/}
|
||
|
LNG=${LNG%.po}
|
||
|
mkdir -p "../../complete/translation-update/${PO%/*}/$LNG"
|
||
|
if test -f "../po-mandatory/$PO" ; then
|
||
|
msgcat --use-first "../po-mandatory/$PO" "$PO" -o "../../complete/translation-update/${PO%/*}/$LNG/${PO##*/}"
|
||
|
else
|
||
|
ln "$PO" "../../complete/translation-update/${PO%/*}/$LNG/${PO##*/}"
|
||
|
fi
|
||
|
|
||
|
# Standard update: Pick only files with changes.
|
||
|
if grep -q "^po/$PO\$" ../../../${0%.sh}-updates.lst ; then
|
||
|
mkdir -p "../../translation-update/${PO%/*}/$LNG"
|
||
|
ln "../../complete/translation-update/${PO%/*}/$LNG/${PO##*/}" "../../translation-update/${PO%/*}/$LNG/${PO##*/}"
|
||
|
fi
|
||
|
done
|
||
|
cd ../po-mandatory
|
||
|
for PO in */*.po ; do
|
||
|
LNG=${PO##*/}
|
||
|
LNG=${LNG%.po}
|
||
|
# Mandatory update: Pick all files.
|
||
|
if ! test -f "../../complete/translation-update/${PO%/*}/$LNG/${PO##*/}" ; then
|
||
|
mkdir -p "../../complete/translation-update/${PO%/*}/$LNG"
|
||
|
ln "$PO" "../../complete/translation-update/${PO%/*}/$LNG/${PO##*/}"
|
||
|
fi
|
||
|
if ! test -f "../../translation-update/${PO%/*}/$LNG/${PO##*/}" ; then
|
||
|
mkdir -p "../../translation-update/${PO%/*}/$LNG"
|
||
|
ln "../../complete/translation-update/${PO%/*}/$LNG/${PO##*/}" "../../translation-update/${PO%/*}/$LNG/${PO##*/}"
|
||
|
fi
|
||
|
done
|
||
|
cd ../../../TRANSLATION_UPDATE/UPDATED/po
|
||
|
for PO in */*.po ; do
|
||
|
LNG=${PO##*/}
|
||
|
LNG=${LNG%.po}
|
||
|
mkdir -p "../../complete/translation-update/${PO%/*}/$LNG"
|
||
|
if test -f "../po-mandatory/$PO" ; then
|
||
|
msgcat --use-first "../po-mandatory/$PO" "$PO" -o "../../complete/translation-update/${PO%/*}/$LNG/${PO##*/}"
|
||
|
else
|
||
|
ln "$PO" "../../complete/translation-update/${PO%/*}/$LNG/${PO##*/}"
|
||
|
fi
|
||
|
|
||
|
# Standard update: Pick only files with changes.
|
||
|
if grep -q "^po/$PO\$" ../../../${0%.sh}-updates.lst ; then
|
||
|
mkdir -p "../../rebuilt/translation-update/${PO%/*}/$LNG"
|
||
|
ln "../../complete/translation-update/${PO%/*}/$LNG/${PO##*/}" "../../rebuilt/translation-update/${PO%/*}/$LNG/${PO##*/}"
|
||
|
fi
|
||
|
done
|
||
|
cd ../po-mandatory
|
||
|
for PO in */*.po ; do
|
||
|
LNG=${PO##*/}
|
||
|
LNG=${LNG%.po}
|
||
|
# Mandatory update: Pick all files.
|
||
|
if ! test -f "../../complete/translation-update/${PO%/*}/$LNG/${PO##*/}" ; then
|
||
|
mkdir -p "../../complete/translation-update/${PO%/*}/$LNG"
|
||
|
ln "$PO" "../../complete/translation-update/${PO%/*}/$LNG/${PO##*/}"
|
||
|
fi
|
||
|
if ! test -f "../../rebuilt/translation-update/${PO%/*}/$LNG/${PO##*/}" ; then
|
||
|
mkdir -p "../../rebuilt/translation-update/${PO%/*}/$LNG"
|
||
|
ln "../../complete/translation-update/${PO%/*}/$LNG/${PO##*/}" "../../rebuilt/translation-update/${PO%/*}/$LNG/${PO##*/}"
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
cd ../..
|
||
|
tar -jcf ../translation-update-from-translation-update-upstream-$SNAPSHOT.tar.bz2 translation-update
|
||
|
echo "Generated translation-update-from-translation-update-upstream-$SNAPSHOT.tar.bz2
|
||
|
Please add it to the package translation-update"
|
||
|
cd rebuilt
|
||
|
tar -jcf ../../translation-update-from-translation-update-upstream-rebuilt-$SNAPSHOT.tar.bz2 translation-update
|
||
|
echo "Generated translation-update-from-translation-update-upstream-rebuilt-$SNAPSHOT.tar.bz2
|
||
|
It contains translations that that should be provided in build time by translation-update-upstream,
|
||
|
but if translation-update-upstream was not updated to the latest version, then you may want to include
|
||
|
these translations to translation-update as well."
|
||
|
cd ../complete
|
||
|
tar -jcf ../../translation-update-from-translation-update-upstream-complete-$SNAPSHOT.tar.bz2 translation-update
|
||
|
echo "Generated translation-update-from-translation-update-upstream-complete-$SNAPSHOT.tar.bz2
|
||
|
This file includes all avaliable translations."
|
||
|
cd ../..
|
||
|
rm -r TRANSLATION_UPDATE
|