81 lines
1.9 KiB
Bash
Executable file
81 lines
1.9 KiB
Bash
Executable file
#!/bin/bash
|
|
# Copyright (c) 2019 Danh Doan
|
|
# All rights reserved.
|
|
#
|
|
# Permission to use, copy, modify, and/or distribute this software for any
|
|
# purpose with or without fee is hereby granted.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
# PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
version=$1
|
|
|
|
esr=""
|
|
[[ $version =~ esr$ ]] && esr="-esr"
|
|
|
|
tmpldir="firefox${esr}-i18n"
|
|
|
|
tmpoldfile="$(mktemp)"
|
|
tmpnewfile="$(mktemp)"
|
|
|
|
xoldlangexpr="^_languages="
|
|
|
|
xlistold() {
|
|
source "${tmpldir}/template"
|
|
for _lang in "${_languages[@]}"; do
|
|
_locale="${_lang%%\"*}"
|
|
[ $_locale ] && echo "$_locale"
|
|
done
|
|
}
|
|
|
|
xlink () {
|
|
ln -sf "$tmpldir" "$tmpldir-$1"
|
|
}
|
|
|
|
xnewlang () {
|
|
lang=$1
|
|
padded=$(printf '%-7s' $lang)
|
|
xoldexpr=$xoldlangexpr
|
|
xoldlangexpr="'$lang \+\""
|
|
grep -q "'$lang \+\"" "$tmpldir/template" && return 0
|
|
sed -i "/$xoldexpr/a\\
|
|
'$padded\"Unknown\"'
|
|
/checksum=/a\\
|
|
badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb" \
|
|
"$tmpldir/template"
|
|
}
|
|
|
|
xprocessnew() {
|
|
while read lang; do
|
|
printf '%-7s\n' $lang >&3
|
|
xlink $lang
|
|
xnewlang $lang
|
|
done
|
|
}
|
|
|
|
xcleanlang() {
|
|
while read lang; do
|
|
padded=$(printf '%-7s' $lang)
|
|
sed -i "/'$padded\"/d" $tmpldir/template
|
|
unlink "$tmpldir-$lang" || true
|
|
done
|
|
}
|
|
|
|
cd $(xdistdir)/srcpkgs
|
|
|
|
xlistold >| "$tmpoldfile"
|
|
|
|
curl "https://ftp.mozilla.org/pub/firefox/releases/$1/linux-i686/xpi/" \
|
|
| grep -o 'xpi/[a-z]\+\(-[A-Z]\+\)\?' \
|
|
| cut -d/ -f2 \
|
|
| xprocessnew 3>$tmpnewfile
|
|
|
|
grep -vF -f $tmpnewfile $tmpoldfile \
|
|
| xcleanlang
|
|
|
|
rm -rf $tmpoldfile $tmpnewfile
|