File: update_pot_file.sh

package info (click to toggle)
iso-codes 4.20.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,044 kB
  • sloc: python: 626; sed: 137; sh: 65; makefile: 2
file content (33 lines) | stat: -rwxr-xr-x 854 bytes parent folder | download
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
#!/bin/sh

# SPDX-FileCopyrightText: 2025 Dr. Tobias Quathamer <toddy@debian.org>
#
# SPDX-License-Identifier: LGPL-2.1-or-later

set -e

update_pot_file() {
    domain=$1
    pot_file="$domain/$domain.pot"

    backup=$(mktemp)
    cp "$pot_file" "$backup"

    python3 ./scripts/pot_from_json.py "$domain" .

    sed -f ./scripts/remove-potcdate.sin < "$pot_file" > "$domain".1po
    sed -f ./scripts/remove-potcdate.sin < "$backup" > "$domain".2po

    if cmp "$domain".1po "$domain".2po > /dev/null 2>&1; then
        rm -f "$domain".1po "$domain".2po "$pot_file"
        mv "$backup" "$pot_file"
    else
        rm -f "$domain".1po "$domain".2po "$backup"
    fi
}

DOMAINS=$(find . -maxdepth 1 -iname "iso_*" -type d | LC_ALL=C sort | xargs -n1 basename)
for domain in $DOMAINS; do
    echo "Processing $domain"
    update_pot_file "$domain"
done