145 lines
3.9 KiB
Nix
145 lines
3.9 KiB
Nix
{stdenv, writeShellApplication, git, python26, jinja2, mysql-python, pil, lxml, file, mysql, html-tidy, wget}: writeShellApplication rec {
|
|
name = "service1";
|
|
|
|
|
|
#propagatedBuildInputs = [python26Packages.setuptools];
|
|
#nativeBuildInputs = [ jinja2 ];
|
|
#buildInputs = [ jinja2 ];
|
|
runtimeInputs = [git (python26.withPackages(ps: [jinja2 mysql-python pil lxml])) file mysql html-tidy wget];
|
|
|
|
#env = {
|
|
# NIX_CFLAGS_COMPILE="-Wno-incompatible-pointer-types";
|
|
#};
|
|
|
|
text = ''
|
|
export LIBMAGIC_PATH="${file}/lib/libmagic.so.1"
|
|
export LIBTIDY_PATH="${html-tidy}/lib/libtidy.so"
|
|
|
|
if [ ! -d "mdn" ]; then
|
|
mkdir mdn
|
|
cd mdn
|
|
|
|
git clone https://github.com/mdn/kuma.git --progress
|
|
cd kuma
|
|
git switch dc45adde8b47269b8f088893fa14978b0c01a40a --detach --progress
|
|
sed -i 's#git://#https://#g' .gitmodules
|
|
git submodule update --init --progress
|
|
sed -i 's#git://#https://#g' ./vendor/.gitmodules
|
|
git submodule update --init --recursive --progress
|
|
|
|
cd ./vendor/src/python-magic
|
|
content="diff --git a/magic.py b/magic.py
|
|
index 53a91fd..97c19dc 100644
|
|
--- a/magic.py
|
|
+++ b/magic.py
|
|
@@ -112,6 +112,8 @@ dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1')
|
|
# This is necessary because find_library returns None if it doesn't find the library
|
|
if dll:
|
|
libmagic = ctypes.CDLL(dll)
|
|
+else:
|
|
+ libmagic = ctypes.CDLL(os.environ[\"LIBMAGIC_PATH\"])
|
|
|
|
if not libmagic or not libmagic._name:
|
|
import sys
|
|
"
|
|
echo "$content" > libmagic.diff
|
|
git apply libmagic.diff
|
|
cd ../../..
|
|
|
|
cd ./vendor/src/pytidylib
|
|
content="diff --git a/tidylib/__init__.py b/tidylib/__init__.py
|
|
index b5b4367..091445b 100644
|
|
--- a/tidylib/__init__.py
|
|
+++ b/tidylib/__init__.py
|
|
@@ -22,6 +22,7 @@ import ctypes
|
|
import threading
|
|
import re
|
|
import platform
|
|
+import os
|
|
from tidylib.sink import create_sink, destroy_sink
|
|
|
|
__all__ = ['tidy_document', 'tidy_fragment', 'release_tidy_doc']
|
|
@@ -30,7 +31,7 @@ __all__ = ['tidy_document', 'tidy_fragment', 'release_tidy_doc']
|
|
# Constants
|
|
|
|
LIB_NAMES = ['libtidy', 'libtidy.so', 'libtidy-0.99.so.0', 'cygtidy-0-99-0',
|
|
- 'tidylib', 'libtidy.dylib', 'tidy']
|
|
+ 'tidylib', 'libtidy.dylib', 'tidy', os.environ[\"LIBTIDY_PATH\"]]
|
|
ENOMEM = -12
|
|
RE_BODY = re.compile(r\"<body>[\r\n]*(.+?)</body>\", re.S)
|
|
BASE_OPTIONS = {
|
|
"
|
|
echo "$content" > libtidy.diff
|
|
git apply libtidy.diff
|
|
cd ../../..
|
|
|
|
cd ../..
|
|
fi
|
|
|
|
cd mdn
|
|
dbDir="$(pwd)/db"
|
|
|
|
if [ ! -d "product_details_json" ]; then
|
|
mkdir product_details_json
|
|
|
|
cd kuma
|
|
content="from settings import *
|
|
DATABASES = {
|
|
'default': {
|
|
'NAME': 'kuma',
|
|
'ENGINE': 'django.db.backends.mysql',
|
|
'HOST': 'localhost',
|
|
'USER': 'kuma',
|
|
'PASSWORD': 'bommels',
|
|
'OPTIONS': {'init_command': 'SET storage_engine=InnoDB'},
|
|
'TEST_CHARSET': 'utf8',
|
|
'TEST_COLLATION': 'utf8_unicode_ci',
|
|
},
|
|
}
|
|
DEBUG = True
|
|
TEMPLATE_DEBUG = DEBUG
|
|
SERVE_MEDIA = True
|
|
SITE_URL = 'http://localhost:8000'
|
|
PROTOCOL = 'http://'
|
|
DOMAIN = 'localhost'
|
|
PORT = 8000
|
|
SESSION_COOKIE_SECURE = False
|
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = False"
|
|
echo "$content" > settings_local.py
|
|
cd ..
|
|
|
|
mkdir "$dbDir"
|
|
mysql_install_db --datadir="$dbDir"
|
|
mysqld --datadir="$dbDir" &
|
|
dbServer="$!"
|
|
sleep 3
|
|
echo "CREATE USER 'kuma'@'localhost' IDENTIFIED BY 'bommels';" | mysql -u root
|
|
echo "CREATE DATABASE kuma;" | mysql -u root
|
|
echo "GRANT ALL PRIVILEGES ON kuma.* TO 'kuma'@'localhost';" | mysql -u root
|
|
|
|
cd kuma
|
|
./manage.py syncdb
|
|
./manage.py migrate
|
|
cd ..
|
|
|
|
cd product_details_json
|
|
wget https://product-details.mozilla.org/1.0/languages.json
|
|
|
|
kill "$dbServer"
|
|
sleep 3
|
|
|
|
cd ..
|
|
fi
|
|
|
|
cd kuma
|
|
mysqld --datadir="$dbDir" &
|
|
dbServer="$!"
|
|
sleep 3
|
|
|
|
python ./manage.py runserver --noreload
|
|
|
|
kill "$dbServer"
|
|
sleep 6
|
|
'';
|
|
}
|