Skip to content

Resolve "Properly support different OS versions"

Rainer Kartmann requested to merge 117-properly-support-different-os-versions into dev

Closes #117 (closed)

Add support for syntax such as

{
  "git": {
    "url": "...",
    "default_checkout_ref": {
       "switch_os": {
         "bionic": "main",
         "focal": "ubuntu20",
         "jammy": "ubuntu22",
         "buster": "debian10"
       }
    }
  }
}

where distro codenames (e.g. bionic) are used to switch between different OS versions.

JSON files are post-processed during loading. At that point, JSON objects with a switch_os key are resolved to their effective value. For example

{
  "git": {
    "url": "...",
    "default_checkout_ref": {
       "switch_os": {
         "bionic": "main",
         "focal": "ubuntu20",
         "jammy": "ubuntu22",
         "buster": "debian10",
         "default": "main"
       }
    }
  }
}

on "focal", this is resolved to

{
  "git": {
    "url": "...",
    "default_checkout_ref": "ubuntu20"
  }
}

and on "whatever", which is not contained, "default" is used:

{
  "git": {
    "url": "...",
    "default_checkout_ref": "main"
  }
}

See https://gitlab.com/ArmarX/meta/setup/-/blob/b780c043d366a8016692eb3a0bd43cd497d5b322/tests/core/util/json/test_json_switch_os.py for a test example

Edited by Rainer Kartmann

Merge request reports