Skip to content

Commit

Permalink
check release info based on arch
Browse files Browse the repository at this point in the history
  • Loading branch information
fuji246 committed Oct 9, 2022
1 parent ad50533 commit 50f0829
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion LomoAgent/LomoUpgrade.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,13 @@ class LomoUpgrade {
if httpresp.statusCode == 200, let jsonResult = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {
DDLogInfo("needUpdateLomoupgAndLomoAgent, json response: \(jsonResult!)")

if let osxConf = jsonResult?["darwin"] as? [String: Any] {
let hardwareType = GetMachineHardwareName()
var configName = "darwin"
if hardwareType == "arm64" {
configName += "-m1"
}

if let osxConf = jsonResult?[configName] as? [String: Any] {

guard let agentSha256 = osxConf["SHA256"] as? String,
let agentVer = osxConf["Version"] as? String,
Expand Down
9 changes: 9 additions & 0 deletions LomoAgent/utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,12 @@ func isPortOpen(port: in_port_t) -> Bool {
Darwin.close(socketFileDescriptor)
return isOpen
}

func GetMachineHardwareName() -> String? {
var sysInfo = utsname()
let retVal = uname(&sysInfo)

guard retVal == EXIT_SUCCESS else { return nil }

return String(cString: &sysInfo.machine.0, encoding: .utf8)
}

0 comments on commit 50f0829

Please sign in to comment.