File indexing completed on 2021-12-21 14:31:22

0001 #!/bin/sh
0002 set -u
0003 
0004 WD=$(pwd)
0005 APP=kcm-grub2
0006 VERSION="0.6.4"
0007 MODULE=extragear
0008 SUBMODULE=sysadmin
0009 THRESHOLD=75
0010 
0011 echo "== Start =="
0012 echo
0013 echo "== Fetching ${APP} source... =="
0014 git clone -l ${WD} ${APP}
0015 rm -rf ${WD}/${APP}/.git
0016 rm ${WD}/${APP}/format_sources
0017 rm ${WD}/${APP}/Messages.sh
0018 rm ${WD}/${APP}/release.sh
0019 
0020 echo
0021 echo "== Patching ${APP} CMakeLists.txt... =="
0022 echo "find_package( Msgfmt REQUIRED )" >> ${WD}/${APP}/CMakeLists.txt
0023 echo "find_package( Gettext REQUIRED )" >> ${WD}/${APP}/CMakeLists.txt
0024 echo "add_subdirectory( po )" >> ${WD}/${APP}/CMakeLists.txt
0025 
0026 echo
0027 echo "== Fetching translations which are >=${THRESHOLD}% complete... =="
0028 for lang in $(svn cat svn://anonsvn.kde.org/home/kde/trunk/l10n-kde4/subdirs); do
0029     test "${lang}" == "x-test" && continue
0030     echo
0031     echo "-- ${lang} --"
0032 
0033     unset TRANS
0034     unset FUZZY
0035     unset UNTRANS
0036     mkdir -p ${WD}/${APP}/po/${lang}
0037     cd ${WD}/${APP}/po/${lang}
0038     svn cat svn://anonsvn.kde.org/home/kde/trunk/l10n-kde4/${lang}/messages/${MODULE}-${SUBMODULE}/${APP}.po >${WD}/${APP}/po/${lang}/${APP}.po 2>/dev/null
0039     if test "$?" -ne "0"; then
0040         echo "  No po file found."
0041         rm -r ${WD}/${APP}/po/${lang}
0042         continue
0043     fi
0044     STAT_STR=$(msgfmt --check --statistics -o /dev/null 2>&1 ${WD}/${APP}/po/${lang}/${APP}.po)
0045     TRANS=$(echo ${STAT_STR}| awk '{print $1}')
0046     if test "untranslated" == "$(echo ${STAT_STR}| awk '{print $5}')"; then
0047         UNTRANS=$(echo ${STAT_STR}| awk '{print $4}')
0048     else
0049         if test "fuzzy" == "$(echo ${STAT_STR}| awk '{print $5}')"; then
0050             FUZZY=$(echo ${STAT_STR}| awk '{print $4}')
0051         fi
0052         if test "untranslated" == "$(echo ${STAT_STR}| awk '{print $8}')"; then
0053             UNTRANS=$(echo ${STAT_STR}| awk '{print $7}')
0054         fi
0055     fi
0056     TRANS=${TRANS:-0}
0057     FUZZY=${FUZZY:-0}
0058     UNTRANS=${UNTRANS:-0}
0059 
0060     TOTAL=$[${TRANS}+${FUZZY}+${UNTRANS}]
0061     PERCENT=$[$[${TRANS}*100]/${TOTAL}]
0062     if test "${PERCENT}" -ge "${THRESHOLD}"; then
0063         echo "  Included (${PERCENT}%)."
0064         echo "file( GLOB _po_files *.po )" >> ${WD}/${APP}/po/${lang}/CMakeLists.txt
0065         echo "GETTEXT_PROCESS_PO_FILES( ${lang} ALL INSTALL_DESTINATION \${LOCALE_INSTALL_DIR} \${_po_files} )" >> ${WD}/${APP}/po/${lang}/CMakeLists.txt
0066         echo "add_subdirectory( ${lang} )" >> ${WD}/${APP}/po/CMakeLists.txt
0067         LANGS+=" ${lang}"
0068     else
0069         echo "  Not included (${PERCENT}%)."
0070         rm -r ${WD}/${APP}/po/${lang}
0071     fi
0072 done
0073 
0074 echo
0075 echo "Languages included in the release:"
0076 echo ${LANGS}
0077 
0078 echo
0079 echo "== Renaming ${WD}/${APP} to ${WD}/${APP}-${VERSION}... =="
0080 mv ${WD}/${APP} ${WD}/${APP}-${VERSION}
0081 echo
0082 echo "== Creating tarball ${WD}/${APP}-${VERSION}.tar.gz... =="
0083 cd ${WD}
0084 tar czvf ${APP}-${VERSION}.tar.gz ${APP}-${VERSION}
0085 rm -rf ${APP}-${VERSION}
0086 
0087 echo
0088 echo "== Finished =="