internal: more gracefully determine host OS
Metadata
Current evaluation
Merged #1636 (a25cfcc12), adding graceful /etc/os-release parsing, Trusty codename fallbacks, and clearer errors for unsupported distributions.
Resolution: closed resolved
Reason: PR #1636 was merged as commit a25cfcc12. It introduced centralized host OS parsing with fallback handling and friendlier unsupported-distro errors.
Evaluated by: mr-cal-bot
No scores available.
Issue body
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?
- [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?
- [x] Have you successfully run `./runtests.sh static`?
- [x] Have you successfully run `./runtests.sh unit`?
-----
Currently snapcraft just reads the `/etc/os-release` file into a dict and accesses keys everywhere without caring whether or not they exist. This leads to difficult-to-diagnose errors on distros where e.g. the `VERSION_CODENAME` isn't set. That particular example includes Trusty, where we can use the VERSION_ID as a fallback to determine the codename.
Create a class around parsing `/etc/os-release` so we can gracefully fallback as appropriate. This allows the snapcraft snap to be used on Trusty, and also makes the errors when running on an unsupported distro more friendly.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged #1636 (a25cfcc12), adding graceful /etc/os-release parsing, Trusty codename fallbacks, and clearer errors for unsupported distributions. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged #1636 (commit a25cfcc12), adding graceful /etc/os-release parsing, codename fallbacks for Trusty, and friendlier errors on unsupported distros. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged a refactoring that replaces direct /etc/os-release parsing with a robust class handling missing keys and fallbacks, enabling Ubuntu Trusty support and improving error messages. A follow-up PR will expose the API publicly. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged an update to gracefully parse /etc/os-release with fallbacks for host OS detection, enabling Ubuntu Trusty compatibility and improving error messages. The maintainer deferred exposing the parser publicly to a follow-up PR. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #3646 utils: gracefully determine host os (CRAFT-845) | snapcraft | merged | PR #3646 (CRAFT-845) merged into snapcraft/7.0 as commit dcee4f58, forward-porting commit a25cfcc from #1636: added snapcraft/os_release.py with an OsRelease class for graceful /etc/os-release parsing and codename fallbacks. |