Skip to main content

specfile.conditions

resolve_expression

def resolve_expression(keyword: str,
expression: str,
context: Optional["Specfile"] = None) -> bool

Resolves a RPM expression.

Arguments:

  • keyword - Condition keyword, e.g. %if or %ifarch.
  • expression - Expression string or a whitespace-delimited list of arches/OSes in case keyword is a variant of %ifarch/%ifos.
  • context - Specfile instance that defines the context for macro expansions.

Returns:

Resolved expression as a boolean value.

process_conditions

def process_conditions(
lines: List[str],
macro_definitions: Optional["MacroDefinitions"] = None,
context: Optional["Specfile"] = None) -> List[Tuple[str, bool]]

Processes conditions in a spec file. Takes a list of lines and returns the same list of lines extended with information about their validity. A line is considered valid if it doesn't appear in a false branch of any condition.

Arguments:

  • lines - List of lines in a spec file.
  • macro_definitions - Parsed macro definitions to be used to prevent parsing conditions inside their bodies (and most likely failing).
  • context - Specfile instance that defines the context for macro expansions.

Returns:

List of tuples in the form of (line, validity).