github.com/hugh712/snapd@v0.0.0-20200910133618-1a99902bd583/update-pot (about) 1 #!/bin/sh 2 # -*- Mode: sh; indent-tabs-mode: t -*- 3 4 set -e 5 6 # In LP#1758684 we got reports that the pot file generation 7 # is broken. To get to the bottom of this add checks here 8 # so that we error the build if this happens. Note that the 9 # strings may be update if those change but spread tests will 10 # tell us when it is needed. 11 check_canaries() { 12 c1="Alternative command to run" 13 c2="Name of the key to use, otherwise use the default key" 14 c3="too many arguments for command" 15 16 for canary in "$c1" "$c2" "$c3"; do 17 if ! grep -q "$canary" "$OUTPUT"; then 18 echo "canary '$canary' not found, pot extraction broken" 19 ls -lh "$OUTPUT" 20 exit 1 21 fi 22 done 23 } 24 25 HERE="$(readlink -f "$(dirname "$0")")" 26 27 OUTPUT="$HERE/po/snappy.pot" 28 if [ -n "$1" ]; then 29 OUTPUT="$1" 30 fi 31 32 # ensure we have our xgettext-go 33 go install github.com/snapcore/snapd/i18n/xgettext-go 34 35 # exclude vendor and _build subdir 36 I18N_FILES="$(mktemp -d)/i18n.files" 37 find "$HERE" -type d \( -name "vendor" -o -name "_build" \) -prune -o -name "*.go" -type f -print > "$I18N_FILES" 38 # shellcheck disable=SC2064 39 trap "rm -rf $(dirname "$I18N_FILES")" EXIT 40 41 "${GOPATH%%:*}/bin/xgettext-go" \ 42 -f "$I18N_FILES" \ 43 -o "$OUTPUT" \ 44 --add-comments-tag=TRANSLATORS: \ 45 --no-location \ 46 --sort-output \ 47 --package-name=snappy\ 48 --msgid-bugs-address=snappy-devel@lists.ubuntu.com \ 49 --keyword=i18n.G \ 50 --keyword-plural=i18n.DG 51 52 # check canary 53 check_canaries 54 55 sed -i 's/charset=CHARSET/charset=UTF-8/' "$OUTPUT" 56 57 # we need the || true because of 58 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=891347 59 xgettext "$HERE"/data/polkit/*.policy \ 60 -o "$OUTPUT" \ 61 --its="$HERE/po/its/polkit.its" \ 62 --no-location \ 63 --package-name=snappy \ 64 --msgid-bugs-address=snappy-devel@lists.ubuntu.com \ 65 --join-existing || true 66 67 check_canaries 68 69 # language packs 70 for p in "${HERE}"/po/*.po; do 71 lang=$(basename "$p" .po) 72 mkdir -p "$HERE/share/locale/$lang/LC_MESSAGES" 73 msgfmt -v -o "$HERE/share/locale/$lang/LC_MESSAGES/snappy.mo" "$p" 74 done