return cid
-def config_parse_minimum_version(
- value: Optional[str],
- old: Optional[GenericVersion],
-) -> Optional[GenericVersion]:
+def config_parse_minimum_version(value: Optional[str], old: Optional[str]) -> Optional[str]:
if not value:
return old
+ if len(value) == 40 and all(c.isalnum() for c in value):
+ if not in_sandbox():
+ gitdir = Path(__file__).parent.parent
+ if not (gitdir / ".git").exists():
+ die("Cannot check mkosi git version, not running from a git repository")
+
+ result = run(["git", "-C", gitdir, "merge-base", "--is-ancestor", value, "HEAD"], check=False)
+ if result.returncode == 1:
+ die(f"mkosi commit {value} or newer is required by this configuration")
+ elif result.returncode != 0:
+ die(f"Failed to check if mkosi git checkout is newer than commit {value}")
+
+ return value
+
new = GenericVersion(value)
if new > __version__:
die(f"mkosi {new} or newer is required by this configuration (found {__version__})")
if not old:
- return new
+ return value
- return max(old, new)
+ return value if new > old else old
def file_run_or_read(file: Path) -> str:
profiles: list[str]
files: list[Path]
dependencies: list[str]
- minimum_version: Optional[GenericVersion]
+ minimum_version: Optional[str]
pass_environment: list[str]
distribution: Distribution
: The minimum **mkosi** version required to build this configuration. If
specified multiple times, the highest specified version is used.
+ The minimum version can also be specified as a unabbreviated git
+ commit hash, in which case mkosi must be executed from a git
+ checkout and the specified git commit hash must be an ancestor of
+ the currently checked out git commit in the repository that mkosi is
+ being executed from.
+
`ConfigureScripts=`, `--configure-script=`
: Takes a comma-separated list of paths to executables that are used as
the configure scripts for this image. See the **Scripts** section for
VsockCID,
)
from mkosi.distributions import Distribution
-from mkosi.versioncomp import GenericVersion
@pytest.mark.parametrize("path", [None, "/baz/qux"])
manifest_format=[ManifestFormat.json, ManifestFormat.changelog],
microcode_host=True,
devicetree=Path("freescale/imx8mm-verdin-nonwifi-dev.dtb"),
- minimum_version=GenericVersion("123"),
+ minimum_version="123",
mirror=None,
nspawn_settings=None,
openpgp_tool="gpg",