From 8c2c9e207be63f90fa7f98a501f879a3bc288d4b Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 8 Nov 2016 19:30:35 +0100 Subject: [PATCH] build: windows installer fixups - make whitespace in build/*.{nsi,nsh} consistenly two spaces - remove bootnode, disasm from alltools archives - use whole-installer lzma compression - add git commit to the displayed version string - place installer .exe in the repository root - never delete the -workdir --- build/ci.go | 44 +++++++-------- build/nsis.geth.nsi | 19 ++++--- build/nsis.install.nsh | 118 +++++++++++++++++++-------------------- build/nsis.uninstall.nsh | 46 +++++++-------- 4 files changed, 113 insertions(+), 114 deletions(-) diff --git a/build/ci.go b/build/ci.go index 24fe1d3966..f5ef54b754 100644 --- a/build/ci.go +++ b/build/ci.go @@ -69,8 +69,6 @@ var ( executablePath("evm"), executablePath("geth"), executablePath("rlpdump"), - executablePath("disasm"), - executablePath("bootnode"), } // A debian package is created for all executables listed here. @@ -579,22 +577,6 @@ func doWindowsInstaller(cmdline []string) { env := build.Env() maybeSkipArchive(env) - defer os.RemoveAll(*workdir) - - // Configure and run the NSIS installer maker. This assumes that all the needed - // files have been previously built (don't mix building and packaging to keep - // cross compilation complexity to a minimum). - var ( - base = archiveBasename(*arch, env) - installerName = "geth-" + base - installFilename = "/DOUTPUTFILE=" + installerName - - version = strings.Split(build.VERSION(), ".") - majorVersion = "/DMAJORVERSION=" + version[0] - minorVersion = "/DMINORVERSION=" + version[1] - buildId = "/DBUILDVERSION=" + version[2] - buildArch = "/DARCH=" + *arch - ) // Aggregate binaries that are included in the installer var ( devTools []string @@ -612,26 +594,40 @@ func doWindowsInstaller(cmdline []string) { devTools = append(devTools, file) } } + // Render NSIS scripts: Installer NSIS contains two installer sections, // first section contains the geth binary, second section holds the dev tools. - installer := map[string]interface{}{ + templateData := map[string]interface{}{ "License": "COPYING", "Geth": gethTool, "DevTools": devTools, } build.Render("build/nsis.geth.nsi", filepath.Join(*workdir, "geth.nsi"), 0644, nil) - build.Render("build/nsis.install.nsh", filepath.Join(*workdir, "install.nsh"), 0644, installer) + build.Render("build/nsis.install.nsh", filepath.Join(*workdir, "install.nsh"), 0644, templateData) build.Render("build/nsis.uninstall.nsh", filepath.Join(*workdir, "uninstall.nsh"), 0644, allTools) build.Render("build/nsis.envvarupdate.nsh", filepath.Join(*workdir, "EnvVarUpdate.nsh"), 0644, nil) - build.CopyFile(filepath.Join(*workdir, "SimpleFC.dll"), "build/nsis.simplefc.dll", 0755) build.CopyFile(filepath.Join(*workdir, "COPYING"), "COPYING", 0755) - makensis := exec.Command("makensis.exe", installFilename, majorVersion, minorVersion, buildId, buildArch, filepath.Join(*workdir, "geth.nsi")) - build.MustRun(makensis) + // Build the installer. This assumes that all the needed files have been previously + // built (don't mix building and packaging to keep cross compilation complexity to a + // minimum). + version := strings.Split(build.VERSION(), ".") + if env.Commit != "" { + version[2] += "-" + env.Commit[:8] + } + installer, _ := filepath.Abs("geth-" + archiveBasename(*arch, env) + ".exe") + build.MustRunCommand("makensis.exe", + "/DOUTPUTFILE="+installer, + "/DMAJORVERSION="+version[0], + "/DMINORVERSION="+version[1], + "/DBUILDVERSION="+version[2], + "/DARCH="+*arch, + filepath.Join(*workdir, "geth.nsi"), + ) // Sign and publish installer. - if err := archiveUpload(filepath.Join(*workdir, installerName+".exe"), *upload, *signer); err != nil { + if err := archiveUpload(installer, *upload, *signer); err != nil { log.Fatal(err) } } diff --git a/build/nsis.geth.nsi b/build/nsis.geth.nsi index 8c5cf4cc5d..dbeb9319c9 100644 --- a/build/nsis.geth.nsi +++ b/build/nsis.geth.nsi @@ -33,6 +33,9 @@ CRCCheck on # Require admin rights on NT6+ (When UAC is turned on) RequestExecutionLevel admin +# Use LZMA compression +SetCompressor /SOLID lzma + !include LogicLib.nsh !include EnvVarUpdate.nsh @@ -40,21 +43,21 @@ RequestExecutionLevel admin UserInfo::GetAccountType pop $0 ${If} $0 != "admin" # Require admin rights on NT4+ - messageBox mb_iconstop "Administrator rights required!" - setErrorLevel 740 # ERROR_ELEVATION_REQUIRED - quit + messageBox mb_iconstop "Administrator rights required!" + setErrorLevel 740 # ERROR_ELEVATION_REQUIRED + quit ${EndIf} !macroend function .onInit - # make vars are global for all users since geth is installed global - setShellVarContext all - !insertmacro VerifyUserIsAdmin + # make vars are global for all users since geth is installed global + setShellVarContext all + !insertmacro VerifyUserIsAdmin ${If} ${ARCH} == "amd64" - StrCpy $InstDir "$PROGRAMFILES64\${APPNAME}" + StrCpy $InstDir "$PROGRAMFILES64\${APPNAME}" ${Else} - StrCpy $InstDir "$PROGRAMFILES32\${APPNAME}" + StrCpy $InstDir "$PROGRAMFILES32\${APPNAME}" ${Endif} functionEnd diff --git a/build/nsis.install.nsh b/build/nsis.install.nsh index d6bf63daf5..f9ad8e95e1 100644 --- a/build/nsis.install.nsh +++ b/build/nsis.install.nsh @@ -1,6 +1,6 @@ Name "geth ${MAJORVERSION}.${MINORVERSION}.${BUILDVERSION}" # VERSION variables set through command line arguments InstallDir "$InstDir" -OutFile "${OUTPUTFILE}.exe" # OUTPUTFILE set through command line arguments +OutFile "${OUTPUTFILE}" # set through command line arguments # Links for "Add/Remove Programs" !define HELPURL "https://github.com/ethereum/go-ethereum/issues" @@ -9,92 +9,92 @@ OutFile "${OUTPUTFILE}.exe" # OUTPUTFILE set through command line arguments !define /date NOW "%Y%m%d" PageEx license - LicenseData {{.License}} + LicenseData {{.License}} PageExEnd # Install geth binary Section "Geth" GETH_IDX - SetOutPath $INSTDIR - file {{.Geth}} + SetOutPath $INSTDIR + file {{.Geth}} - # Create start menu launcher - createDirectory "$SMPROGRAMS\${APPNAME}" - createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\geth.exe" "--fast" "--cache=512" - createShortCut "$SMPROGRAMS\${APPNAME}\Attach.lnk" "$INSTDIR\geth.exe" "attach" "" "" - createShortCut "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "" "" + # Create start menu launcher + createDirectory "$SMPROGRAMS\${APPNAME}" + createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\geth.exe" "--fast" "--cache=512" + createShortCut "$SMPROGRAMS\${APPNAME}\Attach.lnk" "$INSTDIR\geth.exe" "attach" "" "" + createShortCut "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "" "" - # Firewall - remove rules (if exists) - SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)" - SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)" - SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)" + # Firewall - remove rules (if exists) + SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)" + SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)" + SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)" - # Firewall - add rules - SimpleFC::AdvAddRule "Geth incoming peers (TCP:30303)" "" 6 1 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" 30303 "" "" "" - SimpleFC::AdvAddRule "Geth outgoing peers (TCP:30303)" "" 6 2 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" "" 30303 "" "" - SimpleFC::AdvAddRule "Geth UDP discovery (UDP:30303)" "" 17 2 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" "" 30303 "" "" + # Firewall - add rules + SimpleFC::AdvAddRule "Geth incoming peers (TCP:30303)" "" 6 1 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" 30303 "" "" "" + SimpleFC::AdvAddRule "Geth outgoing peers (TCP:30303)" "" 6 2 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" "" 30303 "" "" + SimpleFC::AdvAddRule "Geth UDP discovery (UDP:30303)" "" 17 2 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" "" 30303 "" "" - # Set default IPC endpoint (https://github.com/ethereum/EIPs/issues/147) - ${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc" - ${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "A" "HKLM" "\\.\pipe\geth.ipc" + # Set default IPC endpoint (https://github.com/ethereum/EIPs/issues/147) + ${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc" + ${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "A" "HKLM" "\\.\pipe\geth.ipc" - # Add geth to PATH - ${EnvVarUpdate} $0 "PATH" "A" "HKLM" $INSTDIR + # Add geth to PATH + ${EnvVarUpdate} $0 "PATH" "A" "HKLM" $INSTDIR SectionEnd # Install optional develop tools. Section /o "Development tools" DEV_TOOLS_IDX - SetOutPath $INSTDIR - {{range .DevTools}}file {{.}} - {{end}} + SetOutPath $INSTDIR + {{range .DevTools}}file {{.}} + {{end}} SectionEnd # Return on top of stack the total size (as DWORD) of the selected/installed sections. Var GetInstalledSize.total Function GetInstalledSize - StrCpy $GetInstalledSize.total 0 + StrCpy $GetInstalledSize.total 0 - ${if} ${SectionIsSelected} ${GETH_IDX} - SectionGetSize ${GETH_IDX} $0 - IntOp $GetInstalledSize.total $GetInstalledSize.total + $0 - ${endif} + ${if} ${SectionIsSelected} ${GETH_IDX} + SectionGetSize ${GETH_IDX} $0 + IntOp $GetInstalledSize.total $GetInstalledSize.total + $0 + ${endif} - ${if} ${SectionIsSelected} ${DEV_TOOLS_IDX} - SectionGetSize ${DEV_TOOLS_IDX} $0 - IntOp $GetInstalledSize.total $GetInstalledSize.total + $0 - ${endif} + ${if} ${SectionIsSelected} ${DEV_TOOLS_IDX} + SectionGetSize ${DEV_TOOLS_IDX} $0 + IntOp $GetInstalledSize.total $GetInstalledSize.total + $0 + ${endif} - IntFmt $GetInstalledSize.total "0x%08X" $GetInstalledSize.total - Push $GetInstalledSize.total + IntFmt $GetInstalledSize.total "0x%08X" $GetInstalledSize.total + Push $GetInstalledSize.total FunctionEnd # Write registry, Windows uses these values in various tools such as add/remove program. # PowerShell: Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, InstallLocation, InstallDate | Format-Table –AutoSize function .onInstSuccess - # Save information in registry in HKEY_LOCAL_MACHINE branch, Windows add/remove functionality depends on this - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayName" "${GROUPNAME} - ${APPNAME} - ${DESCRIPTION}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "InstallLocation" "$INSTDIR" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "InstallDate" "${NOW}" - # Wait for Alex - #WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\logo.ico$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "Publisher" "${GROUPNAME}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "HelpLink" "${HELPURL}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "URLUpdateInfo" "${UPDATEURL}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "URLInfoAbout" "${ABOUTURL}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayVersion" "${MAJORVERSION}.${MINORVERSION}.${BUILDVERSION}" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "VersionMajor" ${MAJORVERSION} - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "VersionMinor" ${MINORVERSION} - # There is no option for modifying or repairing the install - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "NoModify" 1 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "NoRepair" 1 + # Save information in registry in HKEY_LOCAL_MACHINE branch, Windows add/remove functionality depends on this + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayName" "${GROUPNAME} - ${APPNAME} - ${DESCRIPTION}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "InstallLocation" "$INSTDIR" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "InstallDate" "${NOW}" + # Wait for Alex + #WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\logo.ico$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "Publisher" "${GROUPNAME}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "HelpLink" "${HELPURL}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "URLUpdateInfo" "${UPDATEURL}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "URLInfoAbout" "${ABOUTURL}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayVersion" "${MAJORVERSION}.${MINORVERSION}.${BUILDVERSION}" + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "VersionMajor" ${MAJORVERSION} + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "VersionMinor" ${MINORVERSION} + # There is no option for modifying or repairing the install + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "NoRepair" 1 - Call GetInstalledSize - Pop $0 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "EstimatedSize" "$0" + Call GetInstalledSize + Pop $0 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "EstimatedSize" "$0" - # Create uninstaller - writeUninstaller "$INSTDIR\uninstall.exe" + # Create uninstaller + writeUninstaller "$INSTDIR\uninstall.exe" functionEnd Page components diff --git a/build/nsis.uninstall.nsh b/build/nsis.uninstall.nsh index d478feaec3..ea7d5e2981 100644 --- a/build/nsis.uninstall.nsh +++ b/build/nsis.uninstall.nsh @@ -1,32 +1,32 @@ Section "Uninstall" - # uninstall for all users - setShellVarContext all + # uninstall for all users + setShellVarContext all - # Delete (optionally) installed files - {{range $}}Delete $INSTDIR\{{.}} - {{end}} - Delete $INSTDIR\uninstall.exe + # Delete (optionally) installed files + {{range $}}Delete $INSTDIR\{{.}} + {{end}} + Delete $INSTDIR\uninstall.exe - # Delete install directory - rmDir $INSTDIR + # Delete install directory + rmDir $INSTDIR - # Delete start menu launcher - Delete "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" - Delete "$SMPROGRAMS\${APPNAME}\Attach.lnk" - Delete "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" - rmDir "$SMPROGRAMS\${APPNAME}" + # Delete start menu launcher + Delete "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" + Delete "$SMPROGRAMS\${APPNAME}\Attach.lnk" + Delete "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" + rmDir "$SMPROGRAMS\${APPNAME}" - # Firewall - remove rules if exists - SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)" - SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)" - SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)" + # Firewall - remove rules if exists + SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)" + SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)" + SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)" - # Remove IPC endpoint (https://github.com/ethereum/EIPs/issues/147) - ${un.EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc" + # Remove IPC endpoint (https://github.com/ethereum/EIPs/issues/147) + ${un.EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc" - # Remove install directory from PATH - ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" $INSTDIR + # Remove install directory from PATH + ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" $INSTDIR - # Cleanup registry (deletes all sub keys) - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" + # Cleanup registry (deletes all sub keys) + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" SectionEnd