Bug 1792224: Add support for individual-files in the moz.yaml r=jewilde

Differential Revision: https://phabricator.services.mozilla.com/D158044
This commit is contained in:
Tom Ritter 2022-10-18 16:56:05 +00:00
Родитель ad38807fc8
Коммит 7ecc56b0a9
1 изменённых файлов: 42 добавлений и 2 удалений

44
python/mozbuild/mozbuild/vendor/moz_yaml.py поставляемый
Просмотреть файл

@ -159,7 +159,8 @@ vendoring:
source-hosting: gitlab
# Type of Vendoring
# This is either 'rust' or 'regular'
# This is either 'regular', 'individual-files', or 'rust'
# If omitted, will default to 'regular'
flavor: rust
# Type of git reference (commit, tag) to track updates from.
@ -423,7 +424,7 @@ def _schema_1():
In(VALID_SOURCE_HOSTS, msg="Unsupported Source Hosting"),
),
"tracking": All(str, Length(min=1)),
"flavor": Match(r"^(regular|rust)$"),
"flavor": Match(r"^(regular|rust|individual-files)$"),
"skip-vendoring-steps": Unique([str]),
"vendor-directory": All(str, Length(min=1)),
"patches": Unique([str]),
@ -431,6 +432,12 @@ def _schema_1():
"exclude": Unique([str]),
"include": Unique([str]),
"generated": Unique([str]),
"individual-files": [
{
Required("upstream"): All(str, Length(min=1)),
Required("destination"): All(str, Length(min=1)),
}
],
"update-actions": All(
UpdateActions(),
[
@ -530,6 +537,39 @@ def _schema_1_additional(filename, manifest, require_license_file=True):
"If Updatebot tasks are specified, a vendoring url must be included."
)
# The Rust and Individual Flavor type precludes a lot of options
# individual-files could, in theory, use several of these, but until we have a use case let's
# disallow them so we're not worrying about whether they work. When we need them we can make
# sure they do.
if (
"vendoring" in manifest
and manifest["vendoring"].get("flavor", "regular") != "regular"
):
for i in [
"skip-vendoring-steps",
"keep",
"exclude",
"include",
"generated",
"update-actions",
]:
if i in manifest["vendoring"]:
raise ValueError("A non-regular flavor of update cannot use '%s'" % i)
if (
"vendoring" in manifest
and manifest["vendoring"].get("flavor", "regular") != "individual-files"
):
if "individual-files" in manifest["vendoring"]:
raise ValueError(
"Only individual-files flavor of update can use 'individual-files'"
)
elif "vendoring" in manifest:
if "individual-files" not in manifest["vendoring"]:
raise ValueError(
"The individual-files flavor of update must include 'individual-files'"
)
# Check for a simple YAML file
with open(filename, "r") as f:
has_schema = False