mirror of https://github.com/liamg/aminal.git
Fix windows launcher (#255)
* Add Windows launcher The launcher looks at directory "Versions" next to its executable. It finds the latest version and runs the executable in that directory with the same name as itself. For instance: Aminal.exe <- the launcher Versions/ 1.0.0/ Aminal.exe 1.0.1/ Aminal.exe In this example, running the top-level Aminal.exe (the launcher) starts Versions/1.0.1/Aminal.exe. Having a launcher allows Aminal to be updated while it is running. For example, version 1.0.1 could be downloaded without disturbing running instances of Aminal 1.0.0. * Implement a command-line installer for Windows It can be generated with the Make target installer-windows. It requires that you ran Make target launcher-windows before. * Implement Uninstaller for Windows * Codesign Windows auto-update executables * Don't require Admin privileges for Win uninstaller * Remove references to fman * Explain automatic updates in windows.md * Limit installer go packages compilation only to Windows platform * Fix Windows launcher * gofmt for launcher.go
This commit is contained in:
parent
68953464ba
commit
efb31fd15e
3
Makefile
3
Makefile
|
@ -78,7 +78,8 @@ launcher-windows: build-windows
|
|||
if exist "bin\windows\Aminal" rmdir /S /Q "bin\windows\Aminal"
|
||||
mkdir "bin\windows\Aminal\Versions\${VERSION}"
|
||||
go build -o "bin\windows\Aminal\${BINARY}.exe" -ldflags "-H windowsgui" "${GEN_SRC_DIR}\launcher"
|
||||
copy ${BINARY}-windows-amd64.exe "bin\windows\Aminal\Versions\${VERSION}\${BINARY}.exe" /Y
|
||||
windres -o aminal.syso aminal.rc
|
||||
go build -o "bin\windows\Aminal\Versions\${VERSION}\${BINARY}.exe" -ldflags "-H windowsgui"
|
||||
IF "${WINDOWS_CODESIGNING_CERT_PW}"=="" ECHO Environment variable WINDOWS_CODESIGNING_CERT_PW is not defined. & exit 1
|
||||
signtool sign /f windows\codesigning_certificate.pfx /p "${WINDOWS_CODESIGNING_CERT_PW}" /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp bin\windows\Aminal\${BINARY}.exe
|
||||
signtool sign /f windows\codesigning_certificate.pfx /p "${WINDOWS_CODESIGNING_CERT_PW}" /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /as /fd sha256 /td sha256 bin\windows\Aminal\${BINARY}.exe
|
||||
|
|
|
@ -23,10 +23,12 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
type Version struct {
|
||||
|
@ -42,8 +44,23 @@ func main() {
|
|||
versionsDir := filepath.Join(executableDir, "Versions")
|
||||
latestVersion, err := getLatestVersion(versionsDir)
|
||||
check(err)
|
||||
target := filepath.Join(versionsDir, latestVersion, executableName)
|
||||
cmd := exec.Command(target, os.Args[1:]...)
|
||||
usr, err := user.Current()
|
||||
check(err)
|
||||
cmd := exec.Command("C:\\Windows\\System32\\cmd.exe", "/C", "start", "Aminal", "/B", executableName)
|
||||
cmd.Dir = usr.HomeDir
|
||||
latestVersionDir := filepath.Join(versionsDir, latestVersion)
|
||||
path, pathSet := os.LookupEnv("PATH")
|
||||
if pathSet {
|
||||
path += ";" + latestVersionDir
|
||||
} else {
|
||||
path = latestVersionDir
|
||||
}
|
||||
cmd.Env = append(os.Environ(), "PATH="+path)
|
||||
const CREATE_NO_WINDOW = 0x08000000
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
HideWindow: true,
|
||||
CreationFlags: CREATE_NO_WINDOW,
|
||||
}
|
||||
check(cmd.Start())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue