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

Persist changes between scripts when BuildSourcesEphemeral=true #2656

Closed
kerneis-anssi opened this issue Apr 24, 2024 · 5 comments · Fixed by #2659
Closed

Persist changes between scripts when BuildSourcesEphemeral=true #2656

kerneis-anssi opened this issue Apr 24, 2024 · 5 comments · Fixed by #2659
Labels

Comments

@kerneis-anssi
Copy link

mkosi commit the issue has been seen with

main

Used host distribution

Fedora 39

Used target distribution

Fedora 40

Linux kernel version used

6.8.5-201.fc39.x86_64

CPU architectures issue was seen on

None

Unexpected behaviour you saw

The documentation for BuildSourcesEphemeral says:

If enabled, all source directories will be reset to their original state after scripts (except sync scripts) finish executing.

I understood this to mean the following sequence of actions:

  • sync scripts are executed on the source directory
  • an overlay is mounted
  • everything other script runs
  • the overlay is discarded

In practice, it looks like a different overlay is mounted before each script runs (then discarded). Or is it before each set of script runs (ie. is there a separate overlay for every prepare script, then every build script, etc. or one for all prepare scripts, one for all build scripts, etc.)?

I think the most useful behaviour is the one I was expecting, because when the prepare script runs against the build image, I expect the result to be available to the build stage. But in any case, even if you disagree and have a use case for the current behaviour, I think the documentation should be clarified.

Used mkosi config

No response

mkosi output

No response

@DaanDeMeyer DaanDeMeyer added RFE and removed bug labels Apr 25, 2024
@DaanDeMeyer DaanDeMeyer changed the title Changes are not persisted between prepare and build when BuildSourcesEphemeral=true Persist changes between scripts when BuildSourcesEphemeral=true Apr 25, 2024
@DaanDeMeyer
Copy link
Contributor

@kerneis-anssi Can you explain more about your use case? This would be rather complicated to change.

@kerneis-anssi
Copy link
Author

My workflow involved pulling build dependencies locally during prepare so that I can avoid network access during build. For instance, in Go I'd use go mod vendor and in Rust cargo vendor.

I have alternative ways to reach the same goal:

  • move this step to the sync phase
  • move those downloads out of build sources (not all build systems handle this gracefully, but cargo allows out-of-tree vendored dependencies, and go mod download to populate the cache is an alternative to vendoring).

I'm not strongly advocating for you to implement this feature, especially if it's too complex. I think it would be useful to clarify the documentation though.

@DaanDeMeyer
Copy link
Contributor

DaanDeMeyer commented Apr 25, 2024

@kerneis-anssi Can't you just download these to $BUILDDIR? If it's not configurable then you can bind mount $BUILDDIR to the directory that these commands try to write to. See BuildDirectory= option.

@DaanDeMeyer
Copy link
Contributor

DaanDeMeyer commented Apr 25, 2024

If the paths to use can be configured via environment variables I would actually be OK with setting those automatically in mkosi.

@kerneis-anssi
Copy link
Author

Cargo (Rust) allows working from BUILDDIR.

Go is really annoying because it will let you download the vendored dependencies anywhere, but then you need to put them under vendor/ at the root of the package you're trying to build for them to be used. I'll try playing with a bind mount of builddir, thanks for the hint!

If the paths to use can be configured via environment variables I would actually be OK with setting those automatically in mkosi.

I don't think that would solve my current issue, but I am indeed setting GOPATH, GOCACHE and others to somewhere inside BuildDirectory. I'll think about whether it makes sense to upstream those and let you know in a separate issue.

Leaving this open as a reminder to update the doc if you agree (I'll let you close as you see fit).

DaanDeMeyer added a commit to DaanDeMeyer/mkosi that referenced this issue Apr 25, 2024
DaanDeMeyer added a commit to DaanDeMeyer/mkosi that referenced this issue Apr 25, 2024
DaanDeMeyer added a commit that referenced this issue Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants