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

Closed
wants to merge 2 commits into from
Closed
Changes from all 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
31 changes: 23 additions & 8 deletions xmake/core/base/linuxos.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

for _, line in ipairs(os_release_lines) do
-- ubuntu: VERSION="16.04.7 LTS (Xenial Xerus)"
-- fedora: VERSION="32 (Container Image)"
-- debian: VERSION="9 (stretch)"
-- kylin : VERSION="V10(kylin)"
if line:find("version=") then
line = line:sub(9)
version = semver.match(line)
Expand All @@ -158,11 +157,27 @@ function linuxos.version()
version = semver.new(version .. ".0")
end
end
-- is kylin?
if not version and line:find("kylin", 1, true) then
version = line:match("\"v(%d+)%(kylin%)\"")
if version then
break
end
end

-- get kylin version from VERSION_ID
--
-- kylin case 1:
-- VERSION="v10(kylin)"
-- VERSION_ID="V10"
--
-- 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('"')

if version then
version = semver.new(version .. ".0")
version = semver.new(version)
end
end
if version then
Expand All @@ -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

for _, line in ipairs(lsb_release:split("\n")) do
-- release: 16.04
if line:find("release:") then
Expand Down
Loading