updatelanglist.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. echo "_languages=(" > "languages.$CARCH.pkgnew"
  12. echo "_sha512sums=(" > "sha512sums.$CARCH.pkgnew"
  13. mkdir -p src
  14. for lang in $(curl -sL "$url" | grep '\.xpi"' | cut -d'"' -f2 | rev | cut -d'/' -f1 | cut -d'.' -f3 | rev | sort); do
  15. printf "\r %-3s..." "${lang%%-*}"
  16. curl -s -o src/"$lang.xpi" "${url%/}/seamonkey-${pkgver%_*}.$lang.langpack.xpi"
  17. sha512sum="$(sha512sum "src/$lang.xpi" | cut -d' ' -f1)"
  18. name="$(unzip -p "src/$lang.xpi" install.rdf | grep " em:name=\"" | cut -d'"' -f2)"
  19. printf " '%-5s \"%s\"'\n" "$lang" "$name" \
  20. >> "languages.$CARCH.pkgnew"
  21. printf " '%s'\n" "$sha512sum" \
  22. >> "sha512sums.$CARCH.pkgnew"
  23. done
  24. echo
  25. echo ")" >> "languages.$CARCH.pkgnew"
  26. echo ")" >> "sha512sums.$CARCH.pkgnew"
  27. admsq() {
  28. if cmp "$1"{,.pkgnew} > /dev/null; then
  29. echo "$1 unchanged"
  30. rm -f "$1.pkgnew"
  31. else
  32. diff -rupN "$1"{,.pkgnew}
  33. while true; do
  34. read -n1 -p "[a]pply, [d]elete, [m]erge, [s]kip, [q]uit " x
  35. echo
  36. case $x in
  37. a) mv "$1"{.pkgnew,}
  38. break
  39. ;;
  40. d) rm -f "$1".pkgnew
  41. break
  42. ;;
  43. m) vimdiff "$1"{,.pkgnew}
  44. rm "$1".pkgnew
  45. break
  46. ;;
  47. s) break
  48. ;;
  49. q) exit
  50. ;;
  51. *) ;;
  52. esac
  53. done
  54. fi
  55. }
  56. # compare and update
  57. admsq "languages.$CARCH"
  58. admsq "sha512sums.$CARCH"
  59. # update PKGBUILD checksums
  60. _languages_shasum="$(sha512sum "languages.$CARCH" | cut -d' ' -f1)"
  61. _sha512sums_shasum="$(sha512sum "sha512sums.$CARCH" | cut -d' ' -f1)"
  62. sed -e "s/^_languages_${CARCH}_shasum=.*/_languages_${CARCH}_shasum=\"${_languages_shasum}\"/" \
  63. -e "s/^_sha512sums_${CARCH}_shasum=.*/_sha512sums_${CARCH}_shasum=\"${_sha512sums_shasum}\"/" \
  64. PKGBUILD > PKGBUILD.pkgnew
  65. admsq "PKGBUILD"