Skip to content

Commit

Permalink
csmock: try harder to install missing packages
Browse files Browse the repository at this point in the history
... with `--keep-going`
  • Loading branch information
kdudka committed Nov 5, 2024
1 parent dcafaa2 commit 27e6af1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions py/csmock
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,16 @@ echo \"$self_pid\" > \"$lock_file\"'" \
cmd = ["--installdeps", srpm] + cmd_add
return (self.exec_mock_cmd(cmd, quiet=quiet) == 0)

def emergency_install_deps(self, srpm):
(_, raw_deps) = self.results.get_cmd_output("rpm -qp '%s' --requires" % srpm)
for dep in raw_deps.split("\n"):
def emergency_install_pkgs(self, pkgs):
for dep in pkgs:
if (dep):
self.try_install([dep])

def emergency_install_deps(self, srpm):
(_, raw_deps) = self.results.get_cmd_output("rpm -qp '%s' --requires" % srpm)
pkgs = raw_deps.split("\n")
self.emergency_install_pkgs(pkgs)

def remove(self, pkgs):
return (self.exec_mock_cmd(["--remove"] + pkgs) == 0)

Expand Down Expand Up @@ -404,6 +408,11 @@ echo \"$self_pid\" > \"$lock_file\"'" \
if try_only:
return False

if keep_going:
# try to install the missing packages one by one
self.emergency_install_pkgs(missing_deps)
missing_deps = find_missing_pkgs(pkgs, self.results, self)

self.results.error(f"failed to install required packages ({strlist_to_shell_cmd(missing_deps)})",
ec=ec_by_scrub)

Expand Down

0 comments on commit 27e6af1

Please sign in to comment.