From 0710bc1edfd25a8a63af904b4102c99bfff672a0 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 19 Feb 2023 12:26:25 +0200 Subject: [PATCH] aedi: hide messages about reversed or failed source code patches during dry run --- aedi/state.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/aedi/state.py b/aedi/state.py index 08d2fbb1..4394a7d3 100644 --- a/aedi/state.py +++ b/aedi/state.py @@ -191,13 +191,15 @@ class BuildState: patch_path = self.patch_path / (patch + '.diff') assert patch_path.exists() - # Check if patch is already applied - test_arg = '--dry-run' - args = ['patch', test_arg, '--strip=1', '--input=' + str(patch_path)] + args = ['patch', '--strip=1', '--input=' + str(patch_path)] - if subprocess.run(args, cwd=extract_path, env=self.environment).returncode == 0: + # Check if patch is already applied + dry_run_args = args + ['--dry-run', '--force'] + dry_run = subprocess.run(dry_run_args, cwd=extract_path, env=self.environment, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + + if dry_run.returncode == 0: # Patch wasn't applied yet, do it now - args.remove(test_arg) subprocess.run(args, check=True, cwd=extract_path, env=self.environment) def run_pkg_config(self, *args) -> str: