Improve windows installer: .prc file assoc, use DOS newlines for prc, error if installing 64-bit version on 32-bit Windows

This commit is contained in:
rdb 2016-11-29 21:53:37 +01:00
parent 7db45cb647
commit 1e2961f7ef
3 changed files with 42 additions and 8 deletions

View File

@ -31,6 +31,7 @@ SetCompressor ${COMPRESSOR}
!include "Sections.nsh"
!include "WinMessages.nsh"
!include "WordFunc.nsh"
!include "x64.nsh"
!define MUI_WELCOMEFINISHPAGE_BITMAP "panda-install.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "panda-install.bmp"
@ -120,6 +121,14 @@ Function runFunction
ExecShell "open" "$SMPROGRAMS\${TITLE}\Panda3D Manual.lnk"
FunctionEnd
Function .onInit
${If} ${REGVIEW} = 64
${AndIfNot} ${RunningX64}
MessageBox MB_OK|MB_ICONEXCLAMATION "You are attempting to install the 64-bit version of Panda3D on a 32-bit version of Windows. Please download and install the 32-bit version of Panda3D instead."
Abort
${EndIf}
FunctionEnd
SectionGroup "Panda3D Libraries"
Section "Core Libraries" SecCore
SectionIn 1 2 RO
@ -634,6 +643,9 @@ Section -post
WriteRegStr HKCU "Software\Classes\.pz" "PerceivedType" "compressed"
WriteRegStr HKCU "Software\Classes\.mf" "" "Panda3D.Multifile"
WriteRegStr HKCU "Software\Classes\.mf" "PerceivedType" "compressed"
WriteRegStr HKCU "Software\Classes\.prc" "" "inifile"
WriteRegStr HKCU "Software\Classes\.prc" "Content Type" "text/plain"
WriteRegStr HKCU "Software\Classes\.prc" "PerceivedType" "text"
; For convenience, if nobody registered .pyd, we will.
ReadRegStr $0 HKCR "Software\Classes\.pyd" ""

View File

@ -2781,8 +2781,13 @@ if (GetTarget() == 'darwin'):
# OpenAL is not yet working well on OSX for us, so let's do this for now.
configprc = configprc.replace("p3openal_audio", "p3fmod_audio")
ConditionalWriteFile(GetOutputDir()+"/etc/Config.prc", configprc)
ConditionalWriteFile(GetOutputDir()+"/etc/Confauto.prc", confautoprc)
if GetTarget() == 'windows':
# Convert to Windows newlines.
ConditionalWriteFile(GetOutputDir()+"/etc/Config.prc", configprc, newline='\r\n')
ConditionalWriteFile(GetOutputDir()+"/etc/Confauto.prc", confautoprc, newline='\r\n')
else:
ConditionalWriteFile(GetOutputDir()+"/etc/Config.prc", configprc)
ConditionalWriteFile(GetOutputDir()+"/etc/Confauto.prc", confautoprc)
##########################################################################################
#
@ -2902,8 +2907,14 @@ if tp_dir is not None:
##
########################################################################
CopyFile(GetOutputDir()+"/", "doc/LICENSE")
CopyFile(GetOutputDir()+"/", "doc/ReleaseNotes")
if GetTarget() == 'windows':
# Convert to Windows newlines so they can be opened by notepad.
WriteFile(GetOutputDir() + "/LICENSE", ReadFile("doc/LICENSE"), newline='\r\n')
WriteFile(GetOutputDir() + "/ReleaseNotes", ReadFile("doc/ReleaseNotes"), newline='\r\n')
else:
CopyFile(GetOutputDir()+"/", "doc/LICENSE")
CopyFile(GetOutputDir()+"/", "doc/ReleaseNotes")
if (PkgSkip("PANDATOOL")==0):
CopyAllFiles(GetOutputDir()+"/plugins/", "pandatool/src/scripts/", ".mel")
CopyAllFiles(GetOutputDir()+"/plugins/", "pandatool/src/scripts/", ".ms")

View File

@ -966,7 +966,12 @@ def ReadBinaryFile(wfile):
ex = sys.exc_info()[1]
exit("Cannot read %s: %s" % (wfile, ex))
def WriteFile(wfile, data):
def WriteFile(wfile, data, newline=None):
if newline is not None:
data = data.replace('\r\n', '\n')
data = data.replace('\r', '\n')
data = data.replace('\n', newline)
try:
dsthandle = open(wfile, "w")
dsthandle.write(data)
@ -984,18 +989,24 @@ def WriteBinaryFile(wfile, data):
ex = sys.exc_info()[1]
exit("Cannot write to %s: %s" % (wfile, ex))
def ConditionalWriteFile(dest, desiredcontents):
def ConditionalWriteFile(dest, data, newline=None):
if newline is not None:
data = data.replace('\r\n', '\n')
data = data.replace('\r', '\n')
data = data.replace('\n', newline)
try:
rfile = open(dest, 'r')
contents = rfile.read(-1)
rfile.close()
except:
contents = 0
if contents != desiredcontents:
if contents != data:
if VERBOSE:
print("Writing %s" % (dest))
sys.stdout.flush()
WriteFile(dest, desiredcontents)
WriteFile(dest, data)
def DeleteVCS(dir):
if dir == "": dir = "."