diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-09-08 12:26:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-08 12:26:50 +0200 |
commit | d729dd8c2e6556de10c4543c018fbebffa265a5e (patch) | |
tree | b374d334aef07d3b699e4f4bdf3861de48206b75 /cmd/podman-msihooks | |
parent | e46bcd72f8d6528dbafb1ad1b34abeb0177a8b77 (diff) | |
parent | 744878a71cb225fca6cf6b8f322539b717559614 (diff) | |
download | podman-d729dd8c2e6556de10c4543c018fbebffa265a5e.tar.gz podman-d729dd8c2e6556de10c4543c018fbebffa265a5e.tar.bz2 podman-d729dd8c2e6556de10c4543c018fbebffa265a5e.zip |
Merge pull request #15610 from n1hility/release-workflow
Introduce a new signed Windows installer with automated build process
Diffstat (limited to 'cmd/podman-msihooks')
-rw-r--r-- | cmd/podman-msihooks/main.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/cmd/podman-msihooks/main.go b/cmd/podman-msihooks/main.go new file mode 100644 index 000000000..903c91abb --- /dev/null +++ b/cmd/podman-msihooks/main.go @@ -0,0 +1,46 @@ +//go:build windows +// +build windows + +package main + +import ( + "C" + "syscall" + "unsafe" + + "github.com/containers/podman/v4/pkg/machine/wsl" +) + +const KernelWarning = "WSL Kernel installation did not complete successfully. " + + "Podman machine will attempt to install this at a later time. " + + "You can also manually complete the installation using the " + + "\"wsl --update\" command." + +//export CheckWSL +func CheckWSL(hInstall uint32) uint32 { + installed := wsl.IsWSLInstalled() + feature := wsl.IsWSLFeatureEnabled() + setMsiProperty(hInstall, "HAS_WSL", strBool(installed)) + setMsiProperty(hInstall, "HAS_WSLFEATURE", strBool(feature)) + + return 0 +} + +func setMsiProperty(hInstall uint32, name string, value string) { + nameW, _ := syscall.UTF16PtrFromString(name) + valueW, _ := syscall.UTF16PtrFromString(value) + + msi := syscall.NewLazyDLL("msi") + proc := msi.NewProc("MsiSetPropertyW") + _, _, _ = proc.Call(uintptr(hInstall), uintptr(unsafe.Pointer(nameW)), uintptr(unsafe.Pointer(valueW))) + +} +func strBool(val bool) string { + if val { + return "1" + } + + return "0" +} + +func main() {} |