From 56536055154350da4b9314eed1235b329737cf72 Mon Sep 17 00:00:00 2001 From: ljf Date: Mon, 21 May 2018 10:51:03 +0200 Subject: [PATCH 1/6] [fix] Missing bc dependencies --- conf/odoo.service.j2 | 14 ++++++++++++++ scripts/_common.sh | 11 ++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 conf/odoo.service.j2 diff --git a/conf/odoo.service.j2 b/conf/odoo.service.j2 new file mode 100644 index 0000000..b832e5d --- /dev/null +++ b/conf/odoo.service.j2 @@ -0,0 +1,14 @@ +[Unit] +Description=Odoo +After=network.target + +[Service] +Type=simple +User=odoo +Environment=PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin +ExecStart=/usr/bin/odoo.py --config {{ conf_file }} > /var/log/odoo/odoo-server.log 2>&1 +Restart=always +RestartSec=3 + +[Install] +WantedBy=multi-user.target diff --git a/scripts/_common.sh b/scripts/_common.sh index 2228359..212e110 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,11 +8,11 @@ function define_paths() { # In odoo 10 some file change if [ $(echo "$odoo_version >= 10" | bc) -ne 0 ]; then export source_path=/usr/lib/python2.7/dist-packages/odoo/ - conf_file=/etc/odoo/odoo.conf + export conf_file=/etc/odoo/odoo.conf bin_file=/usr/bin/odoo else export source_path=/usr/lib/python2.7/dist-packages/openerp/ - conf_file=/etc/odoo/openerp-server.conf + export conf_file=/etc/odoo/openerp-server.conf bin_file=/usr/bin/openerp-server fi } @@ -70,7 +70,7 @@ function install_dependencies() { if [ ! -f /etc/apt/sources.list.d/odoo.list ]; then # Install Odoo # Prepare installation - ynh_package_install curl + ynh_package_install curl bc # Install Odoo curl -sS https://nightly.odoo.com/odoo.key | sudo apt-key add - @@ -106,9 +106,14 @@ function add_services() { yunohost service add postgresql fi if ! grep "^odoo:$" /etc/yunohost/services.yml; then + ynh_configure odoo.service /etc/systemd/system/odoo.service + rm /etc/init.d/odoo + yunohost service add odoo --log /var/log/odoo/odoo-server.log yunohost service stop odoo yunohost service start odoo + yunohost service enable odoo + systemctl enable odoo fi } From 19e965c235e78b13bbbf9e6cf6b3ca32197d082a Mon Sep 17 00:00:00 2001 From: ljf Date: Mon, 21 May 2018 10:53:52 +0200 Subject: [PATCH 2/6] [enh] Add 11.0 version --- manifest.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index e1e4fb1..11cfe60 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "name": "scith, ljf", "email": "ljf+yunohost@grimaud.me" }, - "version": "10.0-1", + "version": "11.0-1", "url": "https://www.odoo.com", "license": "LGPL-3.0", "requirements": { @@ -35,8 +35,8 @@ "en": "Which version of Odoo do you want to install?", "fr": "Quelle version d'Odoo souhaitez-vous installer ?" }, - "choices": ["8.0", "9.0", "10.0"], - "default": "9.0" + "choices": ["8.0", "9.0", "10.0", "11.0"], + "default": "11.0" }, { "name": "oca", "type": "boolean", From 4723c5c67a10a9fdf9922e51ac7dfdfa9d3e1409 Mon Sep 17 00:00:00 2001 From: ljf Date: Mon, 21 May 2018 12:02:01 +0200 Subject: [PATCH 3/6] [fix] Missing backports and othe python3 dependencies --- scripts/_common.sh | 13 ++++++++++--- scripts/_future.sh | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 212e110..5a6d8ea 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,11 @@ APPNAME="odoo" function define_paths() { # In odoo 10 some file change if [ $(echo "$odoo_version >= 10" | bc) -ne 0 ]; then - export source_path=/usr/lib/python2.7/dist-packages/odoo/ + if [ $(echo "$odoo_version >= 11" | bc) -ne 0 ]; then + export source_path=/usr/lib/python3/dist-packages/odoo/ + else + export source_path=/usr/lib/python2.7/dist-packages/odoo/ + fi export conf_file=/etc/odoo/odoo.conf bin_file=/usr/bin/odoo else @@ -78,9 +82,13 @@ function install_dependencies() { # TODO if 8.0 install https://www.odoo.com/apps/modules/8.0/shell/ fi + if is_jessie ; then + sudo echo "deb http://http.debian.net/debian jessie-backports main" | sudo tee /etc/apt/sources.list.d/jessie-backport.list + fi apt-get update - ynh_install_app_dependencies curl postgresql odoo xfonts-75dpi xfonts-base wkhtmltopdf node-less python-xlrd + ynh_install_app_dependencies curl postgresql odoo xfonts-75dpi xfonts-base wkhtmltopdf node-less python-xlrd python3-dev gcc libldap2-dev libssl-dev libsasl2-dev + pip3 install pyldap if ! wkhtmltopdf --version | grep "wkhtmltopdf 0.12.4 (with patched qt)"; then # The debian package has a bug so we deploy a more recent version @@ -113,7 +121,6 @@ function add_services() { yunohost service stop odoo yunohost service start odoo yunohost service enable odoo - systemctl enable odoo fi } diff --git a/scripts/_future.sh b/scripts/_future.sh index d68da67..ff18dad 100644 --- a/scripts/_future.sh +++ b/scripts/_future.sh @@ -203,3 +203,26 @@ exec_as() { sudo sudo -u "$USER" "$@" fi } + +ynh_debian_release () { + lsb_release --codename --short +} + +is_stretch () { + if [ "$(ynh_debian_release)" == "stretch" ] + then + return 0 + else + return 1 + fi +} + +is_jessie () { + if [ "$(ynh_debian_release)" == "jessie" ] + then + return 0 + else + return 1 + fi +} + From e011185b96dbedfc29dcf9e993a373fe188254f3 Mon Sep 17 00:00:00 2001 From: ljf Date: Mon, 21 May 2018 12:08:41 +0200 Subject: [PATCH 4/6] [fix] Missing pip3 --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 5a6d8ea..cdc3320 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -87,7 +87,7 @@ function install_dependencies() { fi apt-get update - ynh_install_app_dependencies curl postgresql odoo xfonts-75dpi xfonts-base wkhtmltopdf node-less python-xlrd python3-dev gcc libldap2-dev libssl-dev libsasl2-dev + ynh_install_app_dependencies curl postgresql odoo xfonts-75dpi xfonts-base wkhtmltopdf node-less python-xlrd python3-dev gcc libldap2-dev libssl-dev libsasl2-dev python3-pip pip3 install pyldap if ! wkhtmltopdf --version | grep "wkhtmltopdf 0.12.4 (with patched qt)"; then From b8002d0e6752fb8920ae4b35ecf15b6489d37855 Mon Sep 17 00:00:00 2001 From: ljf Date: Mon, 21 May 2018 12:41:04 +0200 Subject: [PATCH 5/6] [fix] Bad executable --- conf/odoo.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/odoo.service.j2 b/conf/odoo.service.j2 index b832e5d..c6ba300 100644 --- a/conf/odoo.service.j2 +++ b/conf/odoo.service.j2 @@ -6,7 +6,7 @@ After=network.target Type=simple User=odoo Environment=PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin -ExecStart=/usr/bin/odoo.py --config {{ conf_file }} > /var/log/odoo/odoo-server.log 2>&1 +ExecStart={{ bin_file }} --config {{ conf_file }} > /var/log/odoo/odoo-server.log 2>&1 Restart=always RestartSec=3 From 94b2b28db1286ef79c3d3ba41d047daa6eaf3e01 Mon Sep 17 00:00:00 2001 From: ljf Date: Mon, 21 May 2018 15:44:09 +0200 Subject: [PATCH 6/6] [fix] Export bin_file --- conf/openupgrade.src | 5 ++++ scripts/_common.sh | 4 ++-- scripts/upgrade | 57 ++++++++++++++++++++++++++++++++++---------- 3 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 conf/openupgrade.src diff --git a/conf/openupgrade.src b/conf/openupgrade.src new file mode 100644 index 0000000..7bba77f --- /dev/null +++ b/conf/openupgrade.src @@ -0,0 +1,5 @@ +SOURCE_URL=https://raw.githubusercontent.com/OCA/OpenUpgrade/11.0/scripts/migrate.py +SOURCE_SUM=362c8cf9b43a3aaddb440e642205e9596da78e28d1e47b582612ced671d95e0b +SOURCE_FILE=odoo-migrate-11.py +SOURCE_SUM_PRG=sha256sum +SOURCE_EXTRACT=False diff --git a/scripts/_common.sh b/scripts/_common.sh index cdc3320..f24ac78 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -13,11 +13,11 @@ function define_paths() { export source_path=/usr/lib/python2.7/dist-packages/odoo/ fi export conf_file=/etc/odoo/odoo.conf - bin_file=/usr/bin/odoo + export bin_file=/usr/bin/odoo else export source_path=/usr/lib/python2.7/dist-packages/openerp/ export conf_file=/etc/odoo/openerp-server.conf - bin_file=/usr/bin/openerp-server + export bin_file=/usr/bin/openerp-server fi } diff --git a/scripts/upgrade b/scripts/upgrade index 51aed46..b0948a1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,13 +1,19 @@ #!/bin/bash -set -eu +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= # Source YunoHost helpers source /usr/share/yunohost/helpers source _future.sh source _common.sh -ynh_trap_on +#================================================= +# LOAD SETTINGS +#================================================= # Retrieve arguments export app=$YNH_APP_INSTANCE_NAME @@ -17,18 +23,40 @@ export is_master=$(ynh_app_setting_get "$app" is_master) export oca=$(ynh_app_setting_get "$app" oca) export port=$(ynh_app_setting_get $app port) export is_public=0 +export major_upgrade=$(ynh_app_setting_get $app major_upgrade) -version=$(ynh_read_json "/etc/yunohost/apps/$app/manifest.json" 'version' 2> /dev/null || echo '9.0-0') -last_version=$(ynh_read_manifest 'version') +#================================================= +# CHECK VERSION +#================================================= -#ynh_exit_if_up_to_date -ynh_check_var "$app" "app name not set" +ynh_abort_if_up_to_date -# Upgrade official package -apt-get install odoo -y -qq +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# CHECK THE PATH +#================================================= + +path_url=$(ynh_normalize_url_path $path_url) # VĂ©rifie et corrige la syntaxe du path. + +#================================================= +# STEP Migrations +#================================================= # Zamentur version https://github.com/zamentur/odoo_ynh/commit/cdeb9afbf218431781f752dedfbf4247afbd5b44 -if [ "${version}" = "9.0-0" ]; then +if ynh_version_le "9.0-0" ; then # set new args odoo_version=${odoo_version:-$(ynh_app_setting_get "$app" version)} if [ "$is_master" = "" ]; then @@ -46,9 +74,14 @@ if [ "${version}" = "9.0-0" ]; then install_dependencies fi -if [ "${version}" = "10.0-1" ]; then - # Put here your migrations - echo "" +if ynh_version_le "11.0-1" ; then + # By default we don't upgrade to major version + major_upgrade=${major_upgrade:-0} + ynh_save_args major_upgrade fi +# Upgrade official package +apt-get install odoo -y -qq + +