8000 Bring back --default to allow OBS builds to select an entry point among many by bluca · Pull Request #3768 · systemd/mkosi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bring back --default to allow OBS builds to select an entry point among many #3768

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bluca
Copy link
Member
@bluca bluca commented Jun 11, 2025

When building a mkosi repository called 'particleos', OBS calls mkosi as such:

mkosi --directory /usr/src/packages/SOURCES/particleos --default mkosi.conf

with mkosi.conf being the source file extracted at source time, ie: defined by the user, among the many files available in the repository. So this can be used to select the entry point, that defines what to build, when a repository provides many build types, profiles, images, etc.

Right now --default is a no-op, so make it add the passed conf file as a high priority config file, so that the entry point can have precedence over anything else.

The file is placed at:

/usr/src/packages/SOURCES/mkosi.conf

This cannot be controlled by the user, and it's fixed.

Config file parsing requires absolute paths, and aborts otherwise. Because it is called with a filename only, but mkosi executes from the --directory location, special case it and if a non-absolute path is passed, look in the parent of --directory so that the use case of providing an entry point can be enabled.

With this I can add entry points to hidden directories in a repo, or even outside of it, and select them in the _service on OBS and build multiple different images from the same git repo and branch, for example the particleos gnome image:

https://build.opensuse.org/projects/home:bluca:branches:home:bluca:systemd/packages/particleos/files/_service?expand=1

@bluca bluca force-pushed the default branch 6 times, most recently from 8bfaf94 to d87f24f Compare June 11, 2025 22:44
Copy link
Contributor
@behrmann behrmann left a comment

Choose a reason for hiding this comment

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

I'm not sure having this undocumented is a good idea. Having surprise config pickup from a parent could be problematic, we might forget this exists, I sure did already forget --default still existed as a noop. Besides that I don't have strong objections.

Comment on lines +5162 to +5166
if args.default_config is not None:
if args.directory is not None and not args.default_config.is_absolute():
context.default_config = args.directory.parent / args.default_config
else:
context.default_config = args.default_config
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the args.default_config is None anyways, this could be shortened into

Suggested change
if args.default_config is not None:
if args.directory is not None and not args.default_config.is_absolute():
context.default_config = args.directory.parent / args.default_config
else:
context.default_config = args.default_config
if (
args.default_config is not None:
and args.directory is not None
and not args.default_config.is_absolute()
):
context.default_config = args.directory.parent / args.default_config

(well, it's longer, but slightly less complex)

Copy link
Member Author

Choose a reason for hiding this comment

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

With that change, unless args.directory is set, args.default_config is ignored, even if it's an absolute path which would otherwise work

@bluca
Copy link
Member Author
bluca commented Jun 12, 2025

I'm not sure having this undocumented is a good idea. Having surprise config pickup from a parent could be problematic, we might forget this exists, I sure did already forget --default still existed as a noop. Besides that I don't have strong objections.

I have no preference, given it's for a specific use case I thought you preferred to have it hidden, but I'll change that

…ng many

When building a mkosi repository called 'particleos', OBS calls mkosi as such:

mkosi --directory /usr/src/packages/SOURCES/particleos --default mkosi.conf

with mkosi.conf being the source file extracted at source time, ie: defined
by the user, among the many files available in the repository.
So this can be used to select the entry point, that defines what to build,
when a repository provides many build types, profiles, images, etc.

Right now --default is a no-op, so make it add the passed conf file as a
high priority config file, so that the entry point can have precedence
over anything else.

The file is placed at:

/usr/src/packages/SOURCES/mkosi.conf

This cannot be controlled by the user, and it's fixed.

Config file parsing requires absolute paths, and aborts otherwise.
Because it is called with a filename only, but mkosi executes from the
--directory location, special case it and if a non-absolute path is passed,
look in the parent of --directory so that the use case of providing an
entry point can be enabled.
Copy link
Contributor
@septatrix septatrix left a comment

Choose a reason for hiding this comment

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

Do I understand it correctly that this "default" file is generated dynamically by OBS?

@bluca
Copy link
Member Author
bluca commented Jun 12, 2025

No, it's extracted from wherever, either the same repo or another

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.

3 participants
0