@@ -28,6 +28,7 @@ Available commands are:
2828 archive [-arch architecture] [ -type zip|tar ] [ -signer key-envvar ] [ -upload dest ] -- archives build artefacts
2929 importkeys -- imports signing keys from env
3030 debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
31+ nsis -- creates a Windows NSIS installer
3132 xgo [ options ] -- cross builds according to options
3233
3334For all commands, -n prevents execution of external programs (dry run mode).
@@ -122,6 +123,8 @@ func main() {
122123 doArchive (os .Args [2 :])
123124 case "debsrc" :
124125 doDebianSource (os .Args [2 :])
126+ case "nsis" :
127+ doWindowsInstaller (os .Args [2 :])
125128 case "xgo" :
126129 doXgo (os .Args [2 :])
127130 default :
@@ -429,7 +432,7 @@ func makeWorkdir(wdflag string) string {
429432 if wdflag != "" {
430433 err = os .MkdirAll (wdflag , 0744 )
431434 } else {
432- wdflag , err = ioutil .TempDir ("" , "eth-deb -build-" )
435+ wdflag , err = ioutil .TempDir ("" , "geth -build-" )
433436 }
434437 if err != nil {
435438 log .Fatal (err )
@@ -559,6 +562,76 @@ func stageDebianSource(tmpdir string, meta debMetadata) (pkgdir string) {
559562 return pkgdir
560563}
561564
565+ // Windows installer
566+
567+ func doWindowsInstaller (cmdline []string ) {
568+ // Parse the flags and make skip installer generation on PRs
569+ var (
570+ arch = flag .String ("arch" , runtime .GOARCH , "Architecture for cross build packaging" )
571+ signer = flag .String ("signer" , "" , `Environment variable holding the signing key (e.g. WINDOWS_SIGNING_KEY)` )
572+ upload = flag .String ("upload" , "" , `Destination to upload the archives (usually "gethstore/builds")` )
573+ workdir = flag .String ("workdir" , "" , `Output directory for packages (uses temp dir if unset)` )
574+ )
575+ flag .CommandLine .Parse (cmdline )
576+ * workdir = makeWorkdir (* workdir )
577+ env := build .Env ()
578+ maybeSkipArchive (env )
579+
580+ // Aggregate binaries that are included in the installer
581+ var (
582+ devTools []string
583+ allTools []string
584+ gethTool string
585+ )
586+ for _ , file := range allToolsArchiveFiles {
587+ if file == "COPYING" { // license, copied later
588+ continue
589+ }
590+ allTools = append (allTools , filepath .Base (file ))
591+ if filepath .Base (file ) == "geth.exe" {
592+ gethTool = file
593+ } else {
594+ devTools = append (devTools , file )
595+ }
596+ }
597+
598+ // Render NSIS scripts: Installer NSIS contains two installer sections,
599+ // first section contains the geth binary, second section holds the dev tools.
600+ templateData := map [string ]interface {}{
601+ "License" : "COPYING" ,
602+ "Geth" : gethTool ,
603+ "DevTools" : devTools ,
604+ }
605+ build .Render ("build/nsis.geth.nsi" , filepath .Join (* workdir , "geth.nsi" ), 0644 , nil )
606+ build .Render ("build/nsis.install.nsh" , filepath .Join (* workdir , "install.nsh" ), 0644 , templateData )
607+ build .Render ("build/nsis.uninstall.nsh" , filepath .Join (* workdir , "uninstall.nsh" ), 0644 , allTools )
608+ build .Render ("build/nsis.envvarupdate.nsh" , filepath .Join (* workdir , "EnvVarUpdate.nsh" ), 0644 , nil )
609+ build .CopyFile (filepath .Join (* workdir , "SimpleFC.dll" ), "build/nsis.simplefc.dll" , 0755 )
610+ build .CopyFile (filepath .Join (* workdir , "COPYING" ), "COPYING" , 0755 )
611+
612+ // Build the installer. This assumes that all the needed files have been previously
613+ // built (don't mix building and packaging to keep cross compilation complexity to a
614+ // minimum).
615+ version := strings .Split (build .VERSION (), "." )
616+ if env .Commit != "" {
617+ version [2 ] += "-" + env .Commit [:8 ]
618+ }
619+ installer , _ := filepath .Abs ("geth-" + archiveBasename (* arch , env ) + ".exe" )
620+ build .MustRunCommand ("makensis.exe" ,
621+ "/DOUTPUTFILE=" + installer ,
622+ "/DMAJORVERSION=" + version [0 ],
623+ "/DMINORVERSION=" + version [1 ],
624+ "/DBUILDVERSION=" + version [2 ],
625+ "/DARCH=" + * arch ,
626+ filepath .Join (* workdir , "geth.nsi" ),
627+ )
628+
629+ // Sign and publish installer.
630+ if err := archiveUpload (installer , * upload , * signer ); err != nil {
631+ log .Fatal (err )
632+ }
633+ }
634+
562635// Cross compilation
563636
564637func doXgo (cmdline []string ) {
0 commit comments