From ed8f0c83c46a5011abb5da772b74c3aed5a32b9d Mon Sep 17 00:00:00 2001
From: Simon Lejeune <sle@openerp.com>
Date: Fri, 23 Sep 2016 22:25:18 +0200
Subject: [PATCH] [REF] cli: renamed openerp-server to odoo-bin

The use of an entry point was considered in order to provide
an `odoo` command in the path for the packages users, but the
generated entry point will first check that all the things in
install_requires were provided in a not bright way: it'll check
that it matches a distribution name. This does not work because
python-chart does not have the distrubtion name "pychart" which
is provided by the python-pychart package in debian jessie. Same
for suds-jurko which is provided by python-suds in debian stretch
but does not have the distribution name "suds".

Also, adapted the  packages tests to these cli changes.
---
 README.md                    |  4 ++--
 debian/init                  |  4 ++--
 doc/git.rst                  |  2 +-
 openerp-server => odoo-bin   |  0
 setup.py                     |  4 ++--
 setup/odoo                   |  5 +++++
 setup/package.py             | 14 +++++++-------
 setup/redhat/postinstall.sh  |  2 +-
 setup/setup_dev.py           |  2 +-
 setup/win32/setup.nsi        |  2 +-
 setup/win32/win32_service.py |  2 +-
 11 files changed, 23 insertions(+), 18 deletions(-)
 rename openerp-server => odoo-bin (100%)
 create mode 100644 setup/odoo

diff --git a/README.md b/README.md
index 2521793ec582..4432013ba167 100644
--- a/README.md
+++ b/README.md
@@ -42,9 +42,9 @@ For Odoo employees
 
 To add the odoo-dev remote use this command:
 
-    $ ./odoo.py setup_git_dev
+    $ ./setup/setup_dev.py setup_git_dev
 
 To fetch odoo merge pull requests refs use this command:
 
-    $ ./odoo.py setup_git_review
+    $ ./setup/setup_dev.py setup_git_review
 
diff --git a/debian/init b/debian/init
index 2a3a165dbee6..41cfe2725bc9 100644
--- a/debian/init
+++ b/debian/init
@@ -1,6 +1,6 @@
 #!/bin/bash
 ### BEGIN INIT INFO
-# Provides:          odoo.py
+# Provides:          odoo
 # Required-Start:    $remote_fs $syslog
 # Required-Stop:     $remote_fs $syslog
 # Default-Start:     2 3 4 5
@@ -14,7 +14,7 @@
 . /lib/lsb/init-functions
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
-DAEMON=/usr/bin/odoo.py
+DAEMON=/usr/bin/odoo
 NAME=odoo
 DESC=odoo
 CONFIG=/etc/odoo/openerp-server.conf
diff --git a/doc/git.rst b/doc/git.rst
index 5ae8bee58513..eb0ba1d7f0bf 100644
--- a/doc/git.rst
+++ b/doc/git.rst
@@ -9,7 +9,7 @@ Initializing a working copy
 
 Use the easy-setup shell script::
 
-     curl -O https://raw.githubusercontent.com/odoo/odoo/master/odoo.py | python2
+     curl -O https://raw.githubusercontent.com/odoo/odoo/10.0/setup/setup_dev.py | python2
 
 it will will ask a few questions and create a local copy.
 
diff --git a/openerp-server b/odoo-bin
similarity index 100%
rename from openerp-server
rename to odoo-bin
diff --git a/setup.py b/setup.py
index c226b1631e3d..a43cd737cbe9 100644
--- a/setup.py
+++ b/setup.py
@@ -57,7 +57,7 @@ def py2exe_options():
         import py2exe
         return {
             'console': [
-                {'script': 'openerp-server', 'icon_resources': [
+                {'script': 'odoo-bin', 'icon_resources': [
                     (1, join('setup', 'win32', 'static', 'pixmaps', 'openerp-icon.ico'))
                 ]},
             ],
@@ -128,7 +128,7 @@ setup(
     author_email=author_email,
     classifiers=filter(None, classifiers.split('\n')),
     license=license,
-    scripts=['openerp-server'],
+    scripts=['setup/odoo'],
     packages=find_packages(),
     package_dir={'%s' % lib_name: 'odoo'},
     include_package_data=True,
diff --git a/setup/odoo b/setup/odoo
new file mode 100644
index 000000000000..3cd3358ee236
--- /dev/null
+++ b/setup/odoo
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+import odoo
+
+if __name__ == "__main__":
+    odoo.cli.main()
diff --git a/setup/package.py b/setup/package.py
index 5bc540e16025..eb517c0a8ab7 100755
--- a/setup/package.py
+++ b/setup/package.py
@@ -217,7 +217,7 @@ class KVMWinTestExe(KVM):
         self.rsync('"%s" %s@127.0.0.1:' % (setuppath, self.login))
         self.ssh("TEMP=/tmp ./%s /S" % setupfile)
         self.ssh('PGPASSWORD=openpgpwd /cygdrive/c/"Program Files"/"Odoo %s"/PostgreSQL/bin/createdb.exe -e -U openpg mycompany' % setupversion)
-        self.ssh('/cygdrive/c/"Program Files"/"Odoo %s"/server/openerp-server.exe -d mycompany -i base --stop-after-init' % setupversion)
+        self.ssh('/cygdrive/c/"Program Files"/"Odoo %s"/server/odoo-bin.exe -d mycompany -i base --stop-after-init' % setupversion)
         self.ssh('net start %s' % nt_service_name)
         _rpc_count_modules(port=18069)
 
@@ -307,8 +307,8 @@ def test_tgz(o):
         wheezy.system('su postgres -s /bin/bash -c "createdb mycompany"')
         wheezy.system('mkdir /var/lib/odoo')
         wheezy.system('chown odoo:odoo /var/lib/odoo')
-        wheezy.system('su odoo -s /bin/bash -c "odoo.py --addons-path=/usr/local/lib/python2.7/dist-packages/odoo/addons -d mycompany -i base --stop-after-init"')
-        wheezy.system('su odoo -s /bin/bash -c "odoo.py --addons-path=/usr/local/lib/python2.7/dist-packages/odoo/addons -d mycompany &"')
+        wheezy.system('su odoo -s /bin/bash -c "odoo --addons-path=/usr/local/lib/python2.7/dist-packages/odoo/addons -d mycompany -i base --stop-after-init"')
+        wheezy.system('su odoo -s /bin/bash -c "odoo --addons-path=/usr/local/lib/python2.7/dist-packages/odoo/addons -d mycompany &"')
 
 def test_deb(o):
     with docker('odoo-%s-debian-nightly-tests' % version, o.build_dir, o.pub) as wheezy:
@@ -317,8 +317,8 @@ def test_deb(o):
         wheezy.system('su postgres -s /bin/bash -c "createdb mycompany"')
         wheezy.system('/usr/bin/dpkg -i /opt/release/%s' % wheezy.release)
         wheezy.system('/usr/bin/apt-get install -f -y')
-        wheezy.system('su odoo -s /bin/bash -c "odoo.py -c /etc/odoo/openerp-server.conf -d mycompany -i base --stop-after-init"')
-        wheezy.system('su odoo -s /bin/bash -c "odoo.py -c /etc/odoo/openerp-server.conf -d mycompany &"')
+        wheezy.system('su odoo -s /bin/bash -c "odoo -c /etc/odoo/openerp-server.conf -d mycompany -i base --stop-after-init"')
+        wheezy.system('su odoo -s /bin/bash -c "odoo -c /etc/odoo/openerp-server.conf -d mycompany &"')
 
 def test_rpm(o):
     with docker('odoo-%s-centos-nightly-tests' % version, o.build_dir, o.pub) as centos7:
@@ -329,8 +329,8 @@ def test_rpm(o):
         centos7.system('su postgres -c "createdb mycompany"')
         # 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 &"')
+        centos7.system('su odoo -s /bin/bash -c "odoo -c /etc/odoo/openerp-server.conf -d mycompany -i base --stop-after-init"')
+        centos7.system('su odoo -s /bin/bash -c "odoo -c /etc/odoo/openerp-server.conf -d mycompany &"')
 
 def test_exe(o):
     KVMWinTestExe(o, o.vm_winxp_image, o.vm_winxp_ssh_key, o.vm_winxp_login).start()
diff --git a/setup/redhat/postinstall.sh b/setup/redhat/postinstall.sh
index e8ada1643189..5261e5f615a6 100644
--- a/setup/redhat/postinstall.sh
+++ b/setup/redhat/postinstall.sh
@@ -52,7 +52,7 @@ After=network.target
 Type=simple
 User=odoo
 Group=odoo
-ExecStart=/usr/bin/odoo.py --config=/etc/odoo/openerp-server.conf
+ExecStart=/usr/bin/odoo --config=/etc/odoo/odoo.conf
 
 [Install]
 WantedBy=multi-user.target
diff --git a/setup/setup_dev.py b/setup/setup_dev.py
index c9efdaf89354..dfea4b67d74e 100755
--- a/setup/setup_dev.py
+++ b/setup/setup_dev.py
@@ -4,7 +4,7 @@
 #
 # To install your odoo development environement type:
 #
-# wget -O- https://raw.githubusercontent.com/odoo/odoo/9.0/odoo.py | python
+# wget -O- https://raw.githubusercontent.com/odoo/odoo/10.0/setup/setup_dev.py | python
 #
 # The setup_* subcommands used to boostrap odoo are defined here inline and may
 # only depends on the python 2.7 stdlib
diff --git a/setup/win32/setup.nsi b/setup/win32/setup.nsi
index a243c39b12ac..c63d460a3215 100755
--- a/setup/win32/setup.nsi
+++ b/setup/win32/setup.nsi
@@ -233,7 +233,7 @@ Section $(TITLE_OpenERP_Server) SectionOpenERP_Server
         WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "pg_path" "$INSTDIR\PostgreSQL\bin"
     ${EndIf}
 
-    nsExec::Exec '"$INSTDIR\server\openerp-server.exe" --stop-after-init --logfile "$INSTDIR\server\openerp-server.log" -s'
+    nsExec::Exec '"$INSTDIR\server\odoo-bin.exe" --stop-after-init --logfile "$INSTDIR\server\odoo.log" -s'
     nsExec::Exec '"$INSTDIR\service\win32_service.exe" -auto -install'
 
     nsExec::Exec "net stop ${SERVICENAME}"
diff --git a/setup/win32/win32_service.py b/setup/win32/win32_service.py
index 5da2083323a1..76b21f4050f7 100644
--- a/setup/win32/win32_service.py
+++ b/setup/win32/win32_service.py
@@ -33,7 +33,7 @@ class OdooService(win32serviceutil.ServiceFramework):
         # We start Odoo as an independent process, but we keep its handle
         service_dir = dirname(sys.argv[0])
         server_dir = split(service_dir)[0]
-        server_path = join(server_dir, 'server', 'openerp-server.exe')
+        server_path = join(server_dir, 'server', 'odoo-bin.exe')
         self.odooprocess = subprocess.Popen(
             [server_path], cwd=server_dir, creationflags=win32process.CREATE_NO_WINDOW
         )
-- 
GitLab