-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpost_compile
40 lines (35 loc) · 1.37 KB
/
post_compile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
set -e
buildpack_url=https://github.com/heroku/heroku-buildpack-python
buildpack_vsn=v210
# rebuild python if it's missing loadable sqlite extensions
if ! python3 -msysconfig | grep enable-loadable-sqlite-extensions \
> /dev/null; then
PYTHON_VERSION="$(< runtime.txt)"
git clone -b "$buildpack_vsn" "$buildpack_url" _buildpack
export WORKSPACE_DIR="$PWD/_buildpack/builds"
rm -f .heroku/python/bin/python # prevent failing ln after build
sed -i 's!figure --pre!figure --enable-loadable-sqlite-extensions --pre!' \
"$WORKSPACE_DIR"/runtimes/python3
"$WORKSPACE_DIR/runtimes/$PYTHON_VERSION" /app/.heroku/python/
rm -fr _buildpack
fi
# load DB from cache
cp -R "$CACHE_DIR/.heroku/_cache" .heroku/ &> /dev/null || true
for x in .heroku/_cache/{jmdict,kanji,pitch,sentences}.sqlite3; do
if [ ! -s "$x" ]; then rm -fr .heroku/_cache/; break; fi
done
mkdir -p .heroku/_cache
touch .heroku/_cache/{jmdict,kanji,pitch,sentences}.sqlite3
ln -srf .heroku/_cache/{jmdict,kanji,pitch,sentences}.sqlite3 jiten/res/
# build .so & setup DB
make
rm -fr build
# get .version (FIXME: is there no better way?)
git clone https://github.com/obfusk/jiten.git _jiten
( cd _jiten && git checkout "$SOURCE_VERSION" && make _version )
mv -v _jiten/jiten/.version jiten/
rm -fr _jiten
# save DB to cache
rm -rf "$CACHE_DIR/.heroku/_cache"
cp -R .heroku/_cache "$CACHE_DIR/.heroku/"