aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAlexis Hildebrandt2012-09-03 19:02:25 -0700
committerMike McQuaid2012-09-03 19:02:30 -0700
commitac2b4a1a13316dec469e116bc718d0cbebdbb3f2 (patch)
tree9b18137057b3bfeceaae9a2d3bdb1ce210a0eb68 /Library
parentbf6ae3235de1945588f359bd46d9ef03a2164e10 (diff)
downloadhomebrew-ac2b4a1a13316dec469e116bc718d0cbebdbb3f2.tar.bz2
brew-aspell-dictionaries - generate aspell formulae
This script fetches the current list of aspell dictionaries from the gnu server and generates formulae that can then be included into the aspell formula. This makes updating current dictionaries and adding new ones easier. Tweaked by Mike to generate SHA1s instead of MD5s. Closes #12180. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Contributions/cmds/brew-aspell-dictionaries49
1 files changed, 49 insertions, 0 deletions
diff --git a/Library/Contributions/cmds/brew-aspell-dictionaries b/Library/Contributions/cmds/brew-aspell-dictionaries
new file mode 100755
index 000000000..b07e1a5e4
--- /dev/null
+++ b/Library/Contributions/cmds/brew-aspell-dictionaries
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# brew-aspell-dictionaries - update aspell formula to include latest dictionaries
+# This script fetches the current index for the aspell dictionaries gnu server,
+# it parses the html to retrieve the URL to the dictionary archive for each
+# available language.
+# The script then calculates the sha1 for each dictionary archive and
+# generates a brew formula for each language.
+# The result can then to be merged into the aspell formula, to update
+# the available dictionary formulae.
+
+dictionaries_url=http://ftp.gnu.org/gnu/aspell/dict
+tmp_file=`mktemp -t brew_aspell_dictionaries`
+brew_formulae_tmp_file=`mktemp -t brew_aspell_dictionaries_formulae`
+
+echo "Downloading aspell dictionaries Index"
+curl -s ${dictionaries_url}/0index.html \
+ | egrep '^(<tr><td><a|</table)' \
+ | cut -d\" -f2,4 \
+ > $tmp_file
+
+echo "# BEGIN generated with `basename $0`" > $brew_formulae_tmp_file
+langs=""
+for dict in `cat $tmp_file`; do
+ [ "${dict}" = "</table>" ] && break # only read the entries in the first table, which lists the dictionaries for aspell 0.60
+ lang=`echo $dict | awk -F\" '{ gsub("-", "_", $1); print $1 }'`
+ url="${dictionaries_url}/"`echo $dict | awk -F\" '{ print $2 }'`
+ langs="${langs} ${lang}"
+ echo "Calculating sha1 for formula: ${lang}"
+ sha1=`curl -s "${url}" | shasum | awk '{print $1}'`
+ cat <<EOF >> $brew_formulae_tmp_file
+class Aspell_${lang} < AspellLang
+ url '${url}'
+ sha1 '${sha1}'
+end
+EOF
+done
+
+cat <<EOF >> $brew_formulae_tmp_file
+def available_languages
+ %w(${langs})
+end
+# END generated with `basename $0`
+EOF
+
+rm $tmp_file
+
+echo "The formulae for the aspell dictionaries have been written to\n$brew_formulae_tmp_file"
+