fix(autopatch): Added a run_script action to pre-populate the empty pesign.patches file before add_files runs, and set modify_spec: fals #1

Closed
almalinux-automation wants to merge 1 commit from agent-fix/a10s-20261001-035721 into a10s

Automated fix by autopatch agent.

Summary: Added a run_script action to pre-populate the empty pesign.patches file before add_files runs, and set modify_spec: false on add_files so it only copies the patch file.

Root cause

The add_files action failed with ValueError: File is empty because pesign uses an unusual patch-declaration mechanism:

  • Source3: pesign.patches + %include %{SOURCE3} means all PatchN: declarations live in the separate pesign.patches file, not in the main spec.
  • Upstream ships pesign.patches as an empty placeholder (populated at build time by a separate tool).
  • The autopatch tool detects the *.patches file, redirects the patch declaration target to pesign.patches, and calls read_file_data("pesign.patches") — which raises ValueError: File is empty for a 0-byte file before it can insert anything.

Fix applied:

  • Added scripts/init_patches_file.sh — a script that writes Patch0003: 0003-Add-versioned-x86_64-arches-support.patch into pesign.patches when the file is empty, bypassing the tool's inability to seed an empty spec-fragment file.
  • Added a run_script action (with cwd: rpms) immediately before add_files to invoke that script.
  • Set modify_spec: false on the existing add_files action so it only copies the patch file into the package directory without trying to insert the PatchN: directive again (the script already handled that).

After the fix, pesign.patches contains the Patch0003: declaration, the patch file is present in the rpms tree, the release suffix .alma.1 is appended, and the changelog entry is added — all as intended by the original config.

Original error

Type: ValueError

Traceback (most recent call last):
  File "/root/autopatch-tool/src/webserv.py", line 95, in debrand_packages
    result = apply_modifications(
  File "/root/autopatch-tool/src/debranding.py", line 138, in apply_modifications
    config.apply_actions(rpms_working_dir + f"/{package}")
  File "/root/autopatch-tool/src/actions_handler.py", line 938, in apply_actions
    action.execute(Path(package_path))
  File "/root/autopatch-tool/src/actions_handler.py", line 760, in execute
    spec = read_file_data(spec_file_path)
  File "/root/autopatch-tool/src/actions_handler.py", line 65, in read_file_data
    raise ValueError("File is empty")
ValueError: File is empty

Package: pesign | Webhook branch: c10s

Automated fix by autopatch agent. **Summary:** Added a run_script action to pre-populate the empty pesign.patches file before add_files runs, and set modify_spec: false on add_files so it only copies the patch file. ### Root cause The `add_files` action failed with `ValueError: File is empty` because `pesign` uses an unusual patch-declaration mechanism: - `Source3: pesign.patches` + `%include %{SOURCE3}` means all `PatchN:` declarations live in the separate `pesign.patches` file, not in the main spec. - Upstream ships `pesign.patches` as an **empty** placeholder (populated at build time by a separate tool). - The autopatch tool detects the `*.patches` file, redirects the patch declaration target to `pesign.patches`, and calls `read_file_data("pesign.patches")` — which raises `ValueError: File is empty` for a 0-byte file before it can insert anything. Fix applied: - Added `scripts/init_patches_file.sh` — a script that writes `Patch0003: 0003-Add-versioned-x86_64-arches-support.patch` into `pesign.patches` when the file is empty, bypassing the tool's inability to seed an empty spec-fragment file. - Added a `run_script` action (with `cwd: rpms`) immediately before `add_files` to invoke that script. - Set `modify_spec: false` on the existing `add_files` action so it only copies the patch file into the package directory without trying to insert the `PatchN:` directive again (the script already handled that). After the fix, `pesign.patches` contains the `Patch0003:` declaration, the patch file is present in the rpms tree, the release suffix `.alma.1` is appended, and the changelog entry is added — all as intended by the original config. ### Original error **Type:** `ValueError` ``` Traceback (most recent call last): File "/root/autopatch-tool/src/webserv.py", line 95, in debrand_packages result = apply_modifications( File "/root/autopatch-tool/src/debranding.py", line 138, in apply_modifications config.apply_actions(rpms_working_dir + f"/{package}") File "/root/autopatch-tool/src/actions_handler.py", line 938, in apply_actions action.execute(Path(package_path)) File "/root/autopatch-tool/src/actions_handler.py", line 760, in execute spec = read_file_data(spec_file_path) File "/root/autopatch-tool/src/actions_handler.py", line 65, in read_file_data raise ValueError("File is empty") ValueError: File is empty ``` --- Package: `pesign` | Webhook branch: `c10s`
Added a run_script action to pre-populate the empty pesign.patches file before add_files runs, and set modify_spec: false on add_files so it only copies the patch file.
eabdullin closed this pull request 2026-10-01 08:43:31 +00:00
Owner

Should be fixed in autopatch itself

Should be fixed in autopatch itself

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
autopatch/pesign!1
No description provided.