Everything is now working well, and today I successfully made my first Installer , which leads to my 3 questions...
1. From what I can see, the option "pkg-win-snapshot" in the makefile simply appends the SVN revision number to the filename and file version information. Is this assumption correct, or is there some more fundamental difference between a snapshot and a release version?
2. The default installer as created by OOlite.nsi attempts to uninstall Oolite before proceeding. In other words, it wants to perform an upgrade. What I want to do is create an installer which will allow me to have both 1.72.2 AND trunk installed simultaneously. I have produced a modified version of OOlite.nsi which I believe will accomplish this goal. I'm tempted to simply go ahead and test it, but the more cautious side of me would like confirmation from somebody with more experience in this area first. Have I got it right?
I've modified cosmetic references of Oolite to Oolite-Trunk
InstallDir changed to Oolite-Trunk
All registry keys and strings changed to Oolite-Trunk
Start Menu entries changed to Oolite-Trunk
So far as I can judge, this will allow me to install/upgrade/uninstall both 1.72 and trunk independently of each other.
This is my edited OOlite.nsi script (OOlite_Trunk.nsi).
Code: Select all
; Need to include the versions as we can't pass them in as parameters
; and it's too much work to try to dynamically edit this file
!include /NONFATAL "OoliteVersions.nsh"
!ifndef SVNREV
!warning "No SVN Revision supplied"
!define SVNREV 0
!endif
!ifndef VERSION
!warning "No Version information supplied"
!define VERSION 0.0.0.0
!endif
; Version number must be of format X.X.X.X.
; We use M.m.R.S: M-major, m-minor, R-revision, S-subversion
!define VER ${VERSION}
!ifndef DST
!define DST ..\..\oolite.app
!endif
!ifndef OUTDIR
!define OUTDIR .
!endif
!ifndef SNAPSHOT
!define EXTVER ""
!else
!define EXTVER "-dev"
!endif
!include "MUI.nsh"
SetCompress auto
SetCompressor LZMA
SetCompressorDictSize 32
SetDatablockOptimize on
OutFile "${OUTDIR}\OoliteInstall-${VER}${EXTVER}.exe"
BrandingText "(C) 2003-2009 Giles Williams and contributors"
Name "Oolite"
Caption "Oolite ${VER}${EXTVER} (Trunk Version) Setup"
SubCaption 0 " "
SubCaption 1 " "
SubCaption 2 " "
SubCaption 3 " "
SubCaption 4 " "
Icon Oolite.ico
UninstallIcon Oolite.ico
InstallDirRegKey HKLM Software\Oolite-Trunk "Install_Dir"
InstallDir $PROGRAMFILES\Oolite-Trunk
CRCCheck on
InstallColors /windows
InstProgressFlags smooth
AutoCloseWindow false
SetOverwrite on
VIAddVersionKey "ProductName" "Oolite"
VIAddVersionKey "FileDescription" "A space combat/trading game, inspired by Elite."
VIAddVersionKey "LegalCopyright" "© 2003-2009 Giles Williams and contributors"
VIAddVersionKey "FileVersion" "${VER}"
!ifdef SNAPSHOT
VIAddVersionKey "SVN Revision" "${SVNREV}"
!endif
!ifdef BUILDTIME
VIAddVersionKey "Build Time" "${BUILDTIME}"
!endif
VIProductVersion "${VER}"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP ".\OoliteInstallerHeaderBitmap_ModernUI.bmp"
!define MUI_HEADERIMAGE_UNBITMAP ".\OoliteInstallerHeaderBitmap_ModernUI.bmp"
!define MUI_ICON oolite.ico
!define MUI_UNICON oolite.ico
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Function .onInit
; 1. Check for multiple running installers
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "OoliteInstallerMutex") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "Another instance of the Oolite installer is already running."
Abort
; 2. Checks for already-installed versions of Oolite-Trunk and offers to uninstall
ReadRegStr $R0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Oolite-Trunk" \
"UninstallString"
StrCmp $R0 "" done
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"Oolite-Trunk is already installed. $\n$\nClick `OK` to remove the \
previous version or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort
;Run the uninstaller
uninst:
ClearErrors
ExecWait '$R0 _?=$INSTDIR'
IfErrors no_remove_uninstaller
Delete "$INSTDIR\UninstOolite.exe"
Goto done
no_remove_uninstaller:
MessageBox MB_OK|MB_ICONEXCLAMATION "The Uninstaller did not complete successfully. Please ensure Oolite-Trunk was correctly uninstalled then run the installer again."
Abort
done:
FunctionEnd
Function RegSetup
FunctionEnd
Function un.RegSetup
FunctionEnd
;------------------------------------------------------------
; Installation Section
Section ""
SetOutPath $INSTDIR
; Package files
CreateDirectory "$INSTDIR\AddOns"
File "Oolite.ico"
File "Oolite_Readme.txt"
File "OoliteRS.pdf"
File "..\..\Doc\AdviceForNewCommanders.pdf"
File /r /x .svn /x *~ "${DST}"
WriteUninstaller "$INSTDIR\UninstOolite.exe"
; Registry entries
WriteRegStr HKLM Software\Oolite-Trunk "Install_Dir" "$INSTDIR"
WriteRegStr HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\Oolite-Trunk DisplayName "Oolite ${VER}${EXTVER}"
WriteRegStr HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\Oolite-Trunk UninstallString '"$INSTDIR\UninstOolite.exe"'
; Start Menu shortcuts
SetOutPath $INSTDIR\oolite.app
CreateDirectory "$SMPROGRAMS\Oolite-Trunk"
CreateShortCut "$SMPROGRAMS\Oolite-Trunk\Oolite.lnk" "$INSTDIR\oolite.app\oolite.exe" "" "$INSTDIR\Oolite.ico"
CreateShortCut "$SMPROGRAMS\Oolite-Trunk\Oolite ReadMe.lnk" "$INSTDIR\Oolite_Readme.txt"
CreateShortCut "$SMPROGRAMS\Oolite-Trunk\Oolite Reference Sheet.lnk" "$INSTDIR\OoliteRS.pdf"
CreateShortCut "$SMPROGRAMS\Oolite-Trunk\Oolite Website.lnk" "http://oolite.org/"
CreateShortCut "$SMPROGRAMS\Oolite-Trunk\Oolite Uninstall.lnk" "$INSTDIR\UninstOolite.exe"
Call RegSetup
Exec "notepad.exe $INSTDIR\Oolite_Readme.txt"
SectionEnd
;------------------------------------------------------------
; Uninstaller Section
Section "Uninstall"
; Remove registry entries
DeleteRegKey HKLM Software\Oolite-Trunk
DeleteRegKey HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\Oolite-Trunk
Call un.RegSetup
; Remove Start Menu entries
RMDir /r "$SMPROGRAMS\Oolite-Trunk"
; Remove Package files (but leave any generated content behind)
RMDir /r "$INSTDIR\oolite.app\Contents"
RMDir /r "$INSTDIR\oolite.app\GNUstep"
RMDir /r "$INSTDIR\oolite.app\oolite.app"
RMDir /r "$INSTDIR\oolite.app\Resources"
RMDir /r "$INSTDIR\oolite.app\Logs"
Delete "$INSTDIR\*.*"
Delete "$INSTDIR\oolite.app\*.*"
SectionEnd
3. As an aside, clearly OOlite.nsi is the script that would need to be modified in order to make an installer which automatically changes the default install-directory if it is running on Vista. I don't know how this would be done, (or indeed if it can be) but is anybody currently investigating the possibility?