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

improve kylin support for linuxos module #5873

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

jinke18
Copy link
Contributor

@jinke18 jinke18 commented Nov 23, 2024

i improve kylin support for linuxos module, making it more robust.

@@ -143,12 +143,11 @@ function linuxos.version()
if version == nil and os.isfile("/etc/os-release") then
local os_release = io.readfile("/etc/os-release")
if os_release then
os_release = os_release:trim():lower():split("\n")
for _, line in ipairs(os_release) do
os_release_lines = os_release:trim():lower():split("\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local os_release_lines

-- kylin case 2:
-- VERSION="4.0.2 (juniper)"
-- VERSION_ID="4.0.2"
if line:find("version_id=") and os_release:find("kylin", 1, true) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lowercase or uppercase? and please use line:startswith

line = line:sub(12)
version = semver.match(line)
if not version then
version = line:match("\"(.*)\"")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version = line:trim('"')

@@ -176,7 +191,7 @@ function linuxos.version()
-- get it from lsb release
if version == nil then
local lsb_release = linuxos._lsb_release()
if lsb_release and lsb_release:find("ubuntu", 1, true) then
if lsb_release and (lsb_release:find("ubuntu", 1, true) or lsb_release:find("kylin", 1, true)) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

) or two spaces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants