Skip to content

Commit

Permalink
wip: name the executable as crc-background-launcher.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
anjannath committed Dec 1, 2023
1 parent 73e9e3f commit 87484bc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packaging/windows/product.wxs.template
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<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" />
<File Id="BackgroundLauncher" Source="SourceDir\win32-background-launcher.exe" Name="crc-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>
Expand Down
10 changes: 6 additions & 4 deletions pkg/crc/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Cache struct {
executablePath string
archiveURL string
version string
nameMismatch bool
getVersion func(string) (string, error)
}

Expand All @@ -33,8 +34,8 @@ func (e *VersionMismatchError) Error() string {
return fmt.Sprintf("%s version mismatch: %s expected but %s found in the cache", e.ExecutableName, e.ExpectedVersion, e.CurrentVersion)
}

func newCache(executablePath string, archiveURL string, version string, getVersion func(string) (string, error)) *Cache {
return &Cache{executablePath: executablePath, archiveURL: archiveURL, version: version, getVersion: getVersion}
func newCache(executablePath string, archiveURL string, version string, nameMismatch bool, getVersion func(string) (string, error)) *Cache {
return &Cache{executablePath: executablePath, archiveURL: archiveURL, version: version, getVersion: getVersion, nameMismatch: nameMismatch}
}

func (c *Cache) GetExecutablePath() string {
Expand Down Expand Up @@ -71,6 +72,7 @@ func NewAdminHelperCache() *Cache {
return newCache(constants.AdminHelperPath(),
url,
version,
false,
func(executable string) (string, error) {
out, _, err := crcos.RunWithDefaultLocale(executable, "--version")
if err != nil {
Expand Down Expand Up @@ -127,14 +129,14 @@ func (c *Cache) cacheExecutable() error {
}
} else {
extractedFiles = append(extractedFiles, assetTmpFile)
if filepath.Base(assetTmpFile) != c.GetExecutableName() {
if filepath.Base(assetTmpFile) != c.GetExecutableName() && !c.nameMismatch {
logging.Warnf("Executable name is %s but extracted file name is %s", c.GetExecutableName(), filepath.Base(assetTmpFile))
}
}

// Copy the requested asset into its final destination
for _, extractedFilePath := range extractedFiles {
finalExecutablePath := filepath.Join(constants.CrcBinDir, filepath.Base(extractedFilePath))
finalExecutablePath := filepath.Join(constants.CrcBinDir, c.GetExecutableName())
// If the file exists then remove it (ignore error) first before copy because with `0500` permission
// it is not possible to overwrite the file.
os.Remove(finalExecutablePath)
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/cache/cache_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func NewMachineDriverLibvirtCache() *Cache {
return newCache(libvirt.MachineDriverPath(), libvirt.MachineDriverDownloadURL, libvirt.MachineDriverVersion, getCurrentLibvirtDriverVersion)
return newCache(libvirt.MachineDriverPath(), libvirt.MachineDriverDownloadURL, libvirt.MachineDriverVersion, false, getCurrentLibvirtDriverVersion)
}

func getCurrentLibvirtDriverVersion(executablePath string) (string, error) {
Expand Down
1 change: 1 addition & 0 deletions pkg/crc/cache/cache_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func NewWin32BackgroundLauncherCache() *Cache {
return newCache(constants.Win32BackgroundLauncherPath(),
url,
version,
true,
func(executable string) (string, error) {
stdOut, stdErr, err := powershell.Execute(fmt.Sprintf(`(Get-Item '%s').VersionInfo.FileVersion`, executable))
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/crc/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
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"
BackgroundLauncherURL = "https://github.com/crc-org/win32-background-launcher/releases/download/v%s/%s"
BackgroundLauncherURL = "https://github.com/crc-org/win32-background-launcher/releases/download/v%s/win32-background-launcher.exe"
DefaultBundleURLBase = "https://mirror.openshift.com/pub/openshift-v4/clients/crc/bundles/%s/%s/%s"
DefaultContext = "admin"
DaemonHTTPEndpoint = "http://unix/api"
Expand All @@ -49,7 +49,7 @@ const (
OpenShiftIngressHTTPPort = 80
OpenShiftIngressHTTPSPort = 443

BackgroundLauncherExecutable = "win32-background-launcher.exe"
BackgroundLauncherExecutable = "crc-background-launcher.exe"
)

var adminHelperExecutableForOs = map[string]string{
Expand Down Expand Up @@ -196,7 +196,7 @@ func GetKubeAdminPasswordPath() string {

func GetWin32BackgroundLauncherDownloadURL() string {
return fmt.Sprintf(BackgroundLauncherURL,
version.GetWin32BackgroundLauncherVersion(), BackgroundLauncherExecutable)
version.GetWin32BackgroundLauncherVersion())
}

func GetDefaultCPUs(preset crcpreset.Preset) int {
Expand Down

0 comments on commit 87484bc

Please sign in to comment.