Skip to content

Conversation

@mohamed-rekiba
Copy link

@mohamed-rekiba mohamed-rekiba commented Aug 23, 2025

Introduce Lua Scripting Engine and Fix RPM Spec Processing Issues

Overview

This PR introduces a robust Lua scripting engine for advanced RPM spec file processing and resolves critical parsing issues with option macro negation and conditional directive preservation.

Resolves

Lua function causes syntax errors

Key Features

  • Lua Scripting Engine: Implements a comprehensive Lua scripting system that seamlessly integrates with the existing RPM macro expansion system
  • Shell Command Execution: Enables shell command execution through %(command) syntax expansion
  • Comment Processing Improvements: Prevents unintended macro expansion in regular comments during RPM spec processing

Bug Fixes

  • Option Macro Negation: Fixed parsing of negated option macros (e.g., %{-m:0}) by enhancing the expandmacros() function to properly detect negation patterns and set correct mactest values
  • RPM Directive Preservation: Resolved issues with %if/%endif directives being escaped in multi-line expansions by improving splitexpansionresult() pattern matching to preserve RPM control directives

Testing

  • Added comprehensive test suite covering all Lua engine functionality and edge cases
  • All existing tests continue to pass
  • Enhanced test documentation for better maintainability

Technical Details

The fixes specifically address syntax errors in expression parsing by enabling proper handling of complex option macro expressions within %if conditionals inside macro definitions.

Resolves: Syntax error in expression parsing issues

@mohamed-rekiba mohamed-rekiba changed the title Fix RPM Spec Processing Issues Fix: RPM Spec Processing Issues Aug 23, 2025
- Implement robust Lua scripting engine to enable sophisticated RPM spec file processing
- Add comprehensive test suite covering Lua engine functionality and edge cases
- Seamlessly integrate Lua engine with existing RPM macro expansion system
- Enable shell command execution through %(command) syntax expansion
- Prevent macro expansion in regular comments during RPM spec processing
This commit fixes two related issues with RPM spec parsing:

1. Option macro negation pattern recognition:
   - Added support for negated option macros like %{-m:0} with negation
   - Modified expandmacros() to properly detect negation patterns
   - Sets correct mactest value for negation handling

2. RPM directive preservation in multi-line expansions:
   - Fixed splitexpansionresult() escaping %if/%endif directives
   - Added pattern matching to preserve RPM control directives
   - Prevents breaking %if/%endif conditional logic

The fixes enable proper parsing of complex option macro expressions
within %if conditionals inside macro definitions.

Resolves: syntax error in expression parsing issues
Tests: All existing tests pass, enhanced test documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant