|
From: Tapio V. <aa...@us...> - 2010-08-03 11:36:37
|
Module: performous Branch: joinmenu Commit: 25c741381324761dc21dccd299cad150934eacb0 Author: John Stumpo <st...@js...> Date: Sat Jun 26 03:10:36 2010 -0400 Add a script to generate a simple NSIS installer from the staged installation. As it is, it works (it installs and uninstalls just fine) but could use a bit of extra love. (Start menu entries and an Add/Remove Programs entry come to mind.) --- win32/cross-from-debian/makepackage.py | 111 ++++++++++++++++++++++++++++++++ 1 files changed, 111 insertions(+), 0 deletions(-) diff --git a/win32/cross-from-debian/makepackage.py b/win32/cross-from-debian/makepackage.py new file mode 100755 index 0000000..2ad6342 --- /dev/null +++ b/win32/cross-from-debian/makepackage.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python +# NSIS script generator for Performous. +# Copyright (C) 2010 John Stumpo +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +import os +import subprocess +import sys + +try: + makensis = subprocess.Popen([os.environ['MAKENSIS'], '-'], stdin=subprocess.PIPE) +except KeyError: + makensis = subprocess.Popen(['makensis', '-'], stdin=subprocess.PIPE) + +if not os.path.isdir('dist'): + os.mkdir('dist') +os.chdir('stage') + +# Find the version number. +try: + resources = subprocess.Popen([os.environ['WINDRES'], 'bin/performous.exe'], stdout=subprocess.PIPE) +except: + try: + resources = subprocess.Popen(['windres', 'bin/performous.exe'], stdout=subprocess.PIPE) + except: + resources = subprocess.Popen(['i586-mingw32msvc-windres', 'bin/performous.exe'], stdout=subprocess.PIPE) +for line in resources.stdout.readlines(): + if not line.strip().startswith('VALUE'): + continue + if 'ProductVersion' in line: + version = line.strip().split('"')[-2] + break +else: + version = 'unknown' + + +makensis.stdin.write(r'''!include "MUI2.nsh" + +!define VERSION "%s" + +Name "Performous ${VERSION}" +OutFile "dist\Performous-${VERSION}-win32.exe" + +SetCompressor /SOLID lzma + +ShowInstDetails show +ShowUninstDetails show + +InstallDir "$PROGRAMFILES\Performous" +InstallDirRegKey HKLM "Software\Performous" "" + +RequestExecutionLevel admin + +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_PAGE_FINISH + +!insertmacro MUI_UNPAGE_WELCOME +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +!insertmacro MUI_UNPAGE_FINISH + +!insertmacro MUI_LANGUAGE "English" + +Section +''' % version) + +for root, dirs, files in os.walk('.'): + makensis.stdin.write(' SetOutPath "$INSTDIR\\%s"\n' % root.replace('/', '\\')) + for file in files: + makensis.stdin.write(' File "%s"\n' % os.path.join('stage', root, file).replace('/', '\\')) + +makensis.stdin.write(r''' WriteRegStr HKLM "Software\Performous" "" "$INSTDIR" + WriteUninstaller "$INSTDIR\uninst.exe" +SectionEnd + +Section Uninstall +''') + +for root, dirs, files in os.walk('.', topdown=False): + for dir in dirs: + makensis.stdin.write(' RmDir "$INSTDIR\\%s"\n' % os.path.join(root, dir).replace('/', '\\')) + for file in files: + makensis.stdin.write(' Delete "$INSTDIR\\%s"\n' % os.path.join(root, file).replace('/', '\\')) + makensis.stdin.write(' RmDir "$INSTDIR\\%s"\n' % root.replace('/', '\\')) + +makensis.stdin.write(r''' Delete "$INSTDIR\uninst.exe" + RmDir "$INSTDIR" + DeleteRegKey /ifempty HKLM "Software\Performous" +SectionEnd +''') + +makensis.stdin.close() +if makensis.wait() != 0: + print >>sys.stderr, 'Installer compilation failed.' + sys.exit(1) +else: + print '\ndist/Performous-%s-win32.exe is ready.' % version |