-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
release.sh
88 lines (79 loc) · 2.76 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
set -u
WD=$(pwd)
APP=kcm-grub2
VERSION="0.6.4"
MODULE=extragear
SUBMODULE=sysadmin
THRESHOLD=75
echo "== Start =="
echo
echo "== Fetching ${APP} source... =="
git clone -l ${WD} ${APP}
rm -rf ${WD}/${APP}/.git
rm ${WD}/${APP}/format_sources
rm ${WD}/${APP}/Messages.sh
rm ${WD}/${APP}/release.sh
echo
echo "== Patching ${APP} CMakeLists.txt... =="
echo "find_package( Msgfmt REQUIRED )" >> ${WD}/${APP}/CMakeLists.txt
echo "find_package( Gettext REQUIRED )" >> ${WD}/${APP}/CMakeLists.txt
echo "add_subdirectory( po )" >> ${WD}/${APP}/CMakeLists.txt
echo
echo "== Fetching translations which are >=${THRESHOLD}% complete... =="
for lang in $(svn cat svn://anonsvn.kde.org/home/kde/trunk/l10n-kde4/subdirs); do
test "${lang}" == "x-test" && continue
echo
echo "-- ${lang} --"
unset TRANS
unset FUZZY
unset UNTRANS
mkdir -p ${WD}/${APP}/po/${lang}
cd ${WD}/${APP}/po/${lang}
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
if test "$?" -ne "0"; then
echo " No po file found."
rm -r ${WD}/${APP}/po/${lang}
continue
fi
STAT_STR=$(msgfmt --check --statistics -o /dev/null 2>&1 ${WD}/${APP}/po/${lang}/${APP}.po)
TRANS=$(echo ${STAT_STR}| awk '{print $1}')
if test "untranslated" == "$(echo ${STAT_STR}| awk '{print $5}')"; then
UNTRANS=$(echo ${STAT_STR}| awk '{print $4}')
else
if test "fuzzy" == "$(echo ${STAT_STR}| awk '{print $5}')"; then
FUZZY=$(echo ${STAT_STR}| awk '{print $4}')
fi
if test "untranslated" == "$(echo ${STAT_STR}| awk '{print $8}')"; then
UNTRANS=$(echo ${STAT_STR}| awk '{print $7}')
fi
fi
TRANS=${TRANS:-0}
FUZZY=${FUZZY:-0}
UNTRANS=${UNTRANS:-0}
TOTAL=$[${TRANS}+${FUZZY}+${UNTRANS}]
PERCENT=$[$[${TRANS}*100]/${TOTAL}]
if test "${PERCENT}" -ge "${THRESHOLD}"; then
echo " Included (${PERCENT}%)."
echo "file( GLOB _po_files *.po )" >> ${WD}/${APP}/po/${lang}/CMakeLists.txt
echo "GETTEXT_PROCESS_PO_FILES( ${lang} ALL INSTALL_DESTINATION \${LOCALE_INSTALL_DIR} \${_po_files} )" >> ${WD}/${APP}/po/${lang}/CMakeLists.txt
echo "add_subdirectory( ${lang} )" >> ${WD}/${APP}/po/CMakeLists.txt
LANGS+=" ${lang}"
else
echo " Not included (${PERCENT}%)."
rm -r ${WD}/${APP}/po/${lang}
fi
done
echo
echo "Languages included in the release:"
echo ${LANGS}
echo
echo "== Renaming ${WD}/${APP} to ${WD}/${APP}-${VERSION}... =="
mv ${WD}/${APP} ${WD}/${APP}-${VERSION}
echo
echo "== Creating tarball ${WD}/${APP}-${VERSION}.tar.gz... =="
cd ${WD}
tar czvf ${APP}-${VERSION}.tar.gz ${APP}-${VERSION}
rm -rf ${APP}-${VERSION}
echo
echo "== Finished =="