Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Armbian release info #366

Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/distro/distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class InfoDict(TypedDict):
"SuSE-release",
"altlinux-release",
"arch-release",
"armbian-release",
"base-release",
"centos-release",
"fedora-release",
Expand Down Expand Up @@ -1302,6 +1303,13 @@ def _distro_release_info(self) -> Dict[str, str]:
if match is not None:
distro_info["id"] = match.group(1)

# Armbian release files are not standard as they start with a
# comment. Manually set name if it has not been inferred.
if distro_info["id"] == "armbian" and distro_info.get(
"name", ""
).startswith("#"):
distro_info["name"] = "Armbian"

# CloudLinux < 7: manually enrich info with proper id.
if "cloudlinux" in distro_info.get("name", "").lower():
distro_info["id"] = "cloudlinux"
Expand Down
14 changes: 14 additions & 0 deletions tests/resources/distros/armbian/etc/armbian-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# PLEASE DO NOT EDIT THIS FILE
BOARD=nanopim4v2
BOARD_NAME="NanoPi M4V2"
BOARDFAMILY=rk3399
BUILD_REPOSITORY_URL=https://github.com/armbian/build
BUILD_REPOSITORY_COMMIT=1a8daf0
VERSION=23.02.2
LINUXFAMILY=rockchip64
ARCH=arm64
IMAGE_TYPE=nightly
BOARD_TYPE=conf
INITRD_ARCH=arm64
KERNEL_IMAGE_TYPE=Image
BRANCH=current
1 change: 1 addition & 0 deletions tests/resources/distros/armbian/etc/os-release
9 changes: 9 additions & 0 deletions tests/resources/distros/armbian/usr/lib/os-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
21 changes: 21 additions & 0 deletions tests/test_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,27 @@ def test_altlinux10_release(self) -> None:
}
self._test_release_file_info("altlinux-release", desired_info)

def test_armbian_release(self) -> None:
desired_outcome = {
"id": "debian",
"codename": "buster",
"name": "Debian GNU/Linux",
"pretty_name": "Debian GNU/Linux 10 (buster)",
"like": "",
"version": "10",
"pretty_version": "10 (buster)",
"best_version": "10",
"major_version": "10",
"minor_version": "",
}
self._test_outcome(desired_outcome)

desired_info = {
"id": "armbian",
"name": "Armbian",
}
self._test_release_file_info("armbian-release", desired_info)


def _bad_os_listdir(path: str = ".") -> NoReturn:
"""This function is used by TestOverallWithEtcNotReadable to simulate
Expand Down
Loading