diff --git a/lua/poe1/UpdateCheck.lua b/lua/poe1/UpdateCheck.lua deleted file mode 100644 index e678bc8..0000000 --- a/lua/poe1/UpdateCheck.lua +++ /dev/null @@ -1,301 +0,0 @@ -#@ --- Path of Building --- --- Module: Update Check --- Checks for updates --- -local connectionProtocol, proxyURL = ... - -local xml = require("xml") -local sha1 = require("sha1") -local curl = require("lcurl.safe") -local lzip = require("lzip") - -local globalRetryLimit = 10 -local function downloadFileText(source, file) - for i = 1, 5 do - if i > 1 then - ConPrintf("Retrying... (%d of 5)", i) - end - local text = "" - local easy = curl.easy() - local escapedUrl = source..easy:escape(file) - easy:setopt_url(escapedUrl) - easy:setopt(curl.OPT_ACCEPT_ENCODING, "") - if connectionProtocol then - easy:setopt(curl.OPT_IPRESOLVE, connectionProtocol) - end - if proxyURL then - easy:setopt(curl.OPT_PROXY, proxyURL) - end - easy:setopt_writefunction(function(data) - text = text..data - return true - end) - local _, error = easy:perform() - easy:close() - if not error then - return text - end - ConPrintf("Download failed (%s)", error:msg()) - if globalRetryLimit == 0 or i == 5 then - return nil, error:msg() - end - globalRetryLimit = globalRetryLimit - 1 - end -end -local function downloadFile(source, file, outName) - for i = 1, 5 do - if i > 1 then - ConPrintf("Retrying... (%d of 5)", i) - end - local easy = curl.easy() - local escapedUrl = source..easy:escape(file) - easy:setopt_url(escapedUrl) - easy:setopt(curl.OPT_ACCEPT_ENCODING, "") - if connectionProtocol then - easy:setopt(curl.OPT_IPRESOLVE, connectionProtocol) - end - if proxyURL then - easy:setopt(curl.OPT_PROXY, proxyURL) - end - local file = io.open(outName, "wb+") - easy:setopt_writefunction(file) - local _, error = easy:perform() - easy:close() - file:close() - if not error then - return true - end - ConPrintf("Download failed (%s)", error:msg()) - if globalRetryLimit == 0 or i == 5 then - return nil, error:msg() - end - globalRetryLimit = globalRetryLimit - 1 - end - return true -end - -ConPrintf("Checking for update...") - --- Use built-in helpers to obtain absolute paths without spawning a shell. -local scriptPath = (GetScriptPath and GetScriptPath()) or "." -local runtimePath = (GetRuntimePath and GetRuntimePath()) or scriptPath - --- Load and process local manifest -local localVer -local localPlatform, localBranch -local localFiles = { } -local localManXML = xml.LoadXMLFile(scriptPath.."/manifest.xml") -local localSource -if localManXML and localManXML[1].elem == "PoBVersion" then - for _, node in ipairs(localManXML[1]) do - if type(node) == "table" then - if node.elem == "Version" then - localVer = node.attrib.number - localPlatform = node.attrib.platform - localBranch = node.attrib.branch - elseif node.elem == "Source" then - if node.attrib.part == "default" then - localSource = node.attrib.url - end - elseif node.elem == "File" then - local fullPath - node.attrib.name = node.attrib.name:gsub("{space}", " ") - fullPath = scriptPath .. "/" .. node.attrib.name - localFiles[node.attrib.name] = { sha1 = node.attrib.sha1, part = node.attrib.part, platform = node.attrib.platform, fullPath = fullPath } - end - end - end -end -if not localVer or not localSource or not localBranch or not next(localFiles) then - ConPrintf("Update check failed: invalid local manifest") - return nil, "Invalid local manifest" -end -localSource = localSource:gsub("{branch}", localBranch) - --- Download and process remote manifest -local remoteVer -local remoteFiles = { } -local remoteSources = { } -local remoteManText, errMsg = downloadFileText(localSource, "manifest.xml") -if not remoteManText then - ConPrintf("Update check failed: couldn't download version manifest") - return nil, "Couldn't download version manifest.\nReason: "..errMsg.."\nCheck your internet connectivity.\nIf you are using a proxy, specify it in Options." -end -local remoteManXML = xml.ParseXML(remoteManText) -if remoteManXML and remoteManXML[1].elem == "PoBVersion" then - for _, node in ipairs(remoteManXML[1]) do - if type(node) == "table" then - if node.elem == "Version" then - remoteVer = node.attrib.number - elseif node.elem == "Source" then - if not remoteSources[node.attrib.part] then - remoteSources[node.attrib.part] = { } - end - remoteSources[node.attrib.part][node.attrib.platform or "any"] = node.attrib.url - elseif node.elem == "File" then - if not node.attrib.platform or node.attrib.platform == localPlatform then - local fullPath - fullPath = scriptPath .. "/" .. node.attrib.name - remoteFiles[node.attrib.name] = { sha1 = node.attrib.sha1, part = node.attrib.part, platform = node.attrib.platform, fullPath = fullPath } - end - end - end - end -end -if not remoteVer or not next(remoteSources) or not next(remoteFiles) then - ConPrintf("Update check failed: invalid remote manifest") - return nil, "Invalid remote manifest" -end - --- Build lists of files to be updated or deleted -local updateFiles = { } -for name, data in pairs(remoteFiles) do - data.name = name - local sanitizedName = name:gsub("{space}", " ") - if (not localFiles[name] or localFiles[name].sha1 ~= data.sha1) and (not localFiles[sanitizedName] or localFiles[sanitizedName].sha1 ~= data.sha1) then - table.insert(updateFiles, data) - elseif localFiles[name] then - local file = io.open(localFiles[name].fullPath, "rb") - if not file then - ConPrintf("Warning: '%s' doesn't exist, it will be re-downloaded", data.name) - table.insert(updateFiles, data) - else - local content = file:read("*a") - file:close() - if data.sha1 ~= sha1(content) and data.sha1 ~= sha1(content:gsub("\n", "\r\n")) then - ConPrintf("Warning: Integrity check on '%s' failed, it will be replaced", data.name) - table.insert(updateFiles, data) - end - end - end -end -local deleteFiles = { } -for name, data in pairs(localFiles) do - data.name = name - local unSanitizedName = name:gsub(" ", "{space}") - if not remoteFiles[name] and not remoteFiles[unSanitizedName] then - table.insert(deleteFiles, data) - end -end - -if #updateFiles == 0 and #deleteFiles == 0 then - ConPrintf("No update available.") - return "none" -end - -MakeDir("Update") -ConPrintf("Downloading update...") - --- Download changelog -downloadFile(localSource, "changelog.txt", scriptPath.."/changelog.txt") - --- Download files that need updating -local failedFile = false -local zipFiles = { } -for index, data in ipairs(updateFiles) do - if UpdateProgress then - UpdateProgress("Downloading %d/%d", index, #updateFiles) - end - local partSources = remoteSources[data.part] - local source = partSources[localPlatform] or partSources["any"] - source = source:gsub("{branch}", localBranch) - local fileName = scriptPath.."/Update/"..data.name:gsub("[\\/]","{slash}") - data.updateFileName = fileName - local zipName = source:match("/([^/]+%.zip)$") - if zipName then - if not zipFiles[zipName] then - ConPrintf("Downloading %s...", zipName) - local zipFileName = scriptPath.."/Update/"..zipName - downloadFile(source, "", zipFileName) - zipFiles[zipName] = lzip.open(zipFileName) - end - local zip = zipFiles[zipName] - if zip then - local zippedFile = zip:OpenFile(data.name) - if zippedFile then - local file = io.open(fileName, "wb+") - file:write(zippedFile:Read("*a")) - file:close() - zippedFile:Close() - else - ConPrintf("Couldn't extract '%s' from '%s' (extract failed)", data.name, zipName) - end - else - ConPrintf("Couldn't extract '%s' from '%s' (zip open failed)", data.name, zipName) - end - else - local skipDownload - local file = io.open(fileName, "rb") - if file then - local content = file:read("*all") - if data.sha1 == sha1(content) or data.sha1 == sha1(content:gsub("\n", "\r\n")) then - ConPrintf("Using file from previous update attempt '%s'", fileName) - skipDownload = true - end - file:close() - end - if not skipDownload then - ConPrintf("Downloading %s... (%d of %d)", data.name, index, #updateFiles) - downloadFile(source, data.name, fileName) - end - end - local file = io.open(fileName, "rb") - if not file then - failedFile = true - else - local content = file:read("*all") - if data.sha1 ~= sha1(content) and data.sha1 ~= sha1(content:gsub("\n", "\r\n")) then - ConPrintf("Hash mismatch on '%s'", fileName) - failedFile = true - end - file:close() - end -end -for name, zip in pairs(zipFiles) do - zip:Close() - os.remove(scriptPath.."/Update/"..name) -end -if failedFile then - ConPrintf("Update failed: one or more files couldn't be downloaded") - return nil, "One or more files couldn't be downloaded.\nCheck your internet connectivity,\nor try again later." -end - --- Create new manifest -localManXML = { elem = "PoBVersion" } -table.insert(localManXML, { elem = "Version", attrib = { number = remoteVer, platform = localPlatform, branch = localBranch } }) -for part, platforms in pairs(remoteSources) do - for platform, url in pairs(platforms) do - table.insert(localManXML, { elem = "Source", attrib = { part = part, platform = platform ~= "any" and platform, url = url } }) - end -end -for name, data in pairs(remoteFiles) do - table.insert(localManXML, { elem = "File", attrib = { name = data.name, sha1 = data.sha1, part = data.part, platform = data.platform } }) -end -xml.SaveXMLFile(localManXML, scriptPath.."/Update/manifest.xml") - --- Build list of operations to apply the update -local updateMode = "normal" -local ops = { } -for _, data in pairs(updateFiles) do - -- Ensure that the destination path of this file exists - local dirStr = "" - for dir in data.fullPath:gmatch("([^/]*/)") do - dirStr = dirStr .. dir - MakeDir(dirStr) - end - table.insert(ops, 'move "'..data.updateFileName..'" "'..data.fullPath..'"') -end -for _, data in pairs(deleteFiles) do - table.insert(ops, 'delete "'..data.fullPath..'"') -end -table.insert(ops, 'move "'..scriptPath..'/Update/manifest.xml" "'..scriptPath..'/manifest.xml"') - --- Write operations file -local opFile = io.open(scriptPath.."/Update/opFile.txt", "w+") -opFile:write(table.concat(ops, "\n")) -opFile:close() - -ConPrintf("Update is ready.") -return updateMode diff --git a/lua/poe1/manifest.xml b/lua/poe1/manifest.xml deleted file mode 100644 index 98c60dc..0000000 --- a/lua/poe1/manifest.xml +++ /dev/null @@ -1,843 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lua/poe2/UpdateCheck.lua b/lua/poe2/UpdateCheck.lua deleted file mode 100644 index e678bc8..0000000 --- a/lua/poe2/UpdateCheck.lua +++ /dev/null @@ -1,301 +0,0 @@ -#@ --- Path of Building --- --- Module: Update Check --- Checks for updates --- -local connectionProtocol, proxyURL = ... - -local xml = require("xml") -local sha1 = require("sha1") -local curl = require("lcurl.safe") -local lzip = require("lzip") - -local globalRetryLimit = 10 -local function downloadFileText(source, file) - for i = 1, 5 do - if i > 1 then - ConPrintf("Retrying... (%d of 5)", i) - end - local text = "" - local easy = curl.easy() - local escapedUrl = source..easy:escape(file) - easy:setopt_url(escapedUrl) - easy:setopt(curl.OPT_ACCEPT_ENCODING, "") - if connectionProtocol then - easy:setopt(curl.OPT_IPRESOLVE, connectionProtocol) - end - if proxyURL then - easy:setopt(curl.OPT_PROXY, proxyURL) - end - easy:setopt_writefunction(function(data) - text = text..data - return true - end) - local _, error = easy:perform() - easy:close() - if not error then - return text - end - ConPrintf("Download failed (%s)", error:msg()) - if globalRetryLimit == 0 or i == 5 then - return nil, error:msg() - end - globalRetryLimit = globalRetryLimit - 1 - end -end -local function downloadFile(source, file, outName) - for i = 1, 5 do - if i > 1 then - ConPrintf("Retrying... (%d of 5)", i) - end - local easy = curl.easy() - local escapedUrl = source..easy:escape(file) - easy:setopt_url(escapedUrl) - easy:setopt(curl.OPT_ACCEPT_ENCODING, "") - if connectionProtocol then - easy:setopt(curl.OPT_IPRESOLVE, connectionProtocol) - end - if proxyURL then - easy:setopt(curl.OPT_PROXY, proxyURL) - end - local file = io.open(outName, "wb+") - easy:setopt_writefunction(file) - local _, error = easy:perform() - easy:close() - file:close() - if not error then - return true - end - ConPrintf("Download failed (%s)", error:msg()) - if globalRetryLimit == 0 or i == 5 then - return nil, error:msg() - end - globalRetryLimit = globalRetryLimit - 1 - end - return true -end - -ConPrintf("Checking for update...") - --- Use built-in helpers to obtain absolute paths without spawning a shell. -local scriptPath = (GetScriptPath and GetScriptPath()) or "." -local runtimePath = (GetRuntimePath and GetRuntimePath()) or scriptPath - --- Load and process local manifest -local localVer -local localPlatform, localBranch -local localFiles = { } -local localManXML = xml.LoadXMLFile(scriptPath.."/manifest.xml") -local localSource -if localManXML and localManXML[1].elem == "PoBVersion" then - for _, node in ipairs(localManXML[1]) do - if type(node) == "table" then - if node.elem == "Version" then - localVer = node.attrib.number - localPlatform = node.attrib.platform - localBranch = node.attrib.branch - elseif node.elem == "Source" then - if node.attrib.part == "default" then - localSource = node.attrib.url - end - elseif node.elem == "File" then - local fullPath - node.attrib.name = node.attrib.name:gsub("{space}", " ") - fullPath = scriptPath .. "/" .. node.attrib.name - localFiles[node.attrib.name] = { sha1 = node.attrib.sha1, part = node.attrib.part, platform = node.attrib.platform, fullPath = fullPath } - end - end - end -end -if not localVer or not localSource or not localBranch or not next(localFiles) then - ConPrintf("Update check failed: invalid local manifest") - return nil, "Invalid local manifest" -end -localSource = localSource:gsub("{branch}", localBranch) - --- Download and process remote manifest -local remoteVer -local remoteFiles = { } -local remoteSources = { } -local remoteManText, errMsg = downloadFileText(localSource, "manifest.xml") -if not remoteManText then - ConPrintf("Update check failed: couldn't download version manifest") - return nil, "Couldn't download version manifest.\nReason: "..errMsg.."\nCheck your internet connectivity.\nIf you are using a proxy, specify it in Options." -end -local remoteManXML = xml.ParseXML(remoteManText) -if remoteManXML and remoteManXML[1].elem == "PoBVersion" then - for _, node in ipairs(remoteManXML[1]) do - if type(node) == "table" then - if node.elem == "Version" then - remoteVer = node.attrib.number - elseif node.elem == "Source" then - if not remoteSources[node.attrib.part] then - remoteSources[node.attrib.part] = { } - end - remoteSources[node.attrib.part][node.attrib.platform or "any"] = node.attrib.url - elseif node.elem == "File" then - if not node.attrib.platform or node.attrib.platform == localPlatform then - local fullPath - fullPath = scriptPath .. "/" .. node.attrib.name - remoteFiles[node.attrib.name] = { sha1 = node.attrib.sha1, part = node.attrib.part, platform = node.attrib.platform, fullPath = fullPath } - end - end - end - end -end -if not remoteVer or not next(remoteSources) or not next(remoteFiles) then - ConPrintf("Update check failed: invalid remote manifest") - return nil, "Invalid remote manifest" -end - --- Build lists of files to be updated or deleted -local updateFiles = { } -for name, data in pairs(remoteFiles) do - data.name = name - local sanitizedName = name:gsub("{space}", " ") - if (not localFiles[name] or localFiles[name].sha1 ~= data.sha1) and (not localFiles[sanitizedName] or localFiles[sanitizedName].sha1 ~= data.sha1) then - table.insert(updateFiles, data) - elseif localFiles[name] then - local file = io.open(localFiles[name].fullPath, "rb") - if not file then - ConPrintf("Warning: '%s' doesn't exist, it will be re-downloaded", data.name) - table.insert(updateFiles, data) - else - local content = file:read("*a") - file:close() - if data.sha1 ~= sha1(content) and data.sha1 ~= sha1(content:gsub("\n", "\r\n")) then - ConPrintf("Warning: Integrity check on '%s' failed, it will be replaced", data.name) - table.insert(updateFiles, data) - end - end - end -end -local deleteFiles = { } -for name, data in pairs(localFiles) do - data.name = name - local unSanitizedName = name:gsub(" ", "{space}") - if not remoteFiles[name] and not remoteFiles[unSanitizedName] then - table.insert(deleteFiles, data) - end -end - -if #updateFiles == 0 and #deleteFiles == 0 then - ConPrintf("No update available.") - return "none" -end - -MakeDir("Update") -ConPrintf("Downloading update...") - --- Download changelog -downloadFile(localSource, "changelog.txt", scriptPath.."/changelog.txt") - --- Download files that need updating -local failedFile = false -local zipFiles = { } -for index, data in ipairs(updateFiles) do - if UpdateProgress then - UpdateProgress("Downloading %d/%d", index, #updateFiles) - end - local partSources = remoteSources[data.part] - local source = partSources[localPlatform] or partSources["any"] - source = source:gsub("{branch}", localBranch) - local fileName = scriptPath.."/Update/"..data.name:gsub("[\\/]","{slash}") - data.updateFileName = fileName - local zipName = source:match("/([^/]+%.zip)$") - if zipName then - if not zipFiles[zipName] then - ConPrintf("Downloading %s...", zipName) - local zipFileName = scriptPath.."/Update/"..zipName - downloadFile(source, "", zipFileName) - zipFiles[zipName] = lzip.open(zipFileName) - end - local zip = zipFiles[zipName] - if zip then - local zippedFile = zip:OpenFile(data.name) - if zippedFile then - local file = io.open(fileName, "wb+") - file:write(zippedFile:Read("*a")) - file:close() - zippedFile:Close() - else - ConPrintf("Couldn't extract '%s' from '%s' (extract failed)", data.name, zipName) - end - else - ConPrintf("Couldn't extract '%s' from '%s' (zip open failed)", data.name, zipName) - end - else - local skipDownload - local file = io.open(fileName, "rb") - if file then - local content = file:read("*all") - if data.sha1 == sha1(content) or data.sha1 == sha1(content:gsub("\n", "\r\n")) then - ConPrintf("Using file from previous update attempt '%s'", fileName) - skipDownload = true - end - file:close() - end - if not skipDownload then - ConPrintf("Downloading %s... (%d of %d)", data.name, index, #updateFiles) - downloadFile(source, data.name, fileName) - end - end - local file = io.open(fileName, "rb") - if not file then - failedFile = true - else - local content = file:read("*all") - if data.sha1 ~= sha1(content) and data.sha1 ~= sha1(content:gsub("\n", "\r\n")) then - ConPrintf("Hash mismatch on '%s'", fileName) - failedFile = true - end - file:close() - end -end -for name, zip in pairs(zipFiles) do - zip:Close() - os.remove(scriptPath.."/Update/"..name) -end -if failedFile then - ConPrintf("Update failed: one or more files couldn't be downloaded") - return nil, "One or more files couldn't be downloaded.\nCheck your internet connectivity,\nor try again later." -end - --- Create new manifest -localManXML = { elem = "PoBVersion" } -table.insert(localManXML, { elem = "Version", attrib = { number = remoteVer, platform = localPlatform, branch = localBranch } }) -for part, platforms in pairs(remoteSources) do - for platform, url in pairs(platforms) do - table.insert(localManXML, { elem = "Source", attrib = { part = part, platform = platform ~= "any" and platform, url = url } }) - end -end -for name, data in pairs(remoteFiles) do - table.insert(localManXML, { elem = "File", attrib = { name = data.name, sha1 = data.sha1, part = data.part, platform = data.platform } }) -end -xml.SaveXMLFile(localManXML, scriptPath.."/Update/manifest.xml") - --- Build list of operations to apply the update -local updateMode = "normal" -local ops = { } -for _, data in pairs(updateFiles) do - -- Ensure that the destination path of this file exists - local dirStr = "" - for dir in data.fullPath:gmatch("([^/]*/)") do - dirStr = dirStr .. dir - MakeDir(dirStr) - end - table.insert(ops, 'move "'..data.updateFileName..'" "'..data.fullPath..'"') -end -for _, data in pairs(deleteFiles) do - table.insert(ops, 'delete "'..data.fullPath..'"') -end -table.insert(ops, 'move "'..scriptPath..'/Update/manifest.xml" "'..scriptPath..'/manifest.xml"') - --- Write operations file -local opFile = io.open(scriptPath.."/Update/opFile.txt", "w+") -opFile:write(table.concat(ops, "\n")) -opFile:close() - -ConPrintf("Update is ready.") -return updateMode diff --git a/lua/poe2/manifest.xml b/lua/poe2/manifest.xml deleted file mode 100644 index 2ebbc8f..0000000 --- a/lua/poe2/manifest.xml +++ /dev/null @@ -1,934 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lua/update_manifest.py b/lua/update_manifest.py deleted file mode 100644 index c334cbc..0000000 --- a/lua/update_manifest.py +++ /dev/null @@ -1,83 +0,0 @@ -import argparse -import hashlib -import urllib.request -import xml.etree.ElementTree as Et -from pathlib import Path - -# Downloads the official PoB manifest file and performs the following modifications: -# - set platform and branch -# - add a new 'default' source that points to this repo -# - rename old 'default' source to 'origin' -# - remove win32 libraries and executables -# - remove font files -# - use modified UpdateCheck.lua from this repo, which is compatible with unix paths and disables the 'basic' update mode - -repo = "meehl/rusty-path-of-building" - - -def is_font_file(name: str) -> bool: - return name.endswith(".tga") or name.endswith(".tgf") - - -def is_tar_file(name: str) -> bool: - return name.endswith(".tar") or name.endswith(".tgf") - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument("--game", choices=["poe1", "poe2"], required=True) - args = parser.parse_args() - - if args.game == "poe1": - origin_url = "https://raw.githubusercontent.com/PathOfBuildingCommunity/PathOfBuilding/master/manifest.xml" - else: - origin_url = "https://raw.githubusercontent.com/PathOfBuildingCommunity/PathOfBuilding-PoE2/master/manifest.xml" - - with urllib.request.urlopen(origin_url) as f: - manifest_root = Et.fromstring(f.read().decode("utf-8")) - - for child in list(manifest_root): - if child.tag == "Version": - child.set("branch", "master") - child.set("platform", "any") - elif child.tag == "Source": - if child.get("part") == "default": - child.set("part", "origin") - - if child.get("platform") is not None: - child.attrib.pop("platform") - elif child.tag == "File": - if child.get("part") == "default": - child.set("part", "origin") - - if ( - child.get("runtime") is not None - or is_font_file(child.get("name")) - or is_tar_file(child.get("name")) - ): - manifest_root.remove(child) - - if child.get("name") == "UpdateCheck.lua": - child.set("part", "default") - - path = Path(f"./{args.game}/UpdateCheck.lua") - data = path.read_bytes() - sha1 = hashlib.sha1(data).hexdigest() - child.set("sha1", sha1) - - default_source = Et.Element( - "Source", - { - "part": "default", - "url": f"https://raw.githubusercontent.com/{repo}/main/lua/{args.game}/", - }, - ) - manifest_root.insert(1, default_source) - - tree = Et.ElementTree(manifest_root) - Et.indent(tree, "\t") - tree.write(f"./{args.game}/manifest.xml") - - -if __name__ == "__main__": - main() diff --git a/src/installer.rs b/src/installer.rs index 70cf0d5..651d8f0 100644 --- a/src/installer.rs +++ b/src/installer.rs @@ -7,7 +7,7 @@ use std::{ path::{Path, PathBuf}, }; -const REPO_NAME: &str = "meehl/rusty-path-of-building"; +const REPO_NAME: &str = "meehl/rusty-pob-manifest"; pub fn run_installer() -> anyhow::Result<()> { let script_dir = Game::script_dir(); @@ -96,8 +96,8 @@ fn replace_manifest>(target_dir: P) -> anyhow::Result<()> { log::info!("Replacing manifest..."); let game_path = match Game::current() { - Game::Poe1 => "lua/poe1", - Game::Poe2 => "lua/poe2", + Game::Poe1 => "poe1", + Game::Poe2 => "poe2", }; // Download on overwrite files