-
Notifications
You must be signed in to change notification settings - Fork 45
[runx] Allow non-archived binaries #172
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
Conversation
| } | ||
|
|
||
| func createSymbolicLink(src, dest, repoName string) error { | ||
| if err := fileutil.EnsureDir(dest); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could just be os.MkdirAll.
| if errors.Is(err, os.ErrExist) { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to check that the symlink is pointing to the right binary if it already exists in case the user ever installs a different version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The symlink is already in a versioned directory: (Both the symlink and the source)
ls -al ~/Library/Caches/jetpack.io/pkgs/mvdan/gofumpt/v0.5.0/darwin/arm64/
gofumpt -> /Users/mike/Library/Caches/jetpack.io/pkgs/mvdan/gofumpt/v0.5.0/gofumpt_v0.5.0_darwin_arm64
So nice to have in case we ever change the download logic but not urgent. Will add TODO
| if isKnownArchive(filepath.Base(artifactPath)) { | ||
| err = Extract(ctx, artifactPath, installPath.String()) | ||
| } else { | ||
| // If we can't extract, treat as binary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking the first 4 bytes would be a pretty good heuristic for determining if it's meant to be executable:
#!= shell script0x7f454c46= ELF (Linux)0xfeedface= macho 32 bit binary (macOS)0xfeedfacf= macho 64 bit binary (macOS)0xcafebabe= macho universal binary (macOS)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I also need to add little endian for mac binaries
Summary
Some repos (e.g. https://github.com/mvdan/gofumpt) release files as binaries instead of archives. This expands runx to treat unknown files (that still match the platform and architecture name structure) as binaries. It only does so if it finds a compatible artifact but the type is unknown.
We could additionally test the mime type of the file, but it doesn't seem like binaries use consistent mime types.
How was it tested?
./dist/runx +mvdan/gofumpt gofumpt --help