r-darwish / topgrade

Upgrade everything
GNU General Public License v3.0
3.36k stars 160 forks source link

Enable updating Toolbx through topgrade #830

Closed Funky185540 closed 2 years ago

Funky185540 commented 2 years ago

Standards checklist:

If you developed a feature or a bug fix for someone else and you do not have the means to test it, please tag this person here.

Description

This adds a module to upgrade all toolboxes found on a host system. Toolbox (More recently: toolbx) is a tool that easily provides mutable, containerized command line environments. It is a means to work and develop in a mutable environment on immutable operating systems such as Fedora Silverblue, CoreOS, Kinoite and much more. However, it is not limited to these use cases.

The integration into topgrade works as follows: Toolbx makes many of the hosts folders available form inside the toolbx container by default. In particular, all of the hosts filesystem is mapped under /run/host. This module exploits this fact by:

Additional Notes

In my understanding of rust binaries, they are static, standalone executables. This is the one general assumption upon which this whole PR is based. Toolboxes are standalone containers, as such they don't run the same OS (version) as the host and the application probably cannot rely on having certain library versions available.

I do not know if this poses a problem here. Any feedback is highly appreciated!

MCOfficer commented 2 years ago

Additional Notes

In my understanding of rust binaries, they are static, standalone executables. This is the one general assumption upon which this whole PR is based. Toolboxes are standalone containers, as such they don't run the same OS (version) as the host and the application probably cannot rely on having certain library versions available.

I do not know if this poses a problem here. Any feedback is highly appreciated!

You're correct, unless a crate pulls some fancy stunt everything is linked statically. The one exception to this is libc - unless you choose a binary compiled with musl, libc will be linked dynamically. Whether that is a problem here i do not know.

Funky185540 commented 2 years ago

Alright, thanks for clarifying!

I don't want to push anyone, but if you say that this has a remote chance of being accepted I would ask some other toolbox users to go test the feature and report if they find any issues with it. :)

MCOfficer commented 2 years ago

I don't want to push anyone, but if you say that this has a remote chance of being accepted I would ask some other toolbox users to go test the feature and report if they find any issues with it. :)

Just to clarify: that decision belongs to r-darwish .

Funky185540 commented 2 years ago

Thanks for the feedback! Before I incorporate this I'm afraid I found an issue I'm not sure how to work around. It seems that the application is static except for the C runtime, glibc in my case. Unfortunately, toolbox containers running Fedora versions different from the host don't have a matching libc and can't find some symbols, so running topgrade there fails.

I tried linking the C runtime statically by adding this to Cargo.toml:

rustflags = ["-C", "target-feature=+crt-static"]

but it didn't solve the issue... Do you have an idea if there's a workaround to this?

r-darwish commented 2 years ago

You should probably compile against MUSL instead of glibc.

Funky185540 commented 2 years ago

You should probably compile against MUSL instead of glibc.

That works indeed, thanks! What exactly does this mean with regard to installing and running topgrade for Linux users?

r-darwish commented 2 years ago

You should probably compile against MUSL instead of glibc.

That works indeed, thanks! What exactly does this mean with regard to installing and running topgrade for Linux users?

If you take a look at the release page you'll see that each release contains two Linux binaries for amd64, one compiling against glibc and another one, which is a completely static one, compiled against MUSL. You should download the MUSL version if you use a distribution such as Alpine Linux.

Funky185540 commented 2 years ago

Thanks for accepting it. :)

I'd like to note the information about using this with older Toolbx container versions somewhere, so others looking for it can find it and don't start opening issues when they run into it. Do you have a suggestion where to add this?