Windows installer should now ask if the user wants a desktop icon

This commit is contained in:
rdb 2012-01-04 10:21:56 +00:00
parent cbf9c83e23
commit 94fb5c97eb

View File

@ -865,50 +865,57 @@ class Installer:
nsi = open(nsifile.toOsSpecific(), "w") nsi = open(nsifile.toOsSpecific(), "w")
# Some global info # Some global info
nsi.write('Name "%s"\n' % self.fullname) print >>nsi, 'Name "%s"' % self.fullname
nsi.write('OutFile "%s"\n' % output.toOsSpecific()) print >>nsi, 'OutFile "%s"' % output.toOsSpecific()
nsi.write('InstallDir "$PROGRAMFILES\\%s"\n' % self.fullname) print >>nsi, 'InstallDir "$PROGRAMFILES\\%s"' % self.fullname
nsi.write('SetCompress auto\n') print >>nsi, 'SetCompress auto'
nsi.write('SetCompressor lzma\n') print >>nsi, 'SetCompressor lzma'
nsi.write('ShowInstDetails nevershow\n') print >>nsi, 'ShowInstDetails nevershow'
nsi.write('ShowUninstDetails nevershow\n') print >>nsi, 'ShowUninstDetails nevershow'
nsi.write('InstType "Typical"\n') print >>nsi, 'InstType "Typical"'
# Tell Vista that we require admin rights # Tell Vista that we require admin rights
nsi.write('RequestExecutionLevel admin\n') print >>nsi, 'RequestExecutionLevel admin'
nsi.write('\n') print >>nsi
nsi.write('Function launch\n') print >>nsi, 'Function launch'
nsi.write(' ExecShell "open" "$INSTDIR\\%s.exe"\n' % self.shortname) print >>nsi, ' ExecShell "open" "$INSTDIR\\%s.exe"' % self.shortname
nsi.write('FunctionEnd\n') print >>nsi, 'FunctionEnd'
nsi.write('\n') print >>nsi
nsi.write('!include "MUI2.nsh"\n') print >>nsi, 'Function desktopshortcut'
nsi.write('!define MUI_ABORTWARNING\n') print >>nsi, ' CreateShortcut "$DESKTOP\\%s.lnk" "$INSTDIR\\%s.exe"' % (self.fullname, self.shortname)
nsi.write('!define MUI_FINISHPAGE_RUN\n') print >>nsi, 'FunctionEnd'
nsi.write('!define MUI_FINISHPAGE_RUN_FUNCTION launch\n') print >>nsi
nsi.write('!define MUI_FINISHPAGE_RUN_TEXT "Run %s"\n' % self.fullname) print >>nsi, '!include "MUI2.nsh"'
nsi.write('\n') print >>nsi, '!define MUI_ABORTWARNING'
nsi.write('Var StartMenuFolder\n') print >>nsi, '!define MUI_FINISHPAGE_RUN'
nsi.write('!insertmacro MUI_PAGE_WELCOME\n') print >>nsi, '!define MUI_FINISHPAGE_RUN_FUNCTION launch'
print >>nsi, '!define MUI_FINISHPAGE_RUN_TEXT "Run %s"' % self.fullname
print >>nsi, '!define MUI_FINISHPAGE_SHOWREADME ""'
print >>nsi, '!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"'
print >>nsi, '!define MUI_FINISHPAGE_SHOWREADME_FUNCTION desktopshortcut'
print >>nsi
print >>nsi, 'Var StartMenuFolder'
print >>nsi, '!insertmacro MUI_PAGE_WELCOME'
if not self.licensefile.empty(): if not self.licensefile.empty():
abs = Filename(self.licensefile) abs = Filename(self.licensefile)
abs.makeAbsolute() abs.makeAbsolute()
nsi.write('!insertmacro MUI_PAGE_LICENSE "%s"\n' % abs.toOsSpecific()) print >>nsi, '!insertmacro MUI_PAGE_LICENSE "%s"' % abs.toOsSpecific()
nsi.write('!insertmacro MUI_PAGE_DIRECTORY\n') print >>nsi, '!insertmacro MUI_PAGE_DIRECTORY'
nsi.write('!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder\n') print >>nsi, '!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder'
nsi.write('!insertmacro MUI_PAGE_INSTFILES\n') print >>nsi, '!insertmacro MUI_PAGE_INSTFILES'
nsi.write('!insertmacro MUI_PAGE_FINISH\n') print >>nsi, '!insertmacro MUI_PAGE_FINISH'
nsi.write('!insertmacro MUI_UNPAGE_WELCOME\n') print >>nsi, '!insertmacro MUI_UNPAGE_WELCOME'
nsi.write('!insertmacro MUI_UNPAGE_CONFIRM\n') print >>nsi, '!insertmacro MUI_UNPAGE_CONFIRM'
nsi.write('!insertmacro MUI_UNPAGE_INSTFILES\n') print >>nsi, '!insertmacro MUI_UNPAGE_INSTFILES'
nsi.write('!insertmacro MUI_UNPAGE_FINISH\n') print >>nsi, '!insertmacro MUI_UNPAGE_FINISH'
nsi.write('!insertmacro MUI_LANGUAGE "English"\n') print >>nsi, '!insertmacro MUI_LANGUAGE "English"'
# This section defines the installer. # This section defines the installer.
nsi.write('Section "" SecCore\n') print >>nsi, 'Section "" SecCore'
nsi.write(' SetOutPath "$INSTDIR"\n') print >>nsi, ' SetOutPath "$INSTDIR"'
nsi.write(' File "%s"\n' % exefile.toOsSpecific()) print >>nsi, ' File "%s"' % exefile.toOsSpecific()
for f in extrafiles: for f in extrafiles:
nsi.write(' File "%s"\n' % f.toOsSpecific()) print >>nsi, ' File "%s"' % f.toOsSpecific()
curdir = "" curdir = ""
for root, dirs, files in self.os_walk(hostDir.toOsSpecific()): for root, dirs, files in self.os_walk(hostDir.toOsSpecific()):
for name in files: for name in files:
@ -917,30 +924,30 @@ class Installer:
file.makeRelativeTo(hostDir) file.makeRelativeTo(hostDir)
outdir = file.getDirname().replace('/', '\\') outdir = file.getDirname().replace('/', '\\')
if curdir != outdir: if curdir != outdir:
nsi.write(' SetOutPath "$INSTDIR\\%s"\n' % outdir) print >>nsi, ' SetOutPath "$INSTDIR\\%s"' % outdir
curdir = outdir curdir = outdir
nsi.write(' File "%s"\n' % os.path.join(root, name)) print >>nsi, ' File "%s"' % os.path.join(root, name)
nsi.write(' WriteUninstaller "$INSTDIR\\Uninstall.exe"\n') print >>nsi, ' WriteUninstaller "$INSTDIR\\Uninstall.exe"'
nsi.write(' ; Start menu items\n') print >>nsi, ' ; Start menu items'
nsi.write(' !insertmacro MUI_STARTMENU_WRITE_BEGIN Application\n') print >>nsi, ' !insertmacro MUI_STARTMENU_WRITE_BEGIN Application'
nsi.write(' CreateDirectory "$SMPROGRAMS\\$StartMenuFolder"\n') print >>nsi, ' CreateDirectory "$SMPROGRAMS\\$StartMenuFolder"'
nsi.write(' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\%s.lnk" "$INSTDIR\\%s.exe"\n' % (self.fullname, self.shortname)) print >>nsi, ' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\%s.lnk" "$INSTDIR\\%s.exe"' % (self.fullname, self.shortname)
nsi.write(' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\Uninstall.lnk" "$INSTDIR\\Uninstall.exe"\n') print >>nsi, ' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\Uninstall.lnk" "$INSTDIR\\Uninstall.exe"'
nsi.write(' !insertmacro MUI_STARTMENU_WRITE_END\n') print >>nsi, ' !insertmacro MUI_STARTMENU_WRITE_END'
nsi.write('SectionEnd\n') print >>nsi, 'SectionEnd'
# This section defines the uninstaller. # This section defines the uninstaller.
nsi.write('Section Uninstall\n') print >>nsi, 'Section Uninstall'
nsi.write(' Delete "$INSTDIR\\%s.exe"\n' % self.shortname) print >>nsi, ' Delete "$INSTDIR\\%s.exe"' % self.shortname
for f in extrafiles: for f in extrafiles:
nsi.write(' Delete "%s"\n' % f.getBasename()) print >>nsi, ' Delete "%s"' % f.getBasename()
nsi.write(' Delete "$INSTDIR\\Uninstall.exe"\n') print >>nsi, ' Delete "$INSTDIR\\Uninstall.exe"'
nsi.write(' RMDir /r "$INSTDIR"\n') print >>nsi, ' RMDir /r "$INSTDIR"'
nsi.write(' ; Start menu items\n') print >>nsi, ' ; Start menu items'
nsi.write(' !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder\n') print >>nsi, ' !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder'
nsi.write(' Delete "$SMPROGRAMS\\$StartMenuFolder\\Uninstall.lnk"\n') print >>nsi, ' Delete "$SMPROGRAMS\\$StartMenuFolder\\Uninstall.lnk"'
nsi.write(' RMDir "$SMPROGRAMS\\$StartMenuFolder"\n') print >>nsi, ' RMDir "$SMPROGRAMS\\$StartMenuFolder"'
nsi.write('SectionEnd') print >>nsi, 'SectionEnd'
nsi.close() nsi.close()
cmd = [makensis] cmd = [makensis]