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

pure rust self-install logic #85

Open
Gankra opened this issue Apr 15, 2024 · 1 comment
Open

pure rust self-install logic #85

Gankra opened this issue Apr 15, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Gankra
Copy link
Contributor

Gankra commented Apr 15, 2024

The installer.sh and installer.ps1 scripts in cargo-dist are a hybrid of rustup's installer bootstrap scripts and this rust code.

In rustup the installer scripts just handle detecting target triple, unpacking the archive into a tempdir and then run the rustup binary to finish installing itself. Updating rustup at that point is rustup itself doing the fetch and unpack, and again running its new self.

This is honestly the ideal way for an installer to work, as it gives the cli dev all the room in the world to add custom install logic/output in a way that's a pain with shell. Plus, rust code is a lot easier to maintain/test/trust than random shell scripts. In an ideal world we could actually share code with rustup and mutually improve/maintain this updater logic.

There are three features here:

  • a cargo-dist setting for "hey (power)shell installers, don't do any install-dir stuff, just run this binary with these arguments"
  • an axoupdater setting for "hey just unpack the archive and then run this binary with these arguments"
  • an axoupdater library API for "all the logic installer.sh and installer.ps1 do to setup PATH and whatnot" (i.e. rustup's self_update code)
@Gankra Gankra added the enhancement New feature or request label Apr 15, 2024
@mistydemeo
Copy link
Contributor

Reading over how it does it, seems pretty reasonable for us to adopt the same strategy. We'll keep the logic of OS and arch detection within the shell/powershell scripts, but everything past that can get moved into Rust.

Similar to how axoupdater itself works, we'll probably want an "axoinstaller" library within this crate(?) which performs the installations, and an installer binary that's a thin layer on top of that.

The primary complication I can think of is that we make extensive use of inlining data into the installer script at the time cargo dist build happens, and that's obviously a lot less practical in the case that most of the installer logic is in Rust. The difference between us and rustup is that our installers have all the knowledge they need to know about both the location of an installer package and its contents baked into itself. We can still bake it into the shell half, but we'll need to be able to communicate it from the shell side to the Rust side.

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

No branches or pull requests

2 participants