[FIX] Packaging: RedHat: install in /usr and add systemd unit file
authorSimon Lejeune <sle@openerp.com>
Wed, 26 Nov 2014 13:08:05 +0000 (14:08 +0100)
committerSimon Lejeune <sle@openerp.com>
Fri, 28 Nov 2014 15:40:55 +0000 (16:40 +0100)
By default, the package was installed in /usr/local/lib/python2.7 in CentOS7.
It is problematic because most of other python packages are installed in /usr/lib
and also because /usr/local/lib is not in the default PYTHONPATH. It's fixed by
overriding the install script and forcing prefix to be /usr.

Added a minimal systemd unitfile.
Adapted tests accordingly.

setup.cfg
setup/package.py
setup/redhat/install.sh [new file with mode: 0644]
setup/redhat/postinstall.sh

index 7d0e931..b1bc001 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,4 +1,5 @@
 [bdist_rpm]
+install-script = setup/redhat/install.sh
 post-install = setup/redhat/postinstall.sh
 
 requires =
index f8a9055..ec95448 100755 (executable)
@@ -324,21 +324,23 @@ def test_deb(o):
 def test_rpm(o):
     with docker('centos:centos7', o.build_dir, o.pub) as centos7:
         centos7.release = 'odoo.noarch.rpm'
-        centos7.system('rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm')
-        centos7.system('yum update -y && yum upgrade -y')
-        centos7.system('yum install python-pip gcc python-devel -y')
+        # Dependencies
+        centos7.system('yum install -d 0 -e 0 epel-release -y')
+        centos7.system('yum update -d 0 -e 0 -y')
+        centos7.system('yum install -d 0 -e 0 python-pip gcc python-devel -y')
         centos7.system('pip install pydot pyPdf vatnumber xlwt http://download.gna.org/pychart/PyChart-1.39.tar.gz')
-        centos7.system('yum install postgresql postgresql-server postgresql-libs postgresql-contrib postgresql-devel -y')
+        # Manual install/start of postgres
+        centos7.system('yum install -d 0 -e 0 postgresql postgresql-server postgresql-libs postgresql-contrib postgresql-devel -y')
         centos7.system('mkdir -p /var/lib/postgres/data')
         centos7.system('chown -R postgres:postgres /var/lib/postgres/data')
         centos7.system('chmod 0700 /var/lib/postgres/data')
         centos7.system('su postgres -c "initdb -D /var/lib/postgres/data -E UTF-8"')
         centos7.system('cp /usr/share/pgsql/postgresql.conf.sample /var/lib/postgres/data/postgresql.conf')
         centos7.system('su postgres -c "/usr/bin/pg_ctl -D /var/lib/postgres/data start"')
+        centos7.system('sleep 5')
         centos7.system('su postgres -c "createdb mycompany"')
-        centos7.system('export PYTHONPATH=${PYTHONPATH}:/usr/local/lib/python2.7/dist-packages')
-        centos7.system('su postgres -c "createdb mycompany"')
-        centos7.system('yum install /opt/release/%s -y' % centos7.release)
+        # Odoo install
+        centos7.system('yum install -d 0 -e 0 /opt/release/%s -y' % centos7.release)
         centos7.system('su odoo -s /bin/bash -c "openerp-server -c /etc/odoo/openerp-server.conf -d mycompany -i base --stop-after-init"')
         centos7.system('su odoo -s /bin/bash -c "openerp-server -c /etc/odoo/openerp-server.conf -d mycompany &"')
 
diff --git a/setup/redhat/install.sh b/setup/redhat/install.sh
new file mode 100644 (file)
index 0000000..a74c7cd
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+set -e
+python setup.py install --prefix=/usr --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES
index 437fdce..d12621b 100644 (file)
@@ -25,7 +25,7 @@ db_host = False
 db_port = False
 db_user = $ODOO_USER
 db_password = False
-addons_path = /usr/local/lib/python2.7/dist-packages/openerp/addons
+addons_path = /usr/lib/python2.7/site-packages/openerp/addons
 " > $ODOO_CONFIGURATION_FILE
 chown $ODOO_USER:$ODOO_GROUP $ODOO_CONFIGURATION_FILE
 chmod 0640 $ODOO_CONFIGURATION_FILE
@@ -37,81 +37,20 @@ chmod 0750 $ODOO_LOG_DIR
 mkdir -p $ODOO_DATA_DIR
 chown $ODOO_USER:$ODOO_GROUP $ODOO_DATA_DIR
 
-INIT_FILE=/etc/init.d/openerp
+INIT_FILE=/lib/systemd/system/odoo.service
 touch $INIT_FILE
 chmod 0700 $INIT_FILE
-# FIXME this is a copy of debian/init file.
-#       If anyone know how to tell bdist_rpm to use this file directly...
 cat << 'EOF' > $INIT_FILE
-#!/bin/bash
-### BEGIN INIT INFO
-# Provides:          openerp-server
-# Required-Start:    $remote_fs $syslog
-# Required-Stop:     $remote_fs $syslog
-# Default-Start:     2 3 4 5
-# Default-Stop:      0 1 6
-# Short-Description: Start openerp daemon at boot time
-# Description:       Enable service provided by daemon.
-# X-Interactive:     true
-### END INIT INFO
-## more info: http://wiki.debian.org/LSBInitScripts
-
-PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
-DAEMON=/usr/bin/openerp-server
-NAME=openerp
-DESC=openerp
-CONFIG=/etc/odoo/openerp-server.conf
-LOGFILE=/var/log/odoo/openerp-server.log
-PIDFILE=/var/run/${NAME}.pid
-USER=odoo
-export LOGNAME=$USER
-
-test -x $DAEMON || exit 0
-set -e
-
-function _start() {
-    start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER:$USER --background --make-pidfile --exec $DAEMON -- --config $CONFIG --logfile $LOGFILE
-}
-
-function _stop() {
-    start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --retry 3
-    rm -f $PIDFILE
-}
-
-function _status() {
-    start-stop-daemon --status --quiet --pidfile $PIDFILE
-    return $?
-}
-
-
-case "$1" in
-        start)
-                echo -n "Starting $DESC: "
-                _start
-                echo "ok"
-                ;;
-        stop)
-                echo -n "Stopping $DESC: "
-                _stop
-                echo "ok"
-                ;;
-        restart|force-reload)
-                echo -n "Restarting $DESC: "
-                _stop
-                sleep 1
-                _start
-                echo "ok"
-                ;;
-        status)
-                echo -n "Status of $DESC: "
-                _status && echo "running" || echo "stopped"
-                ;;
-        *)
-                N=/etc/init.d/$NAME
-                echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
-                exit 1
-                ;;
-esac
-
-exit 0
+[Unit]
+Description=Odoo Open Source ERP and CRM
+After=network.target
+
+[Service]
+Type=simple
+User=odoo
+Group=odoo
+ExecStart=/usr/bin/odoo.py --config=/etc/odoo/openerp-server.conf
+
+[Install]
+WantedBy=multi-user.target
 EOF