From 7f8659899eec760701a886061fb1b34bbf3dc1f0 Mon Sep 17 00:00:00 2001 From: Keeyou Date: Tue, 5 Dec 2023 10:35:11 +0800 Subject: [PATCH] tools: generate nsis system installer --- tools/build.go | 19 ++++++++++++++++++- yass.nsi | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/build.go b/tools/build.go index 2cdebcc9c..a3977846e 100644 --- a/tools/build.go +++ b/tools/build.go @@ -1186,6 +1186,19 @@ func generateNSIS(output string) { cmdRun([]string{"C:\\Program Files (x86)\\NSIS\\makensis.exe", "/XSetCompressor /FINAL lzma", "yass.nsi"}, true) } +func generateNSISSystemInstaller(output string) { + glog.Info("Feeding CPack NSIS compiler...") + cmdRun([]string{"C:\\Program Files\\CMake\\bin\\cpack.exe"}, true) + + if msvcTargetArchFlag == "x86" { + os.Rename(fmt.Sprintf("yass-%s-win32.exe", tagFlag), output) + } else if msvcTargetArchFlag == "x64" { + os.Rename(fmt.Sprintf("yass-%s-win64.exe", tagFlag), output) + } else { + glog.Fatalf("Unsupported msvc arch: %s for nsis builder", msvcTargetArchFlag) + } +} + func generateOpenWrtMakefile(archive string, pkg_version string) { archive_dir, _ := filepath.Abs("..") archive_dir += "/" @@ -1256,13 +1269,15 @@ func postStateArchives() map[string][]string { } msiArchive := fmt.Sprintf(archiveFormat, APPNAME, "", ".msi") - nsisArchive := fmt.Sprintf(archiveFormat, APPNAME, "-installer", ".exe") + nsisArchive := fmt.Sprintf(archiveFormat, APPNAME, "-user-installer", ".exe") debugArchive := fmt.Sprintf(archiveFormat, APPNAME, "-debuginfo", ext) + nsisSystemArchive := fmt.Sprintf(archiveFormat, APPNAME, "-system-installer", ".exe") archive = filepath.Join("..", archive) msiArchive = filepath.Join("..", msiArchive) nsisArchive = filepath.Join("..", nsisArchive) debugArchive = filepath.Join("..", debugArchive) + nsisSystemArchive = filepath.Join("..", nsisSystemArchive) archives := map[string][]string{} @@ -1300,6 +1315,8 @@ func postStateArchives() map[string][]string { if systemNameFlag == "windows" && msvcTargetArchFlag != "arm64" { generateNSIS(nsisArchive) archives[nsisArchive] = []string{nsisArchive} + generateNSISSystemInstaller(nsisSystemArchive) + archives[nsisSystemArchive] = []string{nsisSystemArchive} } // debuginfo file if systemNameFlag == "windows" { diff --git a/yass.nsi b/yass.nsi index 23960fc93..9dbc16a2c 100644 --- a/yass.nsi +++ b/yass.nsi @@ -1,6 +1,8 @@ !include "MUI.nsh" !define MUI_ABORTWARNING # This will warn the user if they exit from the installer. +!define MUI_ICON "..\src\win32\yass.ico" +!define MUI_UNICON "..\src\win32\yass.ico" !insertmacro MUI_PAGE_WELCOME # Welcome to the installer page. !insertmacro MUI_PAGE_LICENSE "..\GPL-2.0.rtf"