biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / graphics / tesseract / fetch-language-hashes
blobb8aedcfbd9c059e80d27dbc247d7119bcd1d219d
1 #!/usr/bin/env bash
3 # Usage:
4 # ./fetch-language-hashes <tessdataRev> [<language code>…]
6 # Fetches all languages if no language codes are given.
8 # Example:
9 # ./fetch-language-hashes 4.0.0 eng spa
11 # Output:
12 # eng = "0iy0...";
13 # spa = "15kw...";
15 set -e
17 (( $# >= 1 )) || exit 1
18 tessdataRev=$1
19 shift
21 if (( $# > 0 )); then
22 langCodes="$@"
23 else
24 repoPage=$(curl -fs https://github.com/tesseract-ocr/tessdata/tree/$tessdataRev || {
25 >&2 echo "Invalid tessdataRev: $tessdataRev"
26 exit 1
28 langCodes=$(echo $(echo "$repoPage" | grep -ohP "(?<=/)[^/ ]+?(?=\.traineddata)" | sort -u))
31 for lang in $langCodes; do
32 url=https://github.com/tesseract-ocr/tessdata/raw/$tessdataRev/$lang.traineddata
33 hash=$(nix hash to-sri --type sha256 $(nix-prefetch-url $url 2>/dev/null))
34 echo "$lang = \"$hash\";"
35 done