[REF][FIX]: Windows packaging: lint, cleanup and make it work
setup.nsi: make it build and use postgresql 9.3 win32_se*: lint and simplified Makefile: only one mode
This commit is contained in:
parent
7db12dc47b
commit
29132669a1
|
@ -1,9 +1,11 @@
|
||||||
include Makefile.version
|
include Makefile.version
|
||||||
|
include Makefile.python
|
||||||
|
|
||||||
SERVER_DIRECTORY=../server
|
SERVER_DIRECTORY=../..
|
||||||
FILES_DIRECTORY=files
|
FILES_DIRECTORY=release
|
||||||
|
|
||||||
LAUNCH_PY2EXE=/cygdrive/c/python26/python.exe setup.py py2exe
|
LAUNCH_PY2EXE_SERVICE=/cygdrive/c/python${PYTHON_VERSION}/python.exe win32_setup.py py2exe
|
||||||
|
LAUNCH_PY2EXE=/cygdrive/c/python${PYTHON_VERSION}/python.exe setup.py py2exe
|
||||||
|
|
||||||
MAKENSIS_ARGUMENTS=/DVERSION=$(VERSION)
|
MAKENSIS_ARGUMENTS=/DVERSION=$(VERSION)
|
||||||
|
|
||||||
|
@ -23,14 +25,9 @@ server_clean:
|
||||||
rm -rf $(SERVER_DIRECTORY)/*.exe
|
rm -rf $(SERVER_DIRECTORY)/*.exe
|
||||||
rm -rf $(SERVER_DIRECTORY)/.cyg*
|
rm -rf $(SERVER_DIRECTORY)/.cyg*
|
||||||
|
|
||||||
server: server_clean
|
allinone: server_clean
|
||||||
(cd $(SERVER_DIRECTORY)/win32 && $(LAUNCH_PY2EXE))
|
(cd $(SERVER_DIRECTORY)/setup/win32 && $(LAUNCH_PY2EXE_SERVICE))
|
||||||
(cd $(SERVER_DIRECTORY) && $(LAUNCH_PY2EXE))
|
(cd $(SERVER_DIRECTORY) && $(LAUNCH_PY2EXE))
|
||||||
# rm -rf `/usr/bin/find ${SERVER_DIRECTORY}/dist/openerp/addons -maxdepth 1 -mindepth 1 -not -name "web*" -and -not -name "base" -type d | xargs rm -rf`
|
(cd $(SERVER_DIRECTORY)/setup/win32 && $(LAUNCH_MAKENSIS))
|
||||||
(cd $(SERVER_DIRECTORY) && $(LAUNCH_MAKENSIS))
|
(cd $(SERVER_DIRECTORY)/setup/win32 && mkdir -p $(FILES_DIRECTORY))
|
||||||
cp $(SERVER_DIRECTORY)/openerp-*.exe $(FILES_DIRECTORY)/openerp-server-setup-$(VERSION).exe
|
(cd $(SERVER_DIRECTORY)/setup/win32 && cp openerp-*.exe $(FILES_DIRECTORY)/openerp-server-setup-$(VERSION).exe)
|
||||||
|
|
||||||
allinone: server
|
|
||||||
$(LAUNCH_MAKENSIS)
|
|
||||||
cp ./openerp-*.exe $(FILES_DIRECTORY)/openerp-allinone-setup-$(VERSION).exe
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
PYTHON_VERSION=27
|
|
@ -0,0 +1 @@
|
||||||
|
VERSION=
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
# TODO: Avoid to uninstall the database
|
# TODO: Avoid to uninstall the database
|
||||||
# TODO: We can update the server or the clients without to uninstall the all-in-one
|
# TODO: We can update the server or the clients without to uninstall the all-in-one
|
||||||
|
# TODO: Add startmenu handling (link to localhost + uninstall)
|
||||||
|
|
||||||
!include 'MUI2.nsh'
|
!include 'MUI2.nsh'
|
||||||
!include 'FileFunc.nsh'
|
!include 'FileFunc.nsh'
|
||||||
|
@ -139,9 +140,8 @@ Var HWNDPostgreSQLPassword
|
||||||
|
|
||||||
!define STATIC_PATH "static"
|
!define STATIC_PATH "static"
|
||||||
!define PIXMAPS_PATH "${STATIC_PATH}\pixmaps"
|
!define PIXMAPS_PATH "${STATIC_PATH}\pixmaps"
|
||||||
!define POSTGRESQL_EXE "${STATIC_PATH}\postgresql-8.3-int.msi"
|
!define POSTGRESQL_EXE_FILENAME "postgresql-9.3.5-1-windows.exe"
|
||||||
|
!define POSTGRESQL_EXE "${STATIC_PATH}\${POSTGRESQL_EXE_FILENAME}"
|
||||||
!define OPENERP_SERVER_SETUP 'openerp-server-setup-${VERSION}.exe'
|
|
||||||
|
|
||||||
!define MUI_ABORTWARNING
|
!define MUI_ABORTWARNING
|
||||||
!define MUI_ICON "${PIXMAPS_PATH}\openerp-icon.ico"
|
!define MUI_ICON "${PIXMAPS_PATH}\openerp-icon.ico"
|
||||||
|
@ -220,33 +220,46 @@ LangString Profile_AllInOne ${LANG_FRENCH} "All In One"
|
||||||
LangString Profile_Server ${LANG_FRENCH} "Seulement le serveur"
|
LangString Profile_Server ${LANG_FRENCH} "Seulement le serveur"
|
||||||
LangString TITLE_OpenERP_Server ${LANG_FRENCH} "Serveur OpenERP"
|
LangString TITLE_OpenERP_Server ${LANG_FRENCH} "Serveur OpenERP"
|
||||||
LangString TITLE_PostgreSQL ${LANG_FRENCH} "Installation du serveur de base de donn?es PostgreSQL"
|
LangString TITLE_PostgreSQL ${LANG_FRENCH} "Installation du serveur de base de donn?es PostgreSQL"
|
||||||
LangString DESC_FinishPageText ${LANG_FRENCH} "Lancer OpenERP"
|
LangString DESC_FinishPageText ${LANG_FRENCH} "Démarrer OpenERP"
|
||||||
|
|
||||||
InstType $(Profile_AllInOne)
|
InstType $(Profile_AllInOne)
|
||||||
InstType $(Profile_Server)
|
InstType $(Profile_Server)
|
||||||
|
|
||||||
Section $(TITLE_OpenERP_Server) SectionOpenERP_Server
|
Section $(TITLE_OpenERP_Server) SectionOpenERP_Server
|
||||||
SectionIn 1 2
|
SectionIn 1 2
|
||||||
SetOutPath "$TEMP"
|
|
||||||
File "files\${OPENERP_SERVER_SETUP}"
|
# TODO: install in a temp dir before
|
||||||
ExecWait '"$TEMP\${OPENERP_SERVER_SETUP}" /S /D=$INSTDIR\Server'
|
|
||||||
|
SetOutPath "$INSTDIR\server"
|
||||||
|
File /r "..\..\dist\*"
|
||||||
|
|
||||||
|
SetOutPath "$INSTDIR\service"
|
||||||
|
File /r "dist\*"
|
||||||
|
File "start.bat"
|
||||||
|
File "stop.bat"
|
||||||
|
|
||||||
# If there is a previous install of the OpenERP Server, keep the login/password from the config file
|
# If there is a previous install of the OpenERP Server, keep the login/password from the config file
|
||||||
WriteIniStr "$INSTDIR\Server\server\openerp-server.conf" "options" "db_host" $TextPostgreSQLHostname
|
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "db_host" $TextPostgreSQLHostname
|
||||||
WriteIniStr "$INSTDIR\Server\server\openerp-server.conf" "options" "db_user" $TextPostgreSQLUsername
|
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "db_user" $TextPostgreSQLUsername
|
||||||
WriteIniStr "$INSTDIR\Server\server\openerp-server.conf" "options" "db_password" $TextPostgreSQLPassword
|
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "db_password" $TextPostgreSQLPassword
|
||||||
WriteIniStr "$INSTDIR\Server\server\openerp-server.conf" "options" "db_port" $TextPostgreSQLPort
|
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "db_port" $TextPostgreSQLPort
|
||||||
|
# Fix the addons path
|
||||||
|
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "addons_path" "$INSTDIR\server\openerp\addons"
|
||||||
|
|
||||||
# if we've going to install postgresql force it's path,
|
# if we're going to install postgresql force it's path,
|
||||||
# otherwise we consider it's always done and/or correctly tune by users
|
# otherwise we consider it's always done and/or correctly tune by users
|
||||||
${If} $HasPostgreSQL == 0
|
${If} $HasPostgreSQL == 0
|
||||||
WriteIniStr "$INSTDIR\Server\server\openerp-server.conf" "options" "pg_path" "$INSTDIR\PostgreSQL\bin"
|
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "pg_path" "$INSTDIR\PostgreSQL\bin"
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
nsExec::Exec "net stop openerp-server-7.0"
|
nsExec::Exec '"$INSTDIR\server\openerp-server.exe" --stop-after-init --logfile "$INSTDIR\server\openerp-server.log" -s'
|
||||||
|
nsExec::Exec '"$INSTDIR\service\win32_service.exe" -auto -install'
|
||||||
|
|
||||||
|
# TODO: don't hardcode the service name
|
||||||
|
nsExec::Exec "net stop openerp-server-8.0"
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
nsExec::Exec "net start openerp-server-7.0"
|
nsExec::Exec "net start openerp-server-8.0"
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
@ -256,7 +269,7 @@ Section $(TITLE_PostgreSQL) SectionPostgreSQL
|
||||||
SetOutPath '$TEMP'
|
SetOutPath '$TEMP'
|
||||||
nsExec::Exec 'net user openpgsvc /delete'
|
nsExec::Exec 'net user openpgsvc /delete'
|
||||||
|
|
||||||
File "postgresql-9.2.2-1-windows.exe"
|
File ${POSTGRESQL_EXE}
|
||||||
|
|
||||||
ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName"
|
ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName"
|
||||||
StrCmp $0 "" win9x
|
StrCmp $0 "" win9x
|
||||||
|
@ -265,7 +278,7 @@ Section $(TITLE_PostgreSQL) SectionPostgreSQL
|
||||||
ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName"
|
ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName"
|
||||||
done:
|
done:
|
||||||
Rmdir /r "$INSTDIR\PostgreSQL"
|
Rmdir /r "$INSTDIR\PostgreSQL"
|
||||||
ExecWait '"$TEMP\postgresql-9.2.2-1-windows.exe" \
|
ExecWait '"$TEMP\${POSTGRESQL_EXE_FILENAME}" \
|
||||||
--mode unattended \
|
--mode unattended \
|
||||||
--prefix "$INSTDIR\PostgreSQL" \
|
--prefix "$INSTDIR\PostgreSQL" \
|
||||||
--datadir "$INSTDIR\PostgreSQL\data" \
|
--datadir "$INSTDIR\PostgreSQL\data" \
|
||||||
|
@ -305,6 +318,10 @@ Section "Uninstall"
|
||||||
ReadRegStr $0 HKLM "${UNINSTALL_REGISTRY_KEY_SERVER}" "UninstallString"
|
ReadRegStr $0 HKLM "${UNINSTALL_REGISTRY_KEY_SERVER}" "UninstallString"
|
||||||
ExecWait '"$0" /S'
|
ExecWait '"$0" /S'
|
||||||
|
|
||||||
|
nsExec::Exec "net stop openerp-server-8.0"
|
||||||
|
nsExec::Exec "sc delete openerp-server-8.0"
|
||||||
|
sleep 2
|
||||||
|
|
||||||
Rmdir /r "$INSTDIR\server"
|
Rmdir /r "$INSTDIR\server"
|
||||||
Rmdir /r "$INSTDIR\service"
|
Rmdir /r "$INSTDIR\service"
|
||||||
|
|
||||||
|
|
|
@ -1,82 +1,53 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
import win32serviceutil
|
import servicemanager
|
||||||
import win32service
|
|
||||||
import win32api
|
import win32api
|
||||||
import win32process
|
import win32process
|
||||||
import servicemanager
|
import win32service
|
||||||
|
import win32serviceutil
|
||||||
|
|
||||||
import sys
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import sys
|
||||||
|
from os.path import dirname, join, split
|
||||||
|
|
||||||
try:
|
|
||||||
import meta
|
|
||||||
except ImportError:
|
|
||||||
if hasattr(sys, 'frozen'):
|
|
||||||
raise
|
|
||||||
from setup import generate_files
|
|
||||||
generate_files()
|
|
||||||
import meta # noqa
|
|
||||||
|
|
||||||
class OpenERPServerService(win32serviceutil.ServiceFramework):
|
execfile(join(dirname(__file__), '..', 'server', 'openerp', 'release.py'))
|
||||||
# required info
|
|
||||||
_svc_name_ = meta.nt_service_name
|
|
||||||
_svc_display_name_ = "%s %s" % (meta.description, meta.serie)
|
class OdooService(win32serviceutil.ServiceFramework):
|
||||||
|
_svc_name_ = nt_service_name
|
||||||
|
_svc_display_name_ = "%s %s" % (nt_service_name, serie)
|
||||||
|
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
win32serviceutil.ServiceFramework.__init__(self, args)
|
win32serviceutil.ServiceFramework.__init__(self, args)
|
||||||
# a reference to the server's process
|
self.odooprocess = None # Reference to the server's process
|
||||||
self.terpprocess = None
|
|
||||||
|
|
||||||
def SvcStop(self):
|
def SvcStop(self):
|
||||||
# Before we do anything, tell the SCM we are starting the stop process.
|
# Before we do anything, tell the SCM we are starting the stop process.
|
||||||
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
|
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
|
||||||
# stop the running OpenERP Server: say it's a normal exit
|
# Stop the running Odoo: say it's a normal exit
|
||||||
win32api.TerminateProcess(int(self.terpprocess._handle), 0)
|
win32api.TerminateProcess(int(self.odooprocess._handle), 0)
|
||||||
servicemanager.LogInfoMsg("OpenERP Server stopped correctly")
|
servicemanager.LogInfoMsg("Odoo stopped correctly")
|
||||||
|
|
||||||
def StartTERP(self):
|
|
||||||
# The server finds now its configuration automatically on Windows
|
|
||||||
# We start the ERP Server as an independent process, but we keep its handle
|
|
||||||
# The server's binary must be one directory above the service's binary (when py2exe'd the python libraries shouldn' mix)
|
|
||||||
service_dir = os.path.dirname(sys.argv[0])
|
|
||||||
server_dir = os.path.split(service_dir)[0]
|
|
||||||
server_path = os.path.join(server_dir, 'server', 'openerp-server.exe')
|
|
||||||
self.terpprocess = subprocess.Popen([server_path], cwd=server_dir, creationflags=win32process.CREATE_NO_WINDOW)
|
|
||||||
|
|
||||||
def SvcDoRun(self):
|
def SvcDoRun(self):
|
||||||
self.StartTERP()
|
# We start Odoo as an independent process, but we keep its handle
|
||||||
servicemanager.LogInfoMsg("OpenERP Server up and running")
|
service_dir = dirname(sys.argv[0])
|
||||||
# exit with same exit code as OpenERP process
|
server_dir = split(service_dir)[0]
|
||||||
sys.exit(self.terpprocess.wait())
|
server_path = join(server_dir, 'server', 'openerp-server.exe')
|
||||||
|
self.odooprocess = subprocess.Popen(
|
||||||
|
[server_path], cwd=server_dir, creationflags=win32process.CREATE_NO_WINDOW
|
||||||
|
)
|
||||||
|
servicemanager.LogInfoMsg('Odoo up and running')
|
||||||
|
# exit with same exit code as Odoo process
|
||||||
|
sys.exit(self.odooprocess.wait())
|
||||||
|
|
||||||
|
|
||||||
def option_handler(opts):
|
def option_handler(opts):
|
||||||
# configure the service to auto restart on failures...
|
# configure the service to auto restart on failures...
|
||||||
subprocess.call(['sc', 'failure', meta.nt_service_name, 'reset=', '0', 'actions=', 'restart/0/restart/0/restart/0'])
|
subprocess.call([
|
||||||
|
'sc', 'failure', nt_service_name, 'reset=', '0', 'actions=', 'restart/0/restart/0/restart/0'
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Do with the service whatever option is passed in the command line
|
win32serviceutil.HandleCommandLine(OdooService, customOptionHandler=option_handler)
|
||||||
win32serviceutil.HandleCommandLine(OpenERPServerService, customOptionHandler=option_handler)
|
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
||||||
|
|
|
@ -1,32 +1,13 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
from distutils.core import setup
|
|
||||||
import py2exe
|
import py2exe
|
||||||
|
from distutils.core import setup
|
||||||
|
|
||||||
|
|
||||||
meta = {}
|
execfile(os.path.join(os.path.dirname(__file__), '..', '..', 'openerp', 'release.py'))
|
||||||
execfile(os.path.join(os.path.dirname(__file__), '..', 'openerp', 'release.py'), meta)
|
|
||||||
|
|
||||||
def generate_files():
|
def generate_files():
|
||||||
actions = {
|
actions = {
|
||||||
|
@ -43,29 +24,31 @@ def generate_files():
|
||||||
with open(fname, 'w') as fp:
|
with open(fname, 'w') as fp:
|
||||||
fp.write('@PATH=%WINDIR%\system32;%WINDIR%;%WINDIR%\System32\Wbem;.\n')
|
fp.write('@PATH=%WINDIR%\system32;%WINDIR%;%WINDIR%\System32\Wbem;.\n')
|
||||||
for step in steps:
|
for step in steps:
|
||||||
fp.write('@net %s %s\n' % (step, meta['nt_service_name']))
|
fp.write('@net %s %s\n' % (step, nt_service_name))
|
||||||
|
|
||||||
files.append('meta.py')
|
|
||||||
with open('meta.py', 'w') as fp:
|
|
||||||
for m in 'description serie nt_service_name'.split():
|
|
||||||
fp.write("%s = %r\n" % (m, meta[m],))
|
|
||||||
|
|
||||||
return files
|
return files
|
||||||
|
|
||||||
excludes = "Tkconstants Tkinter tcl _imagingtk PIL._imagingtk ImageTk PIL.ImageTk FixTk".split()
|
setup(
|
||||||
|
service=["win32_service"],
|
||||||
setup(service = ["OpenERPServerService"],
|
version=version,
|
||||||
version = meta['version'],
|
license=license,
|
||||||
license = meta['license'],
|
url=url,
|
||||||
url = meta['url'],
|
author=author,
|
||||||
author = meta['author'],
|
author_email=author_email,
|
||||||
author_email = meta['author_email'],
|
data_files=generate_files(),
|
||||||
data_files = generate_files(),
|
options={
|
||||||
options = {"py2exe": {
|
"py2exe": {
|
||||||
"excludes": excludes,
|
"excludes": [
|
||||||
"skip_archive": 1,
|
'Tkconstants',
|
||||||
"optimize": 2,
|
'Tkinter',
|
||||||
}},
|
'tcl',
|
||||||
)
|
'_imagingtk',
|
||||||
|
'PIL._imagingtk',
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
'ImageTk',
|
||||||
|
'PIL.ImageTk',
|
||||||
|
'FixTk'
|
||||||
|
],
|
||||||
|
"skip_archive": 1,
|
||||||
|
"optimize": 2,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue