Created
October 13, 2012 18:18
-
-
Save notogawa/3885639 to your computer and use it in GitHub Desktop.
Gentoo hoogle offline DB builder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# emerge -vp hoogle の後,hoogle-build-localdbを走らせろと言われるが, | |
# それを無視してコッチのスクリプトを走らせるとローカルにインストールしたパッケージのhaddock等を参照するhoogle DBが作られる. | |
# そのままで hoogle server すると file:/// とローカルドキュメントへのファイルURLが検索結果に出るようになる. | |
# また, hoogle server -l すると http://localhost:port/file//usr/share/doc のような,hoogle serverがstatic fileとして処理ってくれるURLになって, | |
# Haskell環境はVMの中(でホストからputty等で接続してるだけ)だけどブラウザはホストから使いたいようなケースでもOKになる. | |
# | |
ROOT="/" | |
if [ ! -d "${ROOT}var/lib/hoogle/databases" ] | |
then | |
mkdir -p "${ROOT}var/lib/hoogle/databases" | |
fi | |
pushd "${ROOT}var/lib/hoogle/databases" | |
for TXT in $(find $(grep haddock-html $(find $(ghc-pkg list --global | head -n 1 | sed 's/:$//') -type f) | sed 's/.*haddock-html://;s/^[[:space:]]//;/^$/d') -name "*.txt" 2>/dev/null) | |
do | |
SRC=$(basename $TXT) | |
HOO=${SRC/.txt/.hoo} | |
( | |
awk '/^@package/ {exit}; {print}' $TXT; | |
echo "@url file://$(dirname $TXT)/" | |
awk '/^@package/ {x=1}; {if (x == 1) print;}' $TXT | |
) > $SRC | |
hoogle convert $SRC $HOO | |
done | |
rm default.hoo | |
hoogle combine -o=default.hoo $(ls *.hoo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment