From 0c266412871e71387a844e5478b7d3c2698ea0f3 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sun, 8 Apr 2018 10:27:26 +0200 Subject: [PATCH] VADE RETRO PYTHON3! Welcome Weblate 2.20! --- check_process | 1 - conf/settings_history/settings.2.20.py | 2 ++ conf/uwsgi.ini | 4 +-- scripts/_common.sh | 2 ++ scripts/install | 17 +++++---- scripts/restore | 4 +-- scripts/upgrade | 50 ++++++++------------------ 7 files changed, 32 insertions(+), 48 deletions(-) diff --git a/check_process b/check_process index b300842..6f75808 100644 --- a/check_process +++ b/check_process @@ -11,7 +11,6 @@ is_public=1 (PUBLIC|public=1|private=0) github_account="myaccount" github_token="myoauthtoken" - password="pass" ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/conf/settings_history/settings.2.20.py b/conf/settings_history/settings.2.20.py index 4a33300..fd84cfc 100644 --- a/conf/settings_history/settings.2.20.py +++ b/conf/settings_history/settings.2.20.py @@ -593,6 +593,8 @@ EMAIL_SEND_HTML = True # Subject of emails includes site title EMAIL_SUBJECT_PREFIX = '[{0}] '.format(SITE_TITLE) +EMAIL_BACKEND = 'django_sendmail_backend.backends.EmailBackend' + # Enable remote hooks ENABLE_HOOKS = True diff --git a/conf/uwsgi.ini b/conf/uwsgi.ini index 6694559..2c3929e 100644 --- a/conf/uwsgi.ini +++ b/conf/uwsgi.ini @@ -1,12 +1,12 @@ [uwsgi] -plugins = python3 +plugins = python master = true protocol = uwsgi socket = /var/run/uwsgi/__APP__.socket virtualenv = __FINALPATH__/venv # http://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info -mount = __PATH__=__FINALPATH__/venv/lib/python3.4/site-packages/weblate/wsgi.py +mount = __PATH__=__FINALPATH__/venv/lib/python2.7/site-packages/weblate/wsgi.py manage-script-name = true # Needed for OAuth/OpenID diff --git a/scripts/_common.sh b/scripts/_common.sh index b92c20a..e91494b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -82,6 +82,8 @@ ynh_remove_uwsgi_service () { yunohost service remove "uwsgi-app@$app.socket" ynh_secure_remove "$finaluwsgiini" + ynh_secure_remove "/var/run/uwsgi/$app.socket" + ynh_secure_remove "/var/log/uwsgi/app/$app" fi } diff --git a/scripts/install b/scripts/install index f5692c1..fb2c063 100755 --- a/scripts/install +++ b/scripts/install @@ -77,8 +77,8 @@ ynh_app_setting_set "$app" github_token "$github_token" #================================================= ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \ - libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv python-virtualenv \ - postgresql libpq-dev uwsgi uwsgi-plugin-python3 memcached + libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv \ + postgresql libpq-dev uwsgi uwsgi-plugin-python memcached #================================================= # CREATE A PostgreSQL DATABASE @@ -177,7 +177,7 @@ ynh_add_uwsgi_service #================================================= # PIP INSTALLATION #================================================= -virtualenv --python=python3 "${final_path}/venv" +virtualenv "${final_path}/venv" #run source in a 'sub shell' ( set +o nounset @@ -187,7 +187,7 @@ virtualenv --python=python3 "${final_path}/venv" # prevent error: "command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers" pip install --upgrade setuptools pip install Weblate=="$current_version" - pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2 python-memcached phply + pip install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached phply # specific to YunoHost package: pip install django_sendmail_backend ) @@ -201,7 +201,7 @@ db_pwd=$(ynh_app_setting_get "$app" psqlpwd) admin_mail=$(ynh_user_get_info "$admin" mail) key=$(ynh_string_random) memc_port=$(ynh_find_port 8080) -settings="$final_path/venv/lib/python3.4/site-packages/weblate/settings.py" +settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py" cp "../conf/settings_history/settings.$current_version.py" "$settings" weblate_fill_settings "$settings" @@ -238,7 +238,7 @@ ynh_replace_string "__FINALPATH__" "$final_path/" "/etc/cron.d/$app" #================================================= # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$final_path/venv/lib/python3.4/site-packages/weblate/settings.py" +ynh_store_file_checksum "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py" #================================================= # GENERIC FINALIZATION @@ -247,7 +247,10 @@ ynh_store_file_checksum "$final_path/venv/lib/python3.4/site-packages/weblate/se #================================================= # Set permissions to app files -chown -R "$app": "$final_path" +chown -R "$app": "$final_path/data" + +mkdir -p "$final_path/avatar-cache" +chown -R "$app": "$final_path/avatar-cache" #================================================= # SETUP SSOWAT diff --git a/scripts/restore b/scripts/restore index eded65e..df2040f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -75,8 +75,8 @@ chown -R "$app": "$final_path" #================================================= ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \ - libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv python-virtualenv \ - postgresql libpq-dev uwsgi uwsgi-plugin-python3 memcached + libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv \ + postgresql libpq-dev uwsgi uwsgi-plugin-python memcached #================================================= # RESTORE THE PostgreSQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index 9dce434..4173808 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -62,15 +62,7 @@ if [ -z "$db_name" ]; then # If db_name doesn't exist, create it ynh_app_setting_set "$app" db_name "$db_name" fi -# (<2.18) handle python3 migration (because of django 2.0) -if [[ -e "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py" ]] -then - settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py" - migrate_py2to3=true -else - settings="$final_path/venv/lib/python3.4/site-packages/weblate/settings.py" - migrate_py2to3=false -fi +settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py" # (<2.17) save memc_port if it doesn't exist if [[ -z "$memc_port" ]] @@ -143,8 +135,8 @@ chsh --shell /bin/bash "$app" #================================================= ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \ - libjpeg-dev libz-dev libyaml-dev python3-dev python3-pip python3-virtualenv python-virtualenv \ - postgresql libpq-dev uwsgi uwsgi-plugin-python3 memcached + libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv \ + postgresql libpq-dev uwsgi uwsgi-plugin-python memcached #================================================= # SPECIFIC SETUP uwsgi @@ -159,22 +151,6 @@ ynh_add_uwsgi_service # save old settings file cp "$settings" "$final_path/settings.$previous_version.old.py" -# (<2.18) handle python3 migration -if [[ "$migrate_py2to3" = true ]] -then - ynh_secure_remove "$final_path/venv" - virtualenv --python=python3 "${final_path}/venv" - set +o nounset - source "${final_path}/venv/bin/activate" - set -o nounset - pip install --upgrade pip - pip install Weblate=="$current_version" - - settings="$final_path/venv/lib/python3.4/site-packages/weblate/settings.py" - cp "$final_path/settings.$previous_version.old.py" "$settings" - ynh_store_file_checksum "$settings" -fi - old_settings="./settings.$previous_version.old.py" settings_diff="$final_path/settings.${previous_version}_${current_version}.diff" @@ -186,9 +162,7 @@ settings_diff="$final_path/settings.${previous_version}_${current_version}.diff" # prevent error: "command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers" pip install --upgrade setuptools pip install Weblate=="$current_version" - # prevent error "ImportError: No module named 'social'" - pip install -r "$final_path/venv/lib/python3.4/site-packages/weblate/requirements.txt" - pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2 python-memcached phply + pip install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached phply # specific to YunoHost package: pip install django_sendmail_backend ) @@ -261,19 +235,23 @@ fi weblate loadpo --all --lang lt weblate loadpo --all --lang lv fi - - if [[ "$migrate_py2to3" = true ]] - then - weblate rebuild_index --clean --all - fi ) # Recalculate and store the config file checksum into the app settings -ynh_store_file_checksum "$final_path/venv/lib/python3.4/site-packages/weblate/settings.py" +ynh_store_file_checksum "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py" #================================================= # GENERIC FINALIZATION #================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set right permissions for curl installation +chown -R root:root "$final_path" +chown -R "$app": "$final_path/data" + +mkdir -p "$final_path/avatar-cache" +chown -R "$app": "$final_path/avatar-cache" #================================================= # SETUP SSOWAT