#!/bin/sh # refresh-locale-codes -- Refresh the locale (aka ISO 639-1/639-2 codes) # Copyright (C) 2010 Raphael Geissert # # This file is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This file is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this file. If not, see . set -e if [ -z "$1" ]; then printf "Usage: %s \n" "$(basename "$0")" cat < must be the path to the root of the Lintian data directory to update. This script requires the isoquery package to be installed. INFO exit fi readonly lintian_data="$(readlink -f "$1")" [ -d "$lintian_data" ] || { printf "%s is not a directory, aborting" "$lintian_data" >&2 exit 1 } readonly tmpfile="$(mktemp)" cleanup () { [ ! -f "$tmpfile" ] || unlink "$tmpfile" }; trap cleanup EXIT mkdir -p "$lintian_data/files" cat > "$tmpfile" <) { next unless m/^\w{3}\s+(\w{3})\s+(?:(\w{2})\s+)?/; ($iso1, $iso2) = ($2, $1); if (!defined($iso1)) { $iso1 = $iso2; $iso2 = undef; } $iso1 = lc $iso1; $codes{$iso1} = undef unless (exists $codes{$iso1}); if (defined $iso2) { $codes{lc $iso2} = $iso1; } } while (my ($a, $b) = each %codes) { print $a.(defined($b)? " $b" : "")."\n"; } ' | sort -u >> "$tmpfile" mv "$tmpfile" "$lintian_data/files/locale-codes" # Local Variables: # indent-tabs-mode: nil # End: # vim: syntax=sh sw=4 sts=4 sr et