diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7f8dd008..bc254f6e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 @@ -25,20 +25,31 @@ jobs: test: name: Python ${{ matrix.python }} - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: + - "ubuntu-latest" python: - - "3.6" - "3.7" - "3.8" - "3.9" - "3.10" - - "pypy-3.6" + - "3.11" + - "3.12" + include: + - os: "ubuntu-20.04" + python: "3.6" + - os: "ubuntu-20.04" + python: "pypy-3.6" + - os: "ubuntu-22.04" + python: "pypy-3.10" + - os: "macos-12" + python: 3.12 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python }} uses: actions/setup-python@v4 @@ -61,7 +72,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: codecov/codecov-action@v3 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ffbfe8dc..5b58fb09 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest environment: Deploy steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.tag }} - uses: actions/setup-python@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9a2251ac..95cbb415 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,11 +5,11 @@ repos: - id: black args: ["--target-version", "py36"] - repo: https://github.com/PyCQA/flake8 - rev: 3.9.2 + rev: 6.1.0 hooks: - id: flake8 - repo: https://github.com/pycqa/isort - rev: 5.9.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-mypy diff --git a/src/distro/distro.py b/src/distro/distro.py index f78de10f..8346765b 100755 --- a/src/distro/distro.py +++ b/src/distro/distro.py @@ -126,6 +126,7 @@ class InfoDict(TypedDict): # Base file names to be looked up for if _UNIXCONFDIR is not readable. _DISTRO_RELEASE_BASENAMES = [ "SuSE-release", + "altlinux-release", "arch-release", "base-release", "centos-release", @@ -152,6 +153,8 @@ class InfoDict(TypedDict): "system-release", "plesk-release", "iredmail-release", + "board-release", + "ec2_version", ) @@ -244,6 +247,7 @@ def id() -> str: "rocky" Rocky Linux "aix" AIX "guix" Guix System + "altlinux" ALT Linux ============== ========================================= If you have a need to get distros for reliable IDs added into this set, @@ -994,10 +998,10 @@ def info(self, pretty: bool = False, best: bool = False) -> InfoDict: For details, see :func:`distro.info`. """ - return dict( + return InfoDict( id=self.id(), version=self.version(pretty, best), - version_parts=dict( + version_parts=VersionDict( major=self.major_version(best), minor=self.minor_version(best), build_number=self.build_number(best), diff --git a/tests/resources/distros/altlinux10/etc/altlinux-release b/tests/resources/distros/altlinux10/etc/altlinux-release new file mode 100644 index 00000000..dc48160d --- /dev/null +++ b/tests/resources/distros/altlinux10/etc/altlinux-release @@ -0,0 +1 @@ +ALT Server 10.1 (Mendelevium) diff --git a/tests/resources/distros/altlinux10/etc/fedora-release b/tests/resources/distros/altlinux10/etc/fedora-release new file mode 120000 index 00000000..eefa5c16 --- /dev/null +++ b/tests/resources/distros/altlinux10/etc/fedora-release @@ -0,0 +1 @@ +altlinux-release \ No newline at end of file diff --git a/tests/resources/distros/altlinux10/etc/os-release b/tests/resources/distros/altlinux10/etc/os-release new file mode 100644 index 00000000..9363b09a --- /dev/null +++ b/tests/resources/distros/altlinux10/etc/os-release @@ -0,0 +1,10 @@ +NAME="ALT Server" +VERSION="10.1" +ID=altlinux +VERSION_ID=10.1 +PRETTY_NAME="ALT Server 10.1 (Mendelevium)" +ANSI_COLOR="1;33" +CPE_NAME="cpe:/o:alt:server:10.1" +BUILD_ID="ALT Server 10.1" +HOME_URL="https://basealt.ru/" +BUG_REPORT_URL="https://bugs.altlinux.org/" diff --git a/tests/resources/distros/altlinux10/etc/redhat-release b/tests/resources/distros/altlinux10/etc/redhat-release new file mode 120000 index 00000000..eefa5c16 --- /dev/null +++ b/tests/resources/distros/altlinux10/etc/redhat-release @@ -0,0 +1 @@ +altlinux-release \ No newline at end of file diff --git a/tests/resources/distros/altlinux10/etc/system-release b/tests/resources/distros/altlinux10/etc/system-release new file mode 120000 index 00000000..eefa5c16 --- /dev/null +++ b/tests/resources/distros/altlinux10/etc/system-release @@ -0,0 +1 @@ +altlinux-release \ No newline at end of file diff --git a/tests/resources/distros/arch/usr/lib/os-release b/tests/resources/distros/arch/usr/lib/os-release index 30e5cf32..8662a54d 100644 --- a/tests/resources/distros/arch/usr/lib/os-release +++ b/tests/resources/distros/arch/usr/lib/os-release @@ -1,7 +1,11 @@ NAME="Arch Linux" -ID=arch PRETTY_NAME="Arch Linux" -ANSI_COLOR="0;36" -HOME_URL="https://www.archlinux.org/" +ID=arch +BUILD_ID=rolling +ANSI_COLOR="38;2;23;147;209" +HOME_URL="https://archlinux.org/" +DOCUMENTATION_URL="https://wiki.archlinux.org/" SUPPORT_URL="https://bbs.archlinux.org/" BUG_REPORT_URL="https://bugs.archlinux.org/" +PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/" +LOGO=archlinux-logo diff --git a/tests/resources/distros/bttcb1/etc/board-release b/tests/resources/distros/bttcb1/etc/board-release new file mode 100644 index 00000000..f79e870e --- /dev/null +++ b/tests/resources/distros/bttcb1/etc/board-release @@ -0,0 +1,9 @@ +# PLEASE DO NOT EDIT THIS FILE +BOARD=h616 +BOARD_NAME="BTT-CB1" +DISTRIBUTION_CODENAME=bullseye +VERSION=2.3.1 +LINUXFAMILY=sun50iw9 +ARCH=arm64 +INITRD_ARCH=arm64 +BRANCH=current \ No newline at end of file diff --git a/tests/resources/distros/bttcb1/etc/os-release b/tests/resources/distros/bttcb1/etc/os-release new file mode 100644 index 00000000..c4f321ed --- /dev/null +++ b/tests/resources/distros/bttcb1/etc/os-release @@ -0,0 +1,9 @@ +PRETTY_NAME="BTT-CB1 2.3.1 Bullseye" +NAME="Debian GNU/Linux" +VERSION_ID="11" +VERSION="11 (bullseye)" +VERSION_CODENAME=bullseye +ID=debian +HOME_URL="https://www.debian.org/" +SUPPORT_URL="https://www.debian.org/support" +BUG_REPORT_URL="https://bugs.debian.org/" \ No newline at end of file diff --git a/tests/resources/distros/bttcb1/usr/lib/os-release b/tests/resources/distros/bttcb1/usr/lib/os-release new file mode 100644 index 00000000..08d94283 --- /dev/null +++ b/tests/resources/distros/bttcb1/usr/lib/os-release @@ -0,0 +1,9 @@ +PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" +NAME="Debian GNU/Linux" +VERSION_ID="11" +VERSION="11 (bullseye)" +VERSION_CODENAME=bullseye +ID=debian +HOME_URL="https://www.debian.org/" +SUPPORT_URL="https://www.debian.org/support" +BUG_REPORT_URL="https://bugs.debian.org/" \ No newline at end of file diff --git a/tests/resources/distros/debiantesting/bin/lsb_release b/tests/resources/distros/debiantesting/bin/lsb_release new file mode 100755 index 00000000..40b0a880 --- /dev/null +++ b/tests/resources/distros/debiantesting/bin/lsb_release @@ -0,0 +1,23 @@ +#!/bin/bash +# +# lsb_release command for testing the ld module. +# Only the -a option is supported. +# +# This version of the lsb_release command works without a corresponding +# etc/lsb-release file. +# + +if [[ "$@" != "-a" ]]; then + echo "Usage: lsb_release -a" + exit 2 +fi + +cat < None: } self._test_outcome(desired_outcome) + def test_debiantesting_os_release(self) -> None: + desired_outcome = { + "id": "debian", + "name": "Debian GNU/Linux", + "pretty_name": "Debian GNU/Linux bookworm/sid", + "version": "bookworm/sid", + "pretty_version": "bookworm/sid (bookworm)", + "best_version": "bookworm/sid", + "codename": "bookworm", + } + self._test_outcome(desired_outcome) + def test_fedora19_os_release(self) -> None: desired_outcome = { "id": "fedora", @@ -509,6 +521,34 @@ def test_cloudlinux7_os_release(self) -> None: } self._test_outcome(desired_outcome) + def test_altlinux10_os_release(self) -> None: + desired_outcome = { + "id": "altlinux", + "name": "ALT Server", + "pretty_name": "ALT Server 10.1 (Mendelevium)", + "version": "10.1", + "pretty_version": "10.1", + "best_version": "10.1", + "major_version": "10", + "minor_version": "1", + } + self._test_outcome(desired_outcome) + + def test_bttcb1_os_release(self) -> None: + desired_outcome = { + "id": "debian", + "codename": "bullseye", + "name": "Debian GNU/Linux", + "pretty_name": "BTT-CB1 2.3.1 Bullseye", + "like": "", + "version": "11", + "pretty_version": "11 (bullseye)", + "best_version": "11", + "major_version": "11", + "minor_version": "0", + } + self._test_outcome(desired_outcome) + class TestWithRootDir(TestOSRelease): """Test that a LinuxDistribution can be created using an arbitrary root_dir @@ -1105,6 +1145,20 @@ def test_cloudlinux7_dist_release(self) -> None: } self._test_outcome(desired_outcome, "cloudlinux", "7", "redhat") + def test_altlinux10_dist_release(self) -> None: + desired_outcome = { + "id": "altlinux", + "name": "ALT Server", + "codename": "Mendelevium", + "pretty_name": "ALT Server 10.1 (Mendelevium)", + "version": "10.1", + "pretty_version": "10.1 (Mendelevium)", + "best_version": "10.1", + "major_version": "10", + "minor_version": "1", + } + self._test_outcome(desired_outcome, "altlinux", "10") + @pytest.mark.skipif(not IS_LINUX, reason="Irrelevant on non-linux") class TestOverall(DistroTestCase): @@ -1280,6 +1334,20 @@ def test_debian10_release(self) -> None: self._test_outcome(desired_outcome) self._test_non_existing_release_file() + def test_debiantesting_release(self) -> None: + desired_outcome = { + "id": "debian", + "name": "Debian GNU/Linux", + "pretty_name": "Debian GNU/Linux bookworm/sid", + "version": "bookworm/sid", + "pretty_version": "bookworm/sid (bookworm)", + "best_version": "bookworm/sid", + "codename": "bookworm", + "major_version": "", + } + self._test_outcome(desired_outcome) + self._test_non_existing_release_file() + def test_exherbo_release(self) -> None: desired_outcome = { "id": "exherbo", @@ -1854,6 +1922,28 @@ def test_cloudlinux7_release(self) -> None: } self._test_outcome(desired_outcome) + def test_altlinux10_release(self) -> None: + desired_outcome = { + "id": "altlinux", + "name": "ALT Server", + "codename": "Mendelevium", + "pretty_name": "ALT Server 10.1 (Mendelevium)", + "version": "10.1", + "pretty_version": "10.1 (Mendelevium)", + "best_version": "10.1", + "major_version": "10", + "minor_version": "1", + } + self._test_outcome(desired_outcome) + + desired_info = { + "id": "altlinux", + "name": "ALT Server", + "version_id": "10.1", + "codename": "Mendelevium", + } + self._test_release_file_info("altlinux-release", desired_info) + def _bad_os_listdir(path: str = ".") -> NoReturn: """This function is used by TestOverallWithEtcNotReadable to simulate diff --git a/tox.ini b/tox.ini index cc9dfc51..f080b5c5 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ [tox] minversion = 1.9 -envlist = lint, py{36,37,38,39,310,py3} +envlist = lint, py{36,37,38,39,310,311,312,py3} isolated_build = true skip_missing_interpreters = true