Skip to content

Commit

Permalink
msi: add win32-background-launcher to installer
Browse files Browse the repository at this point in the history
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
  • Loading branch information
anjannath committed Nov 21, 2023
1 parent e6f13c3 commit e6b4982
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 18 deletions.
12 changes: 7 additions & 5 deletions cmd/crc-embedder/cmd/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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},
},
}
)
Expand Down
4 changes: 4 additions & 0 deletions packaging/windows/product.wxs.template
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
<ServiceInstall Name="crcAdminHelper" Description="Perform administrative tasks for the user" Arguments="daemon" DisplayName="Red Hat OpenShift Local Admin Helper" ErrorControl="normal" Start="auto" Type="ownProcess" />
<ServiceControl Id="StartAdminHelperService" Name="crcAdminHelper" Start='install' Stop='both' Remove='uninstall' />
</Component>
<Component Id="BackgroundLauncher" Guid="*">
<File Id="BackgroundLauncher" Source="SourceDir\win32-background-launcher.exe" KeyPath="yes" DiskId="1" />
</Component>
<Component Id="AddUserToCrcUsers" Guid="0C793EE7-109A-474B-9651-77E0A83BAF2D" KeyPath="yes">
<Condition>NOT UPGRADINGPRODUCTCODE AND NOT WIX_UPGRADE_DETECTED</Condition>
<util:User Id="LogonUser1" Domain="[%USERDOMAIN]" Name="[LogonUser]" CreateUser="no" RemoveOnUninstall="no">
Expand Down Expand Up @@ -123,6 +126,7 @@
<Feature Id="DefaultFeature" Title="Install core features" Absent="disallow" Level="1">
<ComponentRef Id="CrcExe" />
<ComponentRef Id="AdminHelper" />
<ComponentRef Id="BackgroundLauncher" />
<ComponentRef Id="AddToPath"/>
<ComponentRef Id="AddUserToCrcUsers" />
<ComponentRef Id="VsockRegistryEntry" />
Expand Down
36 changes: 24 additions & 12 deletions pkg/crc/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -47,6 +48,8 @@ const (

OpenShiftIngressHTTPPort = 80
OpenShiftIngressHTTPSPort = 443

Win32BackgroundLauncherExeName = "win32-background-launcher.exe"
)

var adminHelperExecutableForOs = map[string]string{
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion pkg/crc/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ var (
)

const (
crcAdminHelperVersion = "0.0.12"
crcAdminHelperVersion = "0.0.12"
win32BackgroundLauncherVersion = "0.0.0.1"
)

func GetCRCVersion() string {
Expand Down Expand Up @@ -63,6 +64,10 @@ func GetAdminHelperVersion() string {
return crcAdminHelperVersion
}

func GetWin32BackgroundLauncherVersion() string {
return win32BackgroundLauncherVersion
}

func IsInstaller() bool {
return installerBuild != "false"
}
Expand Down

0 comments on commit e6b4982

Please sign in to comment.