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 <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2023-05-31 10:26:45 -07:00
parent d8bad7a292
commit 818c2d5d8f
1 changed files with 18 additions and 11 deletions

View File

@ -639,18 +639,25 @@ sub _repo_setup_updates {
die "Neither ADVISORY_NVRS nor KOJITASK set! Don't know what to do"; 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 if (script_run 'ls *.rpm') {
# source packages and epochs. we use /mnt as the path for this # we didn't actually download any packages (as they are all
# and similar files because, on ostree-based installs where we # for an arch we don't test), so write dummy files
# have to use a toolbox container for part of this, it's common assert_script_run 'touch /mnt/updatepkgnames.txt /mnt/updatepkgs.txt';
# to the host system and container }
assert_script_run 'rpm -qp *.rpm --qf "%{SOURCERPM} %{NAME} %{EPOCHNUM} %{VERSION} %{RELEASE}\n" | sort -u > /mnt/updatepkgs.txt'; else {
upload_logs "/mnt/updatepkgs.txt"; # log the exact packages in the update at test time, with their
# also log just the binary package names: this is so we can check # source packages and epochs. we use /mnt as the path for this
# later whether any package from the update *should* have been # and similar files because, on ostree-based installs where we
# installed, but was not # have to use a toolbox container for part of this, it's common
assert_script_run 'rpm -qp *.rpm --qf "%{NAME} " > /mnt/updatepkgnames.txt'; # 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/updatepkgnames.txt";
upload_logs "/mnt/updatepkgs.txt";
# create the repo metadata # create the repo metadata
assert_script_run "createrepo .", timeout => 180; assert_script_run "createrepo .", timeout => 180;