-
Notifications
You must be signed in to change notification settings - Fork 395
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1768,6 +1768,7 @@ class Args: | |||||||||||||||||||||||
| cmdline: list[str] | ||||||||||||||||||||||||
| force: int | ||||||||||||||||||||||||
| directory: Optional[Path] | ||||||||||||||||||||||||
| default_config: Optional[Path] | ||||||||||||||||||||||||
| debug: bool | ||||||||||||||||||||||||
| debug_shell: bool | ||||||||||||||||||||||||
| debug_workspace: bool | ||||||||||||||||||||||||
|
|
@@ -4328,6 +4329,14 @@ def create_argument_parser(chdir: bool = True) -> argparse.ArgumentParser: | |||||||||||||||||||||||
| help="Change to specified directory before doing anything", | ||||||||||||||||||||||||
| metavar="PATH", | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| parser.add_argument( | ||||||||||||||||||||||||
| "--default", | ||||||||||||||||||||||||
| dest="default_config", | ||||||||||||||||||||||||
| help="Use a specific configuration file as the entry point, allowing to set various defaults", | ||||||||||||||||||||||||
| type=Path, | ||||||||||||||||||||||||
| default=None, | ||||||||||||||||||||||||
| metavar="PATH", | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| parser.add_argument( | ||||||||||||||||||||||||
| "--debug", | ||||||||||||||||||||||||
| help="Turn on debugging output", | ||||||||||||||||||||||||
|
|
@@ -4412,10 +4421,6 @@ def create_argument_parser(chdir: bool = True) -> argparse.ArgumentParser: | |||||||||||||||||||||||
| nargs=0, | ||||||||||||||||||||||||
| action=IgnoreAction, | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| parser.add_argument( | ||||||||||||||||||||||||
| "--default", | ||||||||||||||||||||||||
| action=IgnoreAction, | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| parser.add_argument( | ||||||||||||||||||||||||
| "--cache", | ||||||||||||||||||||||||
| action=IgnoreAction, | ||||||||||||||||||||||||
|
|
@@ -4531,6 +4536,7 @@ def __call__( | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| class ParseContext: | ||||||||||||||||||||||||
| def __init__(self, resources: Path = Path("/")) -> None: | ||||||||||||||||||||||||
| self.default_config: Optional[Path] = None | ||||||||||||||||||||||||
| self.resources = resources | ||||||||||||||||||||||||
| # We keep two namespaces around, one for the settings specified on the CLI and one for | ||||||||||||||||||||||||
| # the settings specified in configuration files. This is required to implement both [Match] | ||||||||||||||||||||||||
|
|
@@ -4810,10 +4816,14 @@ def parse_config_one(self, path: Path, parse_profiles: bool = False, parse_local | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if extras: | ||||||||||||||||||||||||
| if parse_local: | ||||||||||||||||||||||||
| for localpath in ( | ||||||||||||||||||||||||
| *([p] if (p := path.parent / "mkosi.local").is_dir() else []), | ||||||||||||||||||||||||
| *([p] if (p := path.parent / "mkosi.local.conf").is_file() else []), | ||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||
| localpaths = [] | ||||||||||||||||||||||||
| if (p := path.parent / "mkosi.local").is_dir(): | ||||||||||||||||||||||||
| localpaths.append(p) | ||||||||||||||||||||||||
| if (p := path.parent / "mkosi.local.conf").is_file(): | ||||||||||||||||||||||||
| localpaths.append(p) | ||||||||||||||||||||||||
| if self.default_config is not None and self.default_config.is_file(): | ||||||||||||||||||||||||
| localpaths.append(self.default_config) | ||||||||||||||||||||||||
| for localpath in localpaths: | ||||||||||||||||||||||||
| with chdir(localpath if localpath.is_dir() else Path.cwd()): | ||||||||||||||||||||||||
| self.parse_config_one(localpath if localpath.is_file() else Path.cwd()) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -5146,6 +5156,15 @@ def parse_config( | |||||||||||||||||||||||
| # One of the specifiers needs access to the directory, so make sure it is available. | ||||||||||||||||||||||||
| context.config["directory"] = args.directory | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Config paths need to be absolute - as a special case, if it is not, look in the parent | ||||||||||||||||||||||||
| # of --directory. This works nicely on OBS, where the --directory is the git repository | ||||||||||||||||||||||||
| # and the --default is the mkosi.conf selected at source service time, placed in the parent. | ||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||
|
Comment on lines
+5162
to
+5166
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the
Suggested change
(well, it's longer, but slightly less complex)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| context.parse_new_includes() | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| context.config["files"] = [] | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.