[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:
Simon Lejeune 2014-09-02 14:02:37 +02:00
parent 7db12dc47b
commit 29132669a1
6 changed files with 105 additions and 135 deletions

View File

@ -1,9 +1,11 @@
include Makefile.version
include Makefile.python
SERVER_DIRECTORY=../server
FILES_DIRECTORY=files
SERVER_DIRECTORY=../..
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)
@ -23,14 +25,9 @@ server_clean:
rm -rf $(SERVER_DIRECTORY)/*.exe
rm -rf $(SERVER_DIRECTORY)/.cyg*
server: server_clean
(cd $(SERVER_DIRECTORY)/win32 && $(LAUNCH_PY2EXE))
allinone: server_clean
(cd $(SERVER_DIRECTORY)/setup/win32 && $(LAUNCH_PY2EXE_SERVICE))
(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) && $(LAUNCH_MAKENSIS))
cp $(SERVER_DIRECTORY)/openerp-*.exe $(FILES_DIRECTORY)/openerp-server-setup-$(VERSION).exe
allinone: server
$(LAUNCH_MAKENSIS)
cp ./openerp-*.exe $(FILES_DIRECTORY)/openerp-allinone-setup-$(VERSION).exe
(cd $(SERVER_DIRECTORY)/setup/win32 && $(LAUNCH_MAKENSIS))
(cd $(SERVER_DIRECTORY)/setup/win32 && mkdir -p $(FILES_DIRECTORY))
(cd $(SERVER_DIRECTORY)/setup/win32 && cp openerp-*.exe $(FILES_DIRECTORY)/openerp-server-setup-$(VERSION).exe)

View File

@ -0,0 +1 @@
PYTHON_VERSION=27

View File

@ -0,0 +1 @@
VERSION=

View File

@ -26,6 +26,7 @@
# TODO: Avoid to uninstall the database
# 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 'FileFunc.nsh'
@ -139,9 +140,8 @@ Var HWNDPostgreSQLPassword
!define STATIC_PATH "static"
!define PIXMAPS_PATH "${STATIC_PATH}\pixmaps"
!define POSTGRESQL_EXE "${STATIC_PATH}\postgresql-8.3-int.msi"
!define OPENERP_SERVER_SETUP 'openerp-server-setup-${VERSION}.exe'
!define POSTGRESQL_EXE_FILENAME "postgresql-9.3.5-1-windows.exe"
!define POSTGRESQL_EXE "${STATIC_PATH}\${POSTGRESQL_EXE_FILENAME}"
!define MUI_ABORTWARNING
!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 TITLE_OpenERP_Server ${LANG_FRENCH} "Serveur OpenERP"
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_Server)
Section $(TITLE_OpenERP_Server) SectionOpenERP_Server
SectionIn 1 2
SetOutPath "$TEMP"
File "files\${OPENERP_SERVER_SETUP}"
ExecWait '"$TEMP\${OPENERP_SERVER_SETUP}" /S /D=$INSTDIR\Server'
# TODO: install in a temp dir before
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
WriteIniStr "$INSTDIR\Server\server\openerp-server.conf" "options" "db_host" $TextPostgreSQLHostname
WriteIniStr "$INSTDIR\Server\server\openerp-server.conf" "options" "db_user" $TextPostgreSQLUsername
WriteIniStr "$INSTDIR\Server\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_host" $TextPostgreSQLHostname
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "db_user" $TextPostgreSQLUsername
WriteIniStr "$INSTDIR\server\openerp-server.conf" "options" "db_password" $TextPostgreSQLPassword
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
${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}
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
nsExec::Exec "net start openerp-server-7.0"
nsExec::Exec "net start openerp-server-8.0"
sleep 2
SectionEnd
@ -256,7 +269,7 @@ Section $(TITLE_PostgreSQL) SectionPostgreSQL
SetOutPath '$TEMP'
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"
StrCmp $0 "" win9x
@ -265,7 +278,7 @@ Section $(TITLE_PostgreSQL) SectionPostgreSQL
ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName"
done:
Rmdir /r "$INSTDIR\PostgreSQL"
ExecWait '"$TEMP\postgresql-9.2.2-1-windows.exe" \
ExecWait '"$TEMP\${POSTGRESQL_EXE_FILENAME}" \
--mode unattended \
--prefix "$INSTDIR\PostgreSQL" \
--datadir "$INSTDIR\PostgreSQL\data" \
@ -305,6 +318,10 @@ Section "Uninstall"
ReadRegStr $0 HKLM "${UNINSTALL_REGISTRY_KEY_SERVER}" "UninstallString"
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\service"

View File

@ -1,82 +1,53 @@
# -*- 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 win32service
import servicemanager
import win32api
import win32process
import servicemanager
import win32service
import win32serviceutil
import sys
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):
# required info
_svc_name_ = meta.nt_service_name
_svc_display_name_ = "%s %s" % (meta.description, meta.serie)
execfile(join(dirname(__file__), '..', 'server', 'openerp', 'release.py'))
class OdooService(win32serviceutil.ServiceFramework):
_svc_name_ = nt_service_name
_svc_display_name_ = "%s %s" % (nt_service_name, serie)
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
# a reference to the server's process
self.terpprocess = None
self.odooprocess = None # Reference to the server's process
def SvcStop(self):
# Before we do anything, tell the SCM we are starting the stop process.
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
# stop the running OpenERP Server: say it's a normal exit
win32api.TerminateProcess(int(self.terpprocess._handle), 0)
servicemanager.LogInfoMsg("OpenERP Server 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)
# Stop the running Odoo: say it's a normal exit
win32api.TerminateProcess(int(self.odooprocess._handle), 0)
servicemanager.LogInfoMsg("Odoo stopped correctly")
def SvcDoRun(self):
self.StartTERP()
servicemanager.LogInfoMsg("OpenERP Server up and running")
# exit with same exit code as OpenERP process
sys.exit(self.terpprocess.wait())
# 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')
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):
# 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__':
# Do with the service whatever option is passed in the command line
win32serviceutil.HandleCommandLine(OpenERPServerService, customOptionHandler=option_handler)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
win32serviceutil.HandleCommandLine(OdooService, customOptionHandler=option_handler)

View File

@ -1,32 +1,13 @@
# -*- 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 glob
from distutils.core import setup
import py2exe
from distutils.core import setup
meta = {}
execfile(os.path.join(os.path.dirname(__file__), '..', 'openerp', 'release.py'), meta)
execfile(os.path.join(os.path.dirname(__file__), '..', '..', 'openerp', 'release.py'))
def generate_files():
actions = {
@ -43,29 +24,31 @@ def generate_files():
with open(fname, 'w') as fp:
fp.write('@PATH=%WINDIR%\system32;%WINDIR%;%WINDIR%\System32\Wbem;.\n')
for step in steps:
fp.write('@net %s %s\n' % (step, meta['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],))
fp.write('@net %s %s\n' % (step, nt_service_name))
return files
excludes = "Tkconstants Tkinter tcl _imagingtk PIL._imagingtk ImageTk PIL.ImageTk FixTk".split()
setup(service = ["OpenERPServerService"],
version = meta['version'],
license = meta['license'],
url = meta['url'],
author = meta['author'],
author_email = meta['author_email'],
data_files = generate_files(),
options = {"py2exe": {
"excludes": excludes,
"skip_archive": 1,
"optimize": 2,
}},
)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
setup(
service=["win32_service"],
version=version,
license=license,
url=url,
author=author,
author_email=author_email,
data_files=generate_files(),
options={
"py2exe": {
"excludes": [
'Tkconstants',
'Tkinter',
'tcl',
'_imagingtk',
'PIL._imagingtk',
'ImageTk',
'PIL.ImageTk',
'FixTk'
],
"skip_archive": 1,
"optimize": 2,
}
},
)