Skip to content

Commit a7721c8

Browse files
Merge branch 'master' into feat/cloudlinuxvm_support
2 parents ec93f04 + c188abf commit a7721c8

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ namely from these data sources (from high to low precedence):
104104
* The os-release file `/etc/os-release` if present, with a fall-back on `/usr/lib/os-release` if needed.
105105
* The output of the `lsb_release` command, if available.
106106
* The distro release file (`/etc/*(-|_)(release|version)`), if present.
107-
* The `uname` command for BSD based distrubtions.
107+
* The `uname` command for BSD based distributions.
108108

109109

110110
## Python and Distribution Support

src/distro/distro.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,8 +1196,10 @@ def _parse_lsb_release_content(lines: Iterable[str]) -> Dict[str, str]:
11961196
if len(kv) != 2:
11971197
# Ignore lines without colon.
11981198
continue
1199-
k, v = kv
1200-
props.update({k.replace(" ", "_").lower(): v.strip()})
1199+
k, v = kv[0], kv[1].strip()
1200+
if v == "n/a":
1201+
v = ""
1202+
props.update({k.replace(" ", "_").lower(): v})
12011203
return props
12021204

12031205
@cached_property
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
/bin/cat <<'EOT'
3+
No LSB modules are available.
4+
Distributor ID: Debian
5+
Description: Debian GNU/Linux trixie/sid
6+
Release: n/a
7+
Codename: trixie
8+
EOT
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trixie/sid

tests/test_distro.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,25 @@ def test_ubuntu14normal_lsb_release(self) -> None:
735735
}
736736
self._test_outcome(desired_outcome)
737737

738+
def test_debian13noosrelease_lsb_release(self) -> None:
739+
self._setup_for_distro(os.path.join(TESTDISTROS, "lsb", "debian13_noosrelease"))
740+
741+
self.distro = distro.LinuxDistribution(
742+
os_release_file="path-to-non-existing-file",
743+
distro_release_file="path-to-non-existing-file",
744+
)
745+
746+
desired_outcome = {
747+
"id": "debian",
748+
"name": "Debian",
749+
"pretty_name": "Debian GNU/Linux trixie/sid",
750+
"version": "trixie/sid",
751+
"pretty_version": "trixie/sid (trixie)",
752+
"best_version": "trixie/sid",
753+
"codename": "trixie",
754+
}
755+
self._test_outcome(desired_outcome)
756+
738757
def test_ubuntu14nomodules_lsb_release(self) -> None:
739758
self._setup_for_distro(os.path.join(TESTDISTROS, "lsb", "ubuntu14_nomodules"))
740759

@@ -1717,9 +1736,9 @@ def test_sles12_release(self) -> None:
17171736
"name": "SLES",
17181737
"pretty_name": "SUSE Linux Enterprise Server 12 SP1",
17191738
"version": "12.1",
1720-
"pretty_version": "12.1 (n/a)",
1739+
"pretty_version": "12.1 (s390x)",
17211740
"best_version": "12.1",
1722-
"codename": "n/a",
1741+
"codename": "s390x",
17231742
"major_version": "12",
17241743
"minor_version": "1",
17251744
}

0 commit comments

Comments
 (0)