[projects/pld-builder.new] Fix stale package removal and uninstall()
arekm
arekm at pld-linux.org
Thu Apr 16 00:14:01 CEST 2026
commit 0a3317132c08a4f9b625cfa87dcb626c5704ea08
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Apr 16 00:12:22 2026 +0200
Fix stale package removal and uninstall()
Remove packages in a single poldek --erase call instead of one by
one — the old approach caused "no such package" errors when removing
one package cascaded to remove others later in the list.
Use uninstall() for stale package cleanup so removal goes through
close_killset() safety checks and poldek's dependency handling.
PLD_Builder/install.py | 32 ++++++++++----------------------
PLD_Builder/request.py | 11 +++++++----
2 files changed, 17 insertions(+), 26 deletions(-)
---
diff --git a/PLD_Builder/install.py b/PLD_Builder/install.py
index 3e1ce50..6e56a33 100644
--- a/PLD_Builder/install.py
+++ b/PLD_Builder/install.py
@@ -94,12 +94,14 @@ def uninstall(conflicting, b):
util.append_to(b.logfile, err)
b.log_line("error: conflicting packages uninstallation failed")
return False
- else:
- for k in conflicting.keys():
- b.log_line("removing %s" % k)
- res = chroot.run("poldek --noask --erase %s" % k, logfile = b.logfile, user = "root")
- if res != 0:
- b.log_line("package %s removal failed" % k)
+ if not conflicting:
+ return True
+ pkgs = ' '.join(sorted(conflicting.keys()))
+ b.log_line("removing: %s" % pkgs)
+ res = chroot.run("poldek --noask --erase %s" % pkgs, logfile = b.logfile, user = "root")
+ if res != 0:
+ b.log_line("package removal failed")
+ return False
return True
def uninstall_self_conflict(b):
@@ -137,11 +139,6 @@ def cleanup_stale_packages(b):
have installed packages from the wrong version family (e.g. php53-*
when the current build needs php85). These satisfy virtual deps in
the rpm db, preventing poldek from installing the correct version.
-
- When -D php_suffix is set, only that version is kept. Otherwise,
- all versioned PHP packages are removed — poldek will reinstall
- whatever the spec actually needs, guided by its EVR tiebreaker and
- the spec's version constraints.
"""
log.notice("cleaning up stale packages for %s" % b.spec)
patterns = b.cleanup_patterns()
@@ -160,17 +157,8 @@ def cleanup_stale_packages(b):
if not stale:
return
- for p in hold:
- stale.pop(p, None)
-
- if not stale:
- return
-
- names = ' '.join(sorted(stale))
- b.log_line("removing stale packages from chroot: %s" % names)
- res = rpm_remove(names, b)
- if res != 0:
- b.log_line("warning: stale package removal had errors (non-fatal)")
+ b.log_line("removing stale packages from chroot: %s" % ' '.join(sorted(stale)))
+ uninstall(stale, b)
def install_br(r, b):
log.notice("installing BuildRequires for %s" % b.spec)
diff --git a/PLD_Builder/request.py b/PLD_Builder/request.py
index 08a243d..ebf107c 100644
--- a/PLD_Builder/request.py
+++ b/PLD_Builder/request.py
@@ -419,10 +419,10 @@ class Batch:
def _php_patterns(self, require_suffix=False):
"""Build glob patterns for unwanted PHP version packages.
- When require_suffix is True, return [] if php_suffix is not set
- (used for --ignore: let poldek resolve freely). When False,
- return patterns for all versioned PHP except the explicitly
- requested one (used for chroot cleanup).
+ When require_suffix is True, return [] unless php_suffix is
+ set — used for --ignore so poldek can resolve freely.
+ When False, return patterns for all versioned PHP except the
+ requested one — used for cleanup to remove stale packages.
"""
if require_suffix and 'php_suffix' not in self.defines:
return []
@@ -434,6 +434,9 @@ class Batch:
if 'php_suffix' in self.defines:
prefixes.discard("php%s" % self.defines['php_suffix'])
+ if not prefixes:
+ return []
+
res = ['hhvm-*']
for p in sorted(prefixes):
res.append("%s-*" % p)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/0a3317132c08a4f9b625cfa87dcb626c5704ea08
More information about the pld-cvs-commit
mailing list