Clean up the Support Platforms Logic
What does this Merge Request do and why?
As discussed in !2340 (comment 798569481), the logic to find what platform the bootstrap script is running on and if it is supported is redundant. This MR resolves this in the following ways:
- Changes the Supported Platforms array from an array made of arrays, to an associative array which has keys which are the major distributions supported. This allows for matching later and single line replacement of distribution names in commands.
- Line 23.
- Source the
/etc/os-releasefile rather than using awk. The os-release file is formatted so that it can be sourced directly, and its contents turned into variables. By doing this, we avoid some unruly text wrangling.- Lines 213 and 286.
- Use shell regular expression matching to check if the ID or ID_LIKE variables (provided by the os-release file) can be found in the entire contents of the Supported Platforms array. This avoids redundant tests.
- Line 215.
- Loop over the keys in the Supported Platforms array, then for each one compare its value to the ID and ID_LIKE variables to see which distribution family the host is part of.
- Line 287.
- Pass the result from the above loop to a new function (
platform_distro_selector), which will run thesetup_platform_linux_withandmark_platform_as_setupfunctions with the packages file including the name of the distribution family discovered in number 4.- Line 260.
- Check if the version of BASH is 3.2, macOS's default version, before declaring an associative array. Doesn't bother to declare the array if the version is old because it won't be used anyway.
- Line 22.
Merge Request checklist
-
This change is backward compatible. If not, please include steps to communicate to our users. -
Tests added for new functionality. If not, please raise Issue to follow-up. -
Documentation added/updated, if needed. -
gdk doctortest added, if needed. -
Add the ~highlightlabel if this MR should be included in theCHANGELOG.md.
Edited by Caleb Cooper