From e6b498291b6e8afca267aba72d96119427f129f8 Mon Sep 17 00:00:00 2001 From: Anjan Nath Date: Tue, 31 Oct 2023 14:40:11 +0530 Subject: [PATCH] msi: add win32-background-launcher to installer crc-embedder is updated to download win32-background-launcher.exe from its github release at crc-org/win32-backgroun-launcher so that it is available while building the msi it'll be used to start the crc daemon as a background process --- cmd/crc-embedder/cmd/embed.go | 12 +++++---- packaging/windows/product.wxs.template | 4 +++ pkg/crc/constants/constants.go | 36 +++++++++++++++++--------- pkg/crc/version/version.go | 7 ++++- 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/cmd/crc-embedder/cmd/embed.go b/cmd/crc-embedder/cmd/embed.go index fcd4667a97..7cb24a3e86 100644 --- a/cmd/crc-embedder/cmd/embed.go +++ b/cmd/crc-embedder/cmd/embed.go @@ -27,10 +27,11 @@ var ( ) const ( - vfkitDriver = "vfkit-driver" - vfkitEntitlement = "vfkit-entitlement" - libvirtDriver = "libvirt-driver" - adminHelper = "admin-helper" + vfkitDriver = "vfkit-driver" + vfkitEntitlement = "vfkit-entitlement" + libvirtDriver = "libvirt-driver" + adminHelper = "admin-helper" + backgroundLauncher = "background-launcher" ) func init() { @@ -116,7 +117,8 @@ var ( adminHelper: {constants.GetAdminHelperURLForOs("linux"), 0755}, }, "windows": { - adminHelper: {constants.GetAdminHelperURLForOs("windows"), 0755}, + adminHelper: {constants.GetAdminHelperURLForOs("windows"), 0755}, + backgroundLauncher: {constants.GetCRCWindowsBackgroundLauncherDownloadURL(), 0755}, }, } ) diff --git a/packaging/windows/product.wxs.template b/packaging/windows/product.wxs.template index 721ae8aa45..66d28a7a65 100755 --- a/packaging/windows/product.wxs.template +++ b/packaging/windows/product.wxs.template @@ -54,6 +54,9 @@ + + + NOT UPGRADINGPRODUCTCODE AND NOT WIX_UPGRADE_DETECTED @@ -123,6 +126,7 @@ + diff --git a/pkg/crc/constants/constants.go b/pkg/crc/constants/constants.go index 76392f1b91..a7bc4d6c8c 100644 --- a/pkg/crc/constants/constants.go +++ b/pkg/crc/constants/constants.go @@ -22,18 +22,19 @@ const ( CrcEnvPrefix = "CRC" - ConfigFile = "crc.json" - LogFile = "crc.log" - DaemonLogFile = "crcd.log" - CrcLandingPageURL = "https://console.redhat.com/openshift/create/local" // #nosec G101 - DefaultAdminHelperURLBase = "https://github.com/crc-org/admin-helper/releases/download/v%s/%s" - DefaultBundleURLBase = "https://mirror.openshift.com/pub/openshift-v4/clients/crc/bundles/%s/%s/%s" - DefaultContext = "admin" - DaemonHTTPEndpoint = "http://unix/api" - DaemonVsockPort = 1024 - DefaultPodmanNamedPipe = `\\.\pipe\crc-podman` - RootlessPodmanSocket = "/run/user/1000/podman/podman.sock" - RootfulPodmanSocket = "/run/podman/podman.sock" + ConfigFile = "crc.json" + LogFile = "crc.log" + DaemonLogFile = "crcd.log" + CrcLandingPageURL = "https://console.redhat.com/openshift/create/local" // #nosec G101 + DefaultAdminHelperURLBase = "https://github.com/crc-org/admin-helper/releases/download/v%s/%s" + CRCWin32BackgroundLauncherURL = "https://github.com/crc-org/win32-background-launcher/releases/download/v%s/%s" + DefaultBundleURLBase = "https://mirror.openshift.com/pub/openshift-v4/clients/crc/bundles/%s/%s/%s" + DefaultContext = "admin" + DaemonHTTPEndpoint = "http://unix/api" + DaemonVsockPort = 1024 + DefaultPodmanNamedPipe = `\\.\pipe\crc-podman` + RootlessPodmanSocket = "/run/user/1000/podman/podman.sock" + RootfulPodmanSocket = "/run/podman/podman.sock" VSockGateway = "192.168.127.1" VsockSSHPort = 2222 @@ -47,6 +48,8 @@ const ( OpenShiftIngressHTTPPort = 80 OpenShiftIngressHTTPSPort = 443 + + Win32BackgroundLauncherExeName = "win32-background-launcher.exe" ) var adminHelperExecutableForOs = map[string]string{ @@ -145,6 +148,10 @@ func AdminHelperPath() string { return ResolveHelperPath(GetAdminHelperExecutableForOs(runtime.GOOS)) } +func Win32BackgroundLauncherPath() string { + return ResolveHelperPath(Win32BackgroundLauncherExeName) +} + // GetHomeDir returns the home directory for the current user func GetHomeDir() string { homeDir, err := os.UserHomeDir() @@ -187,6 +194,11 @@ func GetKubeAdminPasswordPath() string { return filepath.Join(MachineInstanceDir, DefaultName, "kubeadmin-password") } +func GetCRCWindowsBackgroundLauncherDownloadURL() string { + return fmt.Sprintf(CRCWin32BackgroundLauncherURL, + version.GetWin32BackgroundLauncherVersion(), Win32BackgroundLauncherExeName) +} + func GetDefaultCPUs(preset crcpreset.Preset) int { switch preset { case crcpreset.OpenShift, crcpreset.OKD: diff --git a/pkg/crc/version/version.go b/pkg/crc/version/version.go index 88fc8e24bb..31d3393c18 100644 --- a/pkg/crc/version/version.go +++ b/pkg/crc/version/version.go @@ -35,7 +35,8 @@ var ( ) const ( - crcAdminHelperVersion = "0.0.12" + crcAdminHelperVersion = "0.0.12" + win32BackgroundLauncherVersion = "0.0.0.1" ) func GetCRCVersion() string { @@ -63,6 +64,10 @@ func GetAdminHelperVersion() string { return crcAdminHelperVersion } +func GetWin32BackgroundLauncherVersion() string { + return win32BackgroundLauncherVersion +} + func IsInstaller() bool { return installerBuild != "false" }