Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve arch and system autodetection #52 #57

Closed
wants to merge 1 commit into from

Conversation

slavaGanzin
Copy link
Contributor

Before:

stew i rancher-sandbox/rancher-desktop
rancher-sandbox/rancher-desktop
! Could not automatically detect the release asset matching your OS/Arch. Please select it manually:  [Use arrows to move, type to filter]
> rancher-desktop-linux-v1.16.0.zip
  rancher-desktop-linux-v1.16.0.zip.sha512sum
  Rancher.Desktop-1.16.0-mac.aarch64.zip
  Rancher.Desktop-1.16.0-mac.aarch64.zip.sha512sum
  Rancher.Desktop-1.16.0-mac.x86_64.zip
  Rancher.Desktop-1.16.0-mac.x86_64.zip.sha512sum
  Rancher.Desktop-1.16.0.aarch64.dmg

After:

stew i rancher-sandbox/rancher-desktop
rancher-sandbox/rancher-desktop
! Could not automatically detect the release asset matching your OS/Arch. Please select it manually:  [Use arrows to move, type to filter]
> Rancher.Desktop-1.16.0-mac.x86_64.zip
  Rancher.Desktop-1.16.0.x86_64.dmg
uname -a
Darwin m 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:37:13 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8112 x86_64

@slavaGanzin
Copy link
Contributor Author

@marwanhawari ?

Comment on lines -26 to 30
var RegexDarwin = `(?i)(darwin|mac(os)?|apple|osx)`
var RegexDarwin = `(?i)(darwin|mac(os)?|apple|osx|.dmg)`

// RegexWindows is a regular express for windows systems
var RegexWindows = `(?i)(windows|win)`
var RegexWindows = `(?i)(windows|win|.msi|.exe|.appx)`

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove .dmg and .appx? Don't think these help because even if you can download them you want be able to properly install these formats through stew.

@@ -189,7 +191,7 @@ func DetectAsset(userOS string, userArch string, releaseAssets []string) (string
}
}
if finalAsset == "" {
finalAsset, err = WarningPromptSelect("Could not automatically detect the release asset matching your OS/Arch. Please select it manually:", filteredReleaseAssets)
finalAsset, err = WarningPromptSelect("Could not automatically detect the release asset matching your OS/Arch. Please select it manually:", detectedFinalAssets)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if filtering fails, I'd rather be conservative and show the user everything, so could you please revert this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

But can we add some logic around interactive and non-I reactive terminals? I use stew in docker installations and “I will show you everything” is not working well in this scenario

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it can be an option, but everybody will forget it on a first run. Just like -y is always forgotten in “apt install package“ in scripts

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-interactive installs, you should be installing from a Stewfile.lock.json.

stew install Stewfile.lock.json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh. It will not work this way. I'm on Mac, my container is linux and maybe on different architecture

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does presenting users with a filtered list of options here help with non-interactive installs?

Comment on lines +127 to +130
re := regexp.MustCompile(`\.(sha(256|512)(sum)?)$`)

for _, asset := range assets {
if strings.HasSuffix(asset, ".sha256") {
if re.MatchString(asset) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this to the constants.go file? Include a comment like:

// RegexChecksum is a regular expression for matching checksum files
var RegexChecksum = `\.(sha(256|512)(sum)?)$`

@marwanhawari
Copy link
Owner

Merged in your commit + small changes in #65

Thank you for your contribution!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants