On Mon, Nov 2, 2020 at 12:02 PM Ondrej Mosnacek <omosnace@xxxxxxxxxx> wrote: > For whatever reason, some mirrors contain more than one image version in > the directory, causing the test to bail out. This happens only sometimes > and restarting the Travis job usually helps, but it's better to adapt > the script to handle this case. > > Tweak the script to pick the lexicographically last image and exit with > error only if there is no image at all. > > Signed-off-by: Ondrej Mosnacek <omosnace@xxxxxxxxxx> > --- > travis-ci/run-kvm-test.sh | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/travis-ci/run-kvm-test.sh b/travis-ci/run-kvm-test.sh > index 6afbf96..bb7c3b7 100755 > --- a/travis-ci/run-kvm-test.sh > +++ b/travis-ci/run-kvm-test.sh > @@ -36,8 +36,9 @@ VCPUS="$(nproc)" > # - https://alt.fedoraproject.org/en/verify.html > cd "$HOME" > wget -r -nd -np -l 1 -H -e robots=off -A "*.raw.xz,*-CHECKSUM" "$BASE_URL" > -if [ $(ls -1q *.raw.xz | wc -l) -ne 1 ]; then > - echo "$0: too many image files downloaded!" 1>&2 > +latest_image="$(ls -1q *.raw.xz | tail -n 1)" > +if [ -z "$latest_image" ]; then > + echo "$0: no image file downloaded!" 1>&2 > exit 1 > fi > > @@ -49,7 +50,8 @@ fi > sha256sum --ignore-missing -c ./*-CHECKSUM > > # Extract the image > -unxz -T0 *.raw.xz > +unxz -T0 "$latest_image" > +latest_image="${latest_image%.xz}" > > # Search is needed for $HOME so virt service can access the image file. > chmod a+x "$HOME" > @@ -60,7 +62,7 @@ chmod a+x "$HOME" > # - Enable passwordless login > # - Force a relabel to fix labels on ssh keys > # > -sudo virt-sysprep -a *.raw \ > +sudo virt-sysprep -a "$latest_image" \ > --root-password password:123456 \ > --hostname fedoravm \ > --append-line '/etc/ssh/sshd_config:PermitRootLogin yes' \ > @@ -81,7 +83,7 @@ sudo virt-install \ > --name fedoravm \ > --memory $MEMORY \ > --vcpus $VCPUS \ > - --disk *.raw \ > + --disk "$latest_image" \ > --import --noautoconsole > > # > -- > 2.26.2 Applied: https://github.com/SELinuxProject/selinux-testsuite/commit/025fe57d9b707c925590b78c26dfc9726a4a3933 -- Ondrej Mosnacek Software Engineer, Platform Security - SELinux kernel Red Hat, Inc.