From 309ae75800c12649c75b897b162877480682c3c5 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Sun, 30 Jan 2022 18:09:44 +0100 Subject: [PATCH 1/2] Add Buildroot in distro.id() documentation list For Buildroot information, see https://buildroot.org/ Buildroot systems follows the freedesktop.org /etc/os-release spec. See: https://git.busybox.net/buildroot/commit/?id=451a887894faddef019e9a0628c21b5f2e9eee56 Signed-off-by: Julien Olivain --- src/distro/distro.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/distro/distro.py b/src/distro/distro.py index 4d08067..384b453 100755 --- a/src/distro/distro.py +++ b/src/distro/distro.py @@ -220,6 +220,7 @@ def id() -> str: "opensuse" openSUSE "amzn" Amazon Linux "arch" Arch Linux + "buildroot" Buildroot "cloudlinux" CloudLinux OS "exherbo" Exherbo Linux "gentoo" GenToo Linux From 7ada49b5e2c5d03e6e6095552df6476d8e345bfa Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Sun, 30 Jan 2022 18:06:24 +0100 Subject: [PATCH 2/2] Add Buildroot os-release test Add a test for Linux systems generated with Buildroot: https://buildroot.org/ Buildroot systems follows the freedesktop.org /etc/os-release spec. See: https://git.busybox.net/buildroot/commit/?id=451a887894faddef019e9a0628c21b5f2e9eee56 Example of `distro -j` output: { "codename": "", "id": "buildroot", "like": "", "version": "2022.02", "version_parts": { "build_number": "", "major": "2022", "minor": "02" } } Signed-off-by: Julien Olivain --- tests/resources/distros/buildroot/etc/os-release | 5 +++++ tests/test_distro.py | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/resources/distros/buildroot/etc/os-release diff --git a/tests/resources/distros/buildroot/etc/os-release b/tests/resources/distros/buildroot/etc/os-release new file mode 100644 index 0000000..3aeb531 --- /dev/null +++ b/tests/resources/distros/buildroot/etc/os-release @@ -0,0 +1,5 @@ +NAME=Buildroot +VERSION=2022.02 +ID=buildroot +VERSION_ID=2022.02 +PRETTY_NAME="Buildroot 2022.02" diff --git a/tests/test_distro.py b/tests/test_distro.py index b40b3aa..c7f884f 100644 --- a/tests/test_distro.py +++ b/tests/test_distro.py @@ -163,6 +163,17 @@ def test_arch_os_release(self) -> None: } self._test_outcome(desired_outcome) + def test_buildroot_os_release(self) -> None: + desired_outcome = { + "id": "buildroot", + "name": "Buildroot", + "pretty_name": "Buildroot 2022.02", + "version": "2022.02", + "pretty_version": "2022.02", + "best_version": "2022.02", + } + self._test_outcome(desired_outcome) + def test_kali_os_release(self) -> None: desired_outcome = { "id": "kali",