Skip to content

unexpected operator in conditional #38

Description

@KmoM88

On test-aptsource-pkg-install test, the conditional for legacy distros is not being evaluated and is giving false negatives.

On the last tag actions you can see unexpected operator in the test logs

  +test-aptsource-pkg-install | distro=ubuntu:focal repo=ros2
  +test-aptsource-pkg-install | --> RUN if [ "$legacy_distros" == *"$distro"* ]; then if grep 'BEGIN PGP PUBLIC KEY BLOCK' /usr/share/ros-apt-source/${repo}.sources > /dev/null ; then exit 0; else exit 1; fi; fi;
  +test-aptsource-pkg-install | /bin/sh: 1: [: ubuntu:focal debian:buster debian:bullseye: unexpected operator

This causes that for legacy distros that section of the test is being skipped.

I've tested modifying the conditional if with a case:

  RUN case "$legacy_distros" in \
    *"$distro"*) \
      echo "Distro legacy detected: $distro"; \
      if grep 'BEGIN PGP PUBLIC KEY BLOCK' /usr/share/ros-apt-source/${repo}.sources > /dev/null; then \
        exit 0; \
      else \
        exit 1; \
      fi \
      ;; \
    *) \
      echo "Distro not legacy: $distro. Skipping check."; \
      exit 0; \
      ;; \
  esac

But this gives me errors in the legacy distros (focal & buster) when the case is evaluated. I'll investigate further to validate that the PGP key is present in the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions