From 235db61a013d55f58e4087c604f565fe67047dab Mon Sep 17 00:00:00 2001 From: TheWahlolly Date: Thu, 19 Jun 2025 09:00:09 +0300 Subject: [PATCH] Argentum v1.2.0 - Added checks for if packages are up-to-date before the user gets asked to continue with the update. --- argentum.cfg | 2 +- argentum/store/argentum/package.cfg | 2 +- halyde/apps/argentum.lua | 98 ++++++++++++++++++----------- 3 files changed, 62 insertions(+), 40 deletions(-) diff --git a/argentum.cfg b/argentum.cfg index b048e38..5086a60 100644 --- a/argentum.cfg +++ b/argentum.cfg @@ -60,7 +60,7 @@ local agcfg = { }, ["argentum"] = { ["maindir"] = "", - ["version"] = "1.1.0", + ["version"] = "1.2.0", ["description"] = "The default package manager for Halyde.", ["directories"] = { "argentum", diff --git a/argentum/store/argentum/package.cfg b/argentum/store/argentum/package.cfg index 0693bfe..62b884b 100644 --- a/argentum/store/argentum/package.cfg +++ b/argentum/store/argentum/package.cfg @@ -1,6 +1,6 @@ Aargentum/store/ Aargentum/ -V1.1.0 +V1.2.0 Aargentum/registry.cfg Ahalyde/apps/argentum.lua Ahalyde/apps/helpdb/argentum.txt diff --git a/halyde/apps/argentum.lua b/halyde/apps/argentum.lua index 3759b46..b5d1723 100644 --- a/halyde/apps/argentum.lua +++ b/halyde/apps/argentum.lua @@ -468,12 +468,40 @@ elseif command == "update" then end end while true do + local nonexistent = false -- I couldn't figure out a better way to do this, so I have to use a flag if the package doesn't exist if not fs.exists("/argentum/store/" .. packages[i]) then print("\27[91mPackage " .. packages[i] .. " is not installed.") table.insert(fails, packages[i]) table.remove(packageList, table.find(packageList, packages[i])) table.remove(packages, table.find(packages, packages[i])) i = i - 1 + nonexistent = true + end + if not nonexistent then + -- Check if up to date + local agcfg = getAgConfig(packages[i], source) + if not agcfg then + return false + end + local handle, data, tmpdata = fs.open("/argentum/store/" .. packages[i] .. "/package.cfg", "r"), "", nil + repeat + tmpdata = handle:read(math.huge) + data = data .. (tmpdata or "") + until not tmpdata + handle:close() + local version = "0.0.0" + for line in (data.."\n"):gmatch("(.-)\n") do + if line:sub(1, 1) == "V" then + version = line:sub(2) + break + end + end + if agcfg[packages[i]].version == version then + print(packages[i] .. " is up to date") + table.remove(packageList, table.find(packageList, packages[i])) + table.remove(packages, table.find(packages, packages[i])) + i = i - 1 + end end i = i + 1 if i > #packages then @@ -481,14 +509,19 @@ elseif command == "update" then end end local answer - if #fails == 0 then + if #packageList == 0 then + if #fails == 0 then + print("All packages are up to date.") + return + else + print("None of the packages can be updated.") + return + end + elseif #fails == 0 then print("Packages that will be updated: " .. table.concat(packageList, ", ")) if read(nil, "Would you like to proceed? [Y/n] "):lower() == "n" then return end - elseif #packageList == 0 then - print("None of the packages can be updated.") - return else print("Some packages cannot be updated.") print("Packages that will be updated: " .. table.concat(packageList, ", ")) @@ -502,40 +535,29 @@ elseif command == "update" then end fails = {} for _, package in pairs(packages) do - local agcfg = getAgConfig(package, source) - if not agcfg then - return false - end - local handle, data, tmpdata = fs.open("/argentum/store/" .. package .. "/package.cfg", "r"), "", nil - repeat - tmpdata = handle:read(math.huge) - data = data .. (tmpdata or "") - until not tmpdata - handle:close() - local version = "0.0.0" - for line in (data.."\n"):gmatch("(.-)\n") do - if line:sub(1, 1) == "V" then - version = line:sub(2) - break - end - end - local handle, data, tmpdata = fs.open("/argentum/store/" .. package .. "/package.cfg", "r"), "", nil - repeat - tmpdata = handle:read(math.huge) - data = data .. (tmpdata or "") - until not tmpdata - handle:close() - local version = "0.0.0" - for line in (data.."\n"):gmatch("(.-)\n") do - if line:sub(1, 1) == "V" then - version = line:sub(2) - break - end - end - if agcfg[package].version == version then - print(package .. " is up to date") - goto skip - end + -- Previous up-to-date check + + --local agcfg = getAgConfig(package, source) + --if not agcfg then + -- return false + --end + --local handle, data, tmpdata = fs.open("/argentum/store/" .. package .. "/package.cfg", "r"), "", nil + --repeat + -- tmpdata = handle:read(math.huge) + -- data = data .. (tmpdata or "") + --until not tmpdata + --handle:close() + --local version = "0.0.0" + --for line in (data.."\n"):gmatch("(.-)\n") do + -- if line:sub(1, 1) == "V" then + -- version = line:sub(2) + -- break + -- end + --end + --if agcfg[package].version == version then + -- print(package .. " is up to date") + -- goto skip + --end if not updatePackage(package) then table.insert(fails, packages[i]) table.remove(packageList, table.find(packageList, packages[i]))