From 818c2d5d8ffb0d165b125db894170c24d0408c74 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Wed, 31 May 2023 10:26:45 -0700 Subject: [PATCH] Handle `rpm -q` commands failing if we didn't download anything I think this is new behaviour in rpm 4.19, or else we would have run into this before when testing an s390utils update. But it's easy enough to handle. Signed-off-by: Adam Williamson --- lib/utils.pm | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/utils.pm b/lib/utils.pm index 436aee5f..cb919c00 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -639,18 +639,25 @@ sub _repo_setup_updates { die "Neither ADVISORY_NVRS nor KOJITASK set! Don't know what to do"; } - # log the exact packages in the update at test time, with their - # source packages and epochs. we use /mnt as the path for this - # and similar files because, on ostree-based installs where we - # have to use a toolbox container for part of this, it's common - # to the host system and container - assert_script_run 'rpm -qp *.rpm --qf "%{SOURCERPM} %{NAME} %{EPOCHNUM} %{VERSION} %{RELEASE}\n" | sort -u > /mnt/updatepkgs.txt'; - upload_logs "/mnt/updatepkgs.txt"; - # also log just the binary package names: this is so we can check - # later whether any package from the update *should* have been - # installed, but was not - assert_script_run 'rpm -qp *.rpm --qf "%{NAME} " > /mnt/updatepkgnames.txt'; + if (script_run 'ls *.rpm') { + # we didn't actually download any packages (as they are all + # for an arch we don't test), so write dummy files + assert_script_run 'touch /mnt/updatepkgnames.txt /mnt/updatepkgs.txt'; + } + else { + # log the exact packages in the update at test time, with their + # source packages and epochs. we use /mnt as the path for this + # and similar files because, on ostree-based installs where we + # have to use a toolbox container for part of this, it's common + # to the host system and container + assert_script_run 'rpm -qp *.rpm --qf "%{SOURCERPM} %{NAME} %{EPOCHNUM} %{VERSION} %{RELEASE}\n" | sort -u > /mnt/updatepkgs.txt'; + # also log just the binary package names: this is so we can check + # later whether any package from the update *should* have been + # installed, but was not + assert_script_run 'rpm -qp *.rpm --qf "%{NAME} " > /mnt/updatepkgnames.txt'; + } upload_logs "/mnt/updatepkgnames.txt"; + upload_logs "/mnt/updatepkgs.txt"; # create the repo metadata assert_script_run "createrepo .", timeout => 180;