Fixed spec entanglement PR check (CP: #10585) (#10586)

This commit is contained in:
Pawel Winogrodzki 2024-09-30 17:50:08 -07:00 committed by GitHub
parent 2340f8b4e8
commit 2d9218893c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 8 deletions

View File

@ -2,15 +2,15 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from typing import FrozenSet, List, Set
from pyrpm.spec import Spec
import argparse
from collections import defaultdict
from pathlib import Path
from os import path
from typing import FrozenSet, List, Set
import argparse
import pprint
import sys
from pyrpm.spec import replace_macros, Spec
version_release_matching_groups = [
frozenset([
"SPECS-SIGNED/kernel-signed/kernel-signed.spec",
@ -75,10 +75,10 @@ def check_spec_tags(base_path: str, tags: List[str], groups: List[FrozenSet]) ->
variants = defaultdict(set)
for spec_filename in group:
parsed_spec = Spec.from_file(Path(base_path, spec_filename))
parsed_spec = Spec.from_file(path.join(base_path, spec_filename))
for tag in tags:
variants[tag].add(getattr(
parsed_spec, tag))
tag_value = get_tag_value(parsed_spec, tag)
variants[tag].add(tag_value)
for tag in tags:
if len(variants[tag]) > 1:
@ -118,6 +118,13 @@ def check_matches(base_path: str):
sys.exit(1)
def get_tag_value(spec: "Spec", tag: str) -> str:
value = getattr(spec, tag)
if value:
value = replace_macros(value, spec)
return value
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(