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
This commit is contained in:
Felix Lange 2016-11-08 19:30:35 +01:00
parent 5f3ae3e7f4
commit 8c2c9e207b
4 changed files with 113 additions and 114 deletions

View file

@ -69,8 +69,6 @@ var (
executablePath("evm"), executablePath("evm"),
executablePath("geth"), executablePath("geth"),
executablePath("rlpdump"), executablePath("rlpdump"),
executablePath("disasm"),
executablePath("bootnode"),
} }
// A debian package is created for all executables listed here. // A debian package is created for all executables listed here.
@ -579,22 +577,6 @@ func doWindowsInstaller(cmdline []string) {
env := build.Env() env := build.Env()
maybeSkipArchive(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 // Aggregate binaries that are included in the installer
var ( var (
devTools []string devTools []string
@ -612,26 +594,40 @@ func doWindowsInstaller(cmdline []string) {
devTools = append(devTools, file) devTools = append(devTools, file)
} }
} }
// Render NSIS scripts: Installer NSIS contains two installer sections, // Render NSIS scripts: Installer NSIS contains two installer sections,
// first section contains the geth binary, second section holds the dev tools. // first section contains the geth binary, second section holds the dev tools.
installer := map[string]interface{}{ templateData := map[string]interface{}{
"License": "COPYING", "License": "COPYING",
"Geth": gethTool, "Geth": gethTool,
"DevTools": devTools, "DevTools": devTools,
} }
build.Render("build/nsis.geth.nsi", filepath.Join(*workdir, "geth.nsi"), 0644, nil) 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.uninstall.nsh", filepath.Join(*workdir, "uninstall.nsh"), 0644, allTools)
build.Render("build/nsis.envvarupdate.nsh", filepath.Join(*workdir, "EnvVarUpdate.nsh"), 0644, nil) 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, "SimpleFC.dll"), "build/nsis.simplefc.dll", 0755)
build.CopyFile(filepath.Join(*workdir, "COPYING"), "COPYING", 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 the installer. This assumes that all the needed files have been previously
build.MustRun(makensis) // 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. // 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) log.Fatal(err)
} }
} }

View file

@ -33,6 +33,9 @@ CRCCheck on
# Require admin rights on NT6+ (When UAC is turned on) # Require admin rights on NT6+ (When UAC is turned on)
RequestExecutionLevel admin RequestExecutionLevel admin
# Use LZMA compression
SetCompressor /SOLID lzma
!include LogicLib.nsh !include LogicLib.nsh
!include EnvVarUpdate.nsh !include EnvVarUpdate.nsh
@ -40,21 +43,21 @@ RequestExecutionLevel admin
UserInfo::GetAccountType UserInfo::GetAccountType
pop $0 pop $0
${If} $0 != "admin" # Require admin rights on NT4+ ${If} $0 != "admin" # Require admin rights on NT4+
messageBox mb_iconstop "Administrator rights required!" messageBox mb_iconstop "Administrator rights required!"
setErrorLevel 740 # ERROR_ELEVATION_REQUIRED setErrorLevel 740 # ERROR_ELEVATION_REQUIRED
quit quit
${EndIf} ${EndIf}
!macroend !macroend
function .onInit function .onInit
# make vars are global for all users since geth is installed global # make vars are global for all users since geth is installed global
setShellVarContext all setShellVarContext all
!insertmacro VerifyUserIsAdmin !insertmacro VerifyUserIsAdmin
${If} ${ARCH} == "amd64" ${If} ${ARCH} == "amd64"
StrCpy $InstDir "$PROGRAMFILES64\${APPNAME}" StrCpy $InstDir "$PROGRAMFILES64\${APPNAME}"
${Else} ${Else}
StrCpy $InstDir "$PROGRAMFILES32\${APPNAME}" StrCpy $InstDir "$PROGRAMFILES32\${APPNAME}"
${Endif} ${Endif}
functionEnd functionEnd

View file

