updatelanglist.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/bash
  2. # helper script to check the local language list against upstream
  3. export CARCH="${CARCH:-$(uname -m)}"
  4. # extract pkgbase from pkgbuild
  5. pkgbase="$(bash -c "source PKGBUILD && echo \"\$_pkgbase\"")"
  6. pkgver="$(bash -c "source PKGBUILD && echo \"\$pkgver\"")"
  7. echo "attempting update to language lists for $pkgbase"
  8. echo " CARCH: $CARCH"
  9. # produce new language list
  10. #url="$(bash -c "source PKGBUILD && echo \"\$_src_url\"")/"
  11. url="https://ftp.mozilla.org/pub/firefox/releases/${pkgver%_*}esr/linux-x86_64/xpi/"
  12. echo "_languages=(" > "languages.$CARCH.pkgnew"
  13. echo "_sha512sums=(" > "sha512sums.$CARCH.pkgnew"
  14. mkdir -p src
  15. for lang in $(curl -sL "$url" | grep '\.xpi' | cut -d'"' -f2 | rev | cut -d'/' -f1 | cut -d'.' -f2 | rev | sort); do
  16. #for lang in $(curl -sL "$url" | grep '\.xpi"' | cut -d'"' -f8 | rev | cut -d'/' -f1 | cut -d'.' -f3 | rev | sort); do
  17. # # filter unwanted packs
  18. # case "$lang" in
  19. # compare-locales|ja-JP-mac) continue ;;
  20. # esac
  21. printf "\r %-3s..." "${lang%%-*}"
  22. # curl -s -o src/"$lang.xpi" "${url%/}/icecat-${pkgver%_*}.$lang.langpack.xpi"
  23. curl -s -o src/"$lang.xpi" "${url%/}/$lang.xpi"
  24. # sha512sum="$(sha512sum "icecat-${pkgver%_*}.$lang.langpack.xpi" | cut -d' ' -f1)" # FIXME: normal releases - gnuzilla lang-packs
  25. sha512sum="$(sha512sum "src/$lang.xpi" | cut -d' ' -f1)" # FIXME: pre-release - no gnuzilla lang-packs
  26. name="$(unzip -p "src/$lang.xpi" manifest.json | grep " \"name" | cut -d':' -f2- | cut -d'"' -f2)"
  27. printf " '%-5s \"%s\"'\n" "$lang" "$name" \
  28. >> "languages.$CARCH.pkgnew"
  29. printf " '%s'\n" "$sha512sum" \
  30. >> "sha512sums.$CARCH.pkgnew"
  31. done
  32. echo
  33. echo ")" >> "languages.$CARCH.pkgnew"
  34. echo ")" >> "sha512sums.$CARCH.pkgnew"
  35. admsq() {
  36. if cmp "$1"{,.pkgnew} > /dev/null; then
  37. echo "$1 unchanged"
  38. rm -f "$1.pkgnew"
  39. else
  40. diff -rupN "$1"{,.pkgnew}
  41. while true; do
  42. read -n1 -p "[a]pply, [d]elete, [m]erge, [s]kip, [q]uit " x
  43. echo
  44. case $x in
  45. a) mv "$1"{.pkgnew,}
  46. break
  47. ;;
  48. d) rm -f "$1".pkgnew
  49. break
  50. ;;
  51. m) vimdiff "$1"{,.pkgnew}
  52. rm "$1".pkgnew
  53. break
  54. ;;
  55. s) break
  56. ;;
  57. q) exit
  58. ;;
  59. *) ;;
  60. esac
  61. done
  62. fi
  63. }
  64. # compare and update
  65. admsq "languages.$CARCH"
  66. admsq "sha512sums.$CARCH"
  67. # update PKGBUILD checksums
  68. _languages_shasum="$(sha512sum "languages.$CARCH" | cut -d' ' -f1)"
  69. _sha512sums_shasum="$(sha512sum "sha512sums.$CARCH" | cut -d' ' -f1)"
  70. sed -e "s/^_languages_${CARCH}_shasum=.*/_languages_${CARCH}_shasum=\"${_languages_shasum}\"/" \
  71. -e "s/^_sha512sums_${CARCH}_shasum=.*/_sha512sums_${CARCH}_shasum=\"${_sha512sums_shasum}\"/" \
  72. PKGBUILD > PKGBUILD.pkgnew
  73. admsq "PKGBUILD"