diff options
author | Jason T. Greene <jason.greene@redhat.com> | 2022-08-30 23:23:14 -0500 |
---|---|---|
committer | Jason T. Greene <jason.greene@redhat.com> | 2022-09-06 16:12:09 -0500 |
commit | ecb9f99b88f11556f3c5c3a890c130b16ea6f254 (patch) | |
tree | 297c9fa207752c7aaab93c4ac70e840f0c7d0a48 /cmd/podman-msihooks | |
parent | f4c39df25e643957d9df3bca9536f18451381662 (diff) | |
download | podman-ecb9f99b88f11556f3c5c3a890c130b16ea6f254.tar.gz podman-ecb9f99b88f11556f3c5c3a890c130b16ea6f254.tar.bz2 podman-ecb9f99b88f11556f3c5c3a890c130b16ea6f254.zip |
Add new windows installer and build
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
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() {} |