@ -1,6 +1,6 @@
Name "geth ${MAJORVERSION}.${MINORVERSION}.${BUILDVERSION}" # VERSION variables set through command line arguments Name "geth ${MAJORVERSION}.${MINORVERSION}.${BUILDVERSION}" # VERSION variables set through command line arguments
InstallDir "$InstDir" InstallDir "$InstDir"
OutFile "${OUTPUTFILE}.exe" # OUTPUTFILE set through command line arguments OutFile "${OUTPUTFILE}" # set through command line arguments
# Links for "Add/Remove Programs" # Links for "Add/Remove Programs"
!define HELPURL "https://github.com/ethereum/go-ethereum/issues" !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" !define /date NOW "%Y%m%d"
PageEx license PageEx license
LicenseData {{.License}} LicenseData {{.License}}
PageExEnd PageExEnd
# Install geth binary # Install geth binary
Section "Geth" GETH_IDX Section "Geth" GETH_IDX
SetOutPath $INSTDIR SetOutPath $INSTDIR
file {{.Geth}} file {{.Geth}}
# Create start menu launcher # Create start menu launcher
createDirectory "$SMPROGRAMS\${APPNAME}" createDirectory "$SMPROGRAMS\${APPNAME}"
createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\geth.exe" "--fast" "--cache=512" createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\geth.exe" "--fast" "--cache=512"
createShortCut "$SMPROGRAMS\${APPNAME}\Attach.lnk" "$INSTDIR\geth.exe" "attach" "" "" createShortCut "$SMPROGRAMS\${APPNAME}\Attach.lnk" "$INSTDIR\geth.exe" "attach" "" ""
createShortCut "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "" "" createShortCut "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "" ""
# Firewall - remove rules (if exists) # Firewall - remove rules (if exists)
SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)" SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)"
SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)" SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)"
SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)" SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)"
# Firewall - add rules # Firewall - add rules
SimpleFC::AdvAddRule "Geth incoming peers (TCP:30303)" "" 6 1 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" 30303 "" "" "" 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 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 "" "" 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) # Set default IPC endpoint (https://github.com/ethereum/EIPs/issues/147)
${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc" ${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc"
${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "A" "HKLM" "\\.\pipe\geth.ipc" ${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "A" "HKLM" "\\.\pipe\geth.ipc"
# Add geth to PATH # Add geth to PATH
${EnvVarUpdate} $0 "PATH" "A" "HKLM" $INSTDIR ${EnvVarUpdate} $0 "PATH" "A" "HKLM" $INSTDIR
SectionEnd SectionEnd
# Install optional develop tools. # Install optional develop tools.
Section /o "Development tools" DEV_TOOLS_IDX Section /o "Development tools" DEV_TOOLS_IDX
SetOutPath $INSTDIR SetOutPath $INSTDIR
{{range .DevTools}}file {{.}} {{range .DevTools}}file {{.}}
{{end}} {{end}}
SectionEnd SectionEnd
# Return on top of stack the total size (as DWORD) of the selected/installed sections. # Return on top of stack the total size (as DWORD) of the selected/installed sections.
Var GetInstalledSize.total Var GetInstalledSize.total
Function GetInstalledSize Function GetInstalledSize
StrCpy $GetInstalledSize.total 0 StrCpy $GetInstalledSize.total 0
${if} ${SectionIsSelected} ${GETH_IDX} ${if} ${SectionIsSelected} ${GETH_IDX}
SectionGetSize ${GETH_IDX} $0 SectionGetSize ${GETH_IDX} $0
IntOp $GetInstalledSize.total $GetInstalledSize.total + $0 IntOp $GetInstalledSize.total $GetInstalledSize.total + $0
${endif} ${endif}
${if} ${SectionIsSelected} ${DEV_TOOLS_IDX} ${if} ${SectionIsSelected} ${DEV_TOOLS_IDX}
SectionGetSize ${DEV_TOOLS_IDX} $0 SectionGetSize ${DEV_TOOLS_IDX} $0
IntOp $GetInstalledSize.total $GetInstalledSize.total + $0 IntOp $GetInstalledSize.total $GetInstalledSize.total + $0
${endif} ${endif}
IntFmt $GetInstalledSize.total "0x%08X" $GetInstalledSize.total IntFmt $GetInstalledSize.total "0x%08X" $GetInstalledSize.total
Push $GetInstalledSize.total Push $GetInstalledSize.total
FunctionEnd FunctionEnd
# Write registry, Windows uses these values in various tools such as add/remove program. # 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 # PowerShell: Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, InstallLocation, InstallDate | Format-Table AutoSize
function .onInstSuccess function .onInstSuccess
# Save information in registry in HKEY_LOCAL_MACHINE branch, Windows add/remove functionality depends on this # 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}" "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}" "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}" "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}" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "InstallDate" "${NOW}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "InstallDate" "${NOW}"
# Wait for Alex # 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}" "DisplayIcon" "$\"$INSTDIR\logo.ico$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "Publisher" "${GROUPNAME}" 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}" "HelpLink" "${HELPURL}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "URLUpdateInfo" "${UPDATEURL}" 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}" "URLInfoAbout" "${ABOUTURL}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayVersion" "${MAJORVERSION}.${MINORVERSION}.${BUILDVERSION}" 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}" "VersionMajor" ${MAJORVERSION}
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "VersionMinor" ${MINORVERSION} WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "VersionMinor" ${MINORVERSION}
# There is no option for modifying or repairing the install # 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}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "NoRepair" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "NoRepair" 1
Call GetInstalledSize Call GetInstalledSize
Pop $0 Pop $0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "EstimatedSize" "$0" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "EstimatedSize" "$0"
# Create uninstaller # Create uninstaller
writeUninstaller "$INSTDIR\uninstall.exe" writeUninstaller "$INSTDIR\uninstall.exe"
functionEnd functionEnd
Page components Page components

View file

@ -1,32 +1,32 @@
Section "Uninstall" Section "Uninstall"
# uninstall for all users # uninstall for all users
setShellVarContext all setShellVarContext all
# Delete (optionally) installed files # Delete (optionally) installed files
{{range $}}Delete $INSTDIR\{{.}} {{range $}}Delete $INSTDIR\{{.}}
{{end}} {{end}}
Delete $INSTDIR\uninstall.exe Delete $INSTDIR\uninstall.exe
# Delete install directory # Delete install directory
rmDir $INSTDIR rmDir $INSTDIR
# Delete start menu launcher # Delete start menu launcher
Delete "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" Delete "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk"
Delete "$SMPROGRAMS\${APPNAME}\Attach.lnk" Delete "$SMPROGRAMS\${APPNAME}\Attach.lnk"
Delete "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" Delete "$SMPROGRAMS\${APPNAME}\Uninstall.lnk"
rmDir "$SMPROGRAMS\${APPNAME}" rmDir "$SMPROGRAMS\${APPNAME}"
# Firewall - remove rules if exists # Firewall - remove rules if exists
SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)" SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)"
SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)" SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)"
SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)" SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)"
# Remove IPC endpoint (https://github.com/ethereum/EIPs/issues/147) # Remove IPC endpoint (https://github.com/ethereum/EIPs/issues/147)
${un.EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc" ${un.EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc"
# Remove install directory from PATH # Remove install directory from PATH
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" $INSTDIR ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" $INSTDIR
# Cleanup registry (deletes all sub keys) # Cleanup registry (deletes all sub keys)
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}"
SectionEnd SectionEnd