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

Add option to save the BuildSourcesEphemeral overlay. #3336

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

behrmann
Copy link
Contributor

@behrmann behrmann commented Jan 8, 2025

This systematises a trick Daan showed me a while back and that I've been using most everywhere since. Having it in mkosi itself makes it easier to use for everybody.

Copy link
Contributor

@DaanDeMeyer DaanDeMeyer left a comment

Choose a reason for hiding this comment

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

So I'm not too sure about adding official support for my hack, how about we document it somewhere instead?

@behrmann
Copy link
Contributor Author

It's a hack, but it's quite a useful hack and when one has more than single build script, having the setup code in each is a lot of boilerplate and if one wants to reduce it, it means adding a bit of shell wrapper into the tools tree and/or image and still a bit of boilerplate.

I've instead added another line to the docs and some explosion emojis around it.

I've added the don't merge label for now, though, since I need to test this once more. The thing I build segfaulted and I need to see whether it's somehow from this are the thing just being broken.

@behrmann
Copy link
Contributor Author

I'm also happy to call the option voidwarranty-buildcache instead.

@behrmann
Copy link
Contributor Author

Rebased and dropped the dont merge label, since it worked locally. I cherry-picked 62582f3 from #3402 for now to make CI run.

Copy link
Contributor

@DaanDeMeyer DaanDeMeyer left a comment

Choose a reason for hiding this comment

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

Shouldn't we limit this to only when running build scripts and do regular ephemeral for the other scripts?

@behrmann behrmann force-pushed the cachephemeral branch 2 times, most recently from 40fb5f2 to f5b4fce Compare January 22, 2025 16:01
@behrmann
Copy link
Contributor Author

Good catch, I thought it was there, that's why it's mentioned in the man page. I must have lost this in a rebase.

mkosi/mounts.py Outdated
with contextlib.ExitStack() as stack:
options: list[PathString] = []

for t in config.build_sources:
src, dst = t.with_prefix("/work/src")

if ephemeral:
upperdir = Path(stack.enter_context(tempfile.TemporaryDirectory(prefix="volatile-overlay")))
os.chmod(upperdir, src.stat().st_mode)
if ephemeral == BuildSourcesEphemeral.buildcache and config.build_dir is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would fail if this is specified but there's no build directory configured

@DaanDeMeyer DaanDeMeyer merged commit bcaaccc into systemd:main Jan 23, 2025
35 checks passed
@behrmann behrmann deleted the cachephemeral branch January 23, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants