Skip to content

Commit 80a9324

Browse files
committed
FIX] packaging: odoo-ification
1 parent 2232453 commit 80a9324

File tree

10 files changed

+160
-135
lines changed

10 files changed

+160
-135
lines changed

debian/init

+56-47
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,71 @@
1-
#!/bin/sh
2-
1+
#!/bin/bash
32
### BEGIN INIT INFO
4-
# Provides: openerp-server
5-
# Required-Start: $remote_fs $syslog
6-
# Required-Stop: $remote_fs $syslog
7-
# Should-Start: $network
8-
# Should-Stop: $network
9-
# Default-Start: 2 3 4 5
10-
# Default-Stop: 0 1 6
11-
# Short-Description: Enterprise Resource Management software
12-
# Description: Open ERP is a complete ERP and CRM software.
3+
# Provides: openerp-server
4+
# Required-Start: $remote_fs $syslog
5+
# Required-Stop: $remote_fs $syslog
6+
# Default-Start: 2 3 4 5
7+
# Default-Stop: 0 1 6
8+
# Short-Description: Start openerp daemon at boot time
9+
# Description: Enable service provided by daemon.
10+
# X-Interactive: true
1311
### END INIT INFO
12+
## more info: http://wiki.debian.org/LSBInitScripts
1413

1514
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
1615
DAEMON=/usr/bin/openerp-server
17-
NAME=openerp-server
18-
DESC=openerp-server
19-
CONFIG=/etc/openerp/openerp-server.conf
20-
LOGFILE=/var/log/openerp/openerp-server.log
21-
USER=openerp
22-
23-
test -x ${DAEMON} || exit 0
16+
NAME=openerp
17+
DESC=openerp
18+
CONFIG=/etc/odoo/openerp-server.conf
19+
LOGFILE=/var/log/odoo/openerp-server.log
20+
PIDFILE=/var/run/${NAME}.pid
21+
USER=odoo
22+
export LOGNAME=$USER
2423

24+
test -x $DAEMON || exit 0
2525
set -e
2626

27-
do_start () {
28-
echo -n "Starting ${DESC}: "
29-
start-stop-daemon --start --quiet --pidfile /var/run/${NAME}.pid --chuid ${USER} --background --make-pidfile --exec ${DAEMON} -- --config=${CONFIG} --logfile=${LOGFILE}
30-
echo "${NAME}."
27+
function _start() {
28+
start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER:$USER --background --make-pidfile --exec $DAEMON -- --config $CONFIG --logfile $LOGFILE
3129
}
3230

33-
do_stop () {
34-
echo -n "Stopping ${DESC}: "
35-
start-stop-daemon --stop --quiet --pidfile /var/run/${NAME}.pid --oknodo
36-
echo "${NAME}."
31+
function _stop() {
32+
start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --retry 3
33+
rm -f $PIDFILE
3734
}
3835

39-
case "${1}" in
40-
start)
41-
do_start
42-
;;
43-
44-
stop)
45-
do_stop
46-
;;
47-
48-
restart|force-reload)
49-
echo -n "Restarting ${DESC}: "
50-
do_stop
51-
sleep 1
52-
do_start
53-
;;
54-
55-
*)
56-
N=/etc/init.d/${NAME}
57-
echo "Usage: ${NAME} {start|stop|restart|force-reload}" >&2
58-
exit 1
59-
;;
36+
function _status() {
37+
start-stop-daemon --status --quiet --pidfile $PIDFILE
38+
return $?
39+
}
40+
41+
42+
case "$1" in
43+
start)
44+
echo -n "Starting $DESC: "
45+
_start
46+
echo "ok"
47+
;;
48+
stop)
49+
echo -n "Stopping $DESC: "
50+
_stop
51+
echo "ok"
52+
;;
53+
restart|force-reload)
54+
echo -n "Restarting $DESC: "
55+
_stop
56+
sleep 1
57+
_start
58+
echo "ok"
59+
;;
60+
status)
61+
echo -n "Status of $DESC: "
62+
_status && echo "running" || echo "stopped"
63+
;;
64+
*)
65+
N=/etc/init.d/$NAME
66+
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
67+
exit 1
68+
;;
6069
esac
6170

6271
exit 0

debian/install

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
debian/openerp-server.conf /etc/openerp
2-
README.md /usr/share/doc/openerp
1+
debian/openerp-server.conf /etc/odoo
2+
README.md /usr/share/doc/odoo

debian/logrotate

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/var/log/openerp/*.log {
1+
/var/log/odoo/*.log {
22
copytruncate
33
missingok
44
notifempty

debian/openerp-server.conf

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
; admin_passwd = admin
44
db_host = False
55
db_port = False
6-
db_user = openerp
6+
db_user = odoo
77
db_password = False
8-
addons_path = /usr/lib/python2.7/dist-packages/openerp/addons
8+
addons_path = /usr/lib/python2.7/dist-packages/openerp/addons

debian/postinst

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
set -e
44

5-
ODOO_CONFIGURATION_FILE=/etc/openerp/openerp-server.conf
6-
ODOO_GROUP="openerp"
7-
ODOO_DATA_DIR=/var/lib/openerp
8-
ODOO_LOG_DIR=/var/log/openerp
9-
ODOO_USER="openerp"
5+
ODOO_CONFIGURATION_FILE=/etc/odoo/openerp-server.conf
6+
ODOO_GROUP="odoo"
7+
ODOO_DATA_DIR=/var/lib/odoo
8+
ODOO_LOG_DIR=/var/log/odoo
9+
ODOO_USER="odoo"
1010

1111
case "${1}" in
1212
configure)
13-
if ! getent passwd | grep -q "^openerp:"; then
13+
if ! getent passwd | grep -q "^odoo:"; then
1414
adduser --system --no-create-home --quiet --group $ODOO_USER
1515
fi
16-
# Register "openerp" as a postgres superuser
17-
su - postgres -c "createuser -s openerp" 2> /dev/null || true
16+
# Register "$ODOO_USER" as a postgres superuser
17+
su - postgres -c "createuser -s $ODOO_USER" 2> /dev/null || true
1818
# Configuration file
1919
chown $ODOO_USER:$ODOO_GROUP $ODOO_CONFIGURATION_FILE
2020
chmod 0640 $ODOO_CONFIGURATION_FILE

debian/postrm

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
set -e
44

5-
ODOO_LIB_DIR=/var/lib/openerp
6-
ODOO_USER="openerp"
7-
ODOO_GROUP="openerp"
5+
ODOO_LIB_DIR=/var/lib/odoo
6+
ODOO_USER="odoo"
7+
ODOO_GROUP="odoo"
88

99
case "${1}" in
1010
remove)

openerp/release.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
version = '.'.join(map(str, version_info[:2])) + RELEASE_LEVELS_DISPLAY[version_info[3]] + str(version_info[4] or '')
3535
series = serie = major_version = '.'.join(map(str, version_info[:2]))
3636

37+
product_name = 'Odoo'
3738
description = 'Odoo Server'
3839
long_desc = '''Odoo is a complete ERP and CRM. The main features are accounting (analytic
3940
and financial), stock management, sales and purchases management, tasks
@@ -45,9 +46,9 @@
4546
License :: OSI Approved :: GNU Affero General Public License v3
4647
Programming Language :: Python
4748
"""
48-
url = 'http://www.openerp.com'
49+
url = 'https://www.odoo.com'
4950
author = 'OpenERP S.A.'
50-
author_email = 'info@openerp.com'
51+
author_email = 'info@odoo.com'
5152
license = 'AGPL-3'
5253

5354
nt_service_name = "openerp-server-" + series

openerp/tools/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def _get_default_datadir():
6868
if sys.platform in ['win32', 'darwin']:
6969
func = appdirs.site_data_dir
7070
else:
71-
func = lambda **kwarg: "/var/lib/%s" % kwarg['appname']
71+
func = lambda **kwarg: "/var/lib/%s" % kwarg['appname'].lower()
7272
# No "version" kwarg as session and filestore paths are shared against series
73-
return func(appname='openerp', appauthor=release.author)
73+
return func(appname=release.product_name, appauthor=release.author)
7474

7575
class configmanager(object):
7676
def __init__(self, fname=None):

setup/package.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,13 @@ def test_tgz(o):
266266
wheezy.system('su postgres -s /bin/bash -c "pg_createcluster --start -e UTF-8 9.1 main"')
267267
wheezy.system('pip install -r /opt/release/requirements.txt')
268268
wheezy.system('/usr/local/bin/pip install /opt/release/%s' % wheezy.release)
269-
wheezy.system("useradd --system --no-create-home openerp")
270-
wheezy.system('su postgres -s /bin/bash -c "createuser -s openerp"')
269+
wheezy.system("useradd --system --no-create-home odoo")
270+
wheezy.system('su postgres -s /bin/bash -c "createuser -s odoo"')
271271
wheezy.system('su postgres -s /bin/bash -c "createdb mycompany"')
272-
wheezy.system('mkdir /var/lib/openerp')
273-
wheezy.system('chown openerp:openerp /var/lib/openerp')
274-
wheezy.system('su openerp -s /bin/bash -c "odoo.py --addons-path=/usr/local/lib/python2.7/dist-packages/openerp/addons -d mycompany -i base --stop-after-init"')
275-
wheezy.system('su openerp -s /bin/bash -c "odoo.py --addons-path=/usr/local/lib/python2.7/dist-packages/openerp/addons -d mycompany &"')
272+
wheezy.system('mkdir /var/lib/odoo')
273+
wheezy.system('chown odoo:odoo /var/lib/odoo')
274+
wheezy.system('su odoo -s /bin/bash -c "odoo.py --addons-path=/usr/local/lib/python2.7/dist-packages/openerp/addons -d mycompany -i base --stop-after-init"')
275+
wheezy.system('su odoo -s /bin/bash -c "odoo.py --addons-path=/usr/local/lib/python2.7/dist-packages/openerp/addons -d mycompany &"')
276276

277277
def test_deb(o):
278278
with docker('debian:stable', o.build_dir, o.pub) as wheezy:
@@ -285,8 +285,8 @@ def test_deb(o):
285285
wheezy.system('su postgres -s /bin/bash -c "createdb mycompany"')
286286
wheezy.system('/usr/bin/dpkg -i /opt/release/%s' % wheezy.release)
287287
wheezy.system('/usr/bin/apt-get install -f -y')
288-
wheezy.system('su openerp -s /bin/bash -c "odoo.py -c /etc/openerp/openerp-server.conf -d mycompany -i base --stop-after-init"')
289-
wheezy.system('su openerp -s /bin/bash -c "odoo.py -c /etc/openerp/openerp-server.conf -d mycompany &"')
288+
wheezy.system('su odoo -s /bin/bash -c "odoo.py -c /etc/odoo/openerp-server.conf -d mycompany -i base --stop-after-init"')
289+
wheezy.system('su odoo -s /bin/bash -c "odoo.py -c /etc/odoo/openerp-server.conf -d mycompany &"')
290290

291291
def test_rpm(o):
292292
with docker('centos:centos7', o.build_dir, o.pub) as centos7:
@@ -306,8 +306,8 @@ def test_rpm(o):
306306
centos7.system('export PYTHONPATH=${PYTHONPATH}:/usr/local/lib/python2.7/dist-packages')
307307
centos7.system('su postgres -c "createdb mycompany"')
308308
centos7.system('yum install /opt/release/%s -y' % centos7.release)
309-
centos7.system('su openerp -s /bin/bash -c "openerp-server -c /etc/openerp/openerp-server.conf -d mycompany -i base --stop-after-init"')
310-
centos7.system('su openerp -s /bin/bash -c "openerp-server -c /etc/openerp/openerp-server.conf -d mycompany &"')
309+
centos7.system('su odoo -s /bin/bash -c "openerp-server -c /etc/odoo/openerp-server.conf -d mycompany -i base --stop-after-init"')
310+
centos7.system('su odoo -s /bin/bash -c "openerp-server -c /etc/odoo/openerp-server.conf -d mycompany &"')
311311

312312
def test_exe(o):
313313
KVMWinTestExe(o, o.vm_winxp_image, o.vm_winxp_ssh_key, o.vm_winxp_login).start()

0 commit comments

Comments
 (0)