[projects/pld-builder.new] Remove installed packages matching ignore patterns before checking BRs
arekm
arekm at pld-linux.org
Wed Apr 15 21:58:36 CEST 2026
commit 1112adeb5ab0ada69d19f1d237c22b6494ea6d90
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Wed Apr 15 21:47:53 2026 +0200
Remove installed packages matching ignore patterns before checking BRs
The builder reuses chroots across builds, so a previous build may
have installed packages that should be ignored (e.g. php53-* when
the default PHP is php85). These satisfy virtual deps in the rpm
db, causing rpmbuild to report "no BR needed" while the installed
packages are actually broken.
Before checking BuildRequires, query the chroot for installed
packages matching the ignore patterns and remove them. This forces
get_missing_br() to report the deps as unmet, so poldek installs
the correct versions.
The call is placed in rpm_builder.py between uninstall_self_conflict
and install_br, keeping the build sequence explicit: remove
conflicts, remove ignored packages, then install BRs.
Also:
- Add ignore_patterns() to Batch exposing the raw pattern list,
so install.py uses patterns directly instead of re-parsing the
--ignore=X string
- Batch all patterns into a single rpm -qa call
- Check rpm -e exit code and log on failure
- Guard the new step with 'if not res' to skip after prior failure
- Simplify ignores() formatting
PLD_Builder/install.py | 33 +++++++++++++++++++++++++++++++++
PLD_Builder/request.py | 12 ++++++------
PLD_Builder/rpm_builder.py | 2 ++
3 files changed, 41 insertions(+), 6 deletions(-)
---
diff --git a/PLD_Builder/install.py b/PLD_Builder/install.py
index acbf58a..e304503 100644
--- a/PLD_Builder/install.py
+++ b/PLD_Builder/install.py
@@ -126,6 +126,39 @@ def uninstall_self_conflict(b):
b.log_line("no BuildConflicts found")
return True
+def remove_ignored_packages(b):
+ """Remove installed packages that match the ignore patterns.
+
+ The builder reuses chroots across builds, so a previous build may
+ have installed packages that should be ignored (e.g. php53-* when
+ the default PHP is php85). These satisfy virtual deps in the rpm
+ db, preventing poldek from installing the correct version. Remove
+ them so that get_missing_br() reports the deps as unmet and poldek
+ installs the right packages.
+ """
+ patterns = b.ignore_patterns()
+ if not patterns:
+ return
+
+ query = ' '.join("'%s'" % p for p in patterns)
+ f = chroot.popen("rpm -qa %s --queryformat '%%{NAME}\\n'" % query, user = "root", encoding = "utf-8")
+ seen = {}
+ for l in f:
+ name = l.strip()
+ if name:
+ seen[name] = 1
+ f.close()
+
+ if not seen:
+ return
+
+ to_remove = ' '.join(seen.keys())
+ b.log_line("removing ignored packages from chroot: %s" % to_remove)
+ res = chroot.run("rpm --allmatches -e %s" % to_remove,
+ logfile = b.logfile, user = "root")
+ if res != 0:
+ b.log_line("warning: removal of ignored packages failed")
+
def install_br(r, b):
def get_missing_br(r, b):
# ignore internal rpm dependencies, see lib/rpmns.c for list
diff --git a/PLD_Builder/request.py b/PLD_Builder/request.py
index 1416042..5dc6e68 100644
--- a/PLD_Builder/request.py
+++ b/PLD_Builder/request.py
@@ -439,17 +439,17 @@ class Batch:
return res
+ def ignore_patterns(self):
+ return self.php_ignores()
+
# build ignore package list for poldek
def ignores(self):
- ignores = self.php_ignores()
+ patterns = self.ignore_patterns()
- if len(ignores) == 0:
+ if len(patterns) == 0:
return ""
- def add_ignore(s):
- return "--ignore=%s" % s
-
- return " ".join(list(map(add_ignore, ignores)))
+ return " ".join("--ignore=%s" % s for s in patterns)
def kernel_string(self):
r = ""
diff --git a/PLD_Builder/rpm_builder.py b/PLD_Builder/rpm_builder.py
index 91014d5..14ed8ce 100644
--- a/PLD_Builder/rpm_builder.py
+++ b/PLD_Builder/rpm_builder.py
@@ -231,6 +231,8 @@ def build_rpm(r, b):
if not res:
if ("no-install-br" not in r.flags) and not install.uninstall_self_conflict(b):
res = "FAIL_DEPS_UNINSTALL"
+ if ("no-install-br" not in r.flags):
+ install.remove_ignored_packages(b)
if ("no-install-br" not in r.flags) and not install.install_br(r, b):
res = "FAIL_DEPS_INSTALL"
if not res:
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/1112adeb5ab0ada69d19f1d237c22b6494ea6d90
More information about the pld-cvs-commit
mailing list