Argentum v1.2.0 - Added checks for if packages are up-to-date before the user gets asked to continue with the update.

This commit is contained in:
TheWahlolly
2025-06-19 09:00:09 +03:00
parent a0724f7458
commit 235db61a01
3 changed files with 62 additions and 40 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ local agcfg = {
}, },
["argentum"] = { ["argentum"] = {
["maindir"] = "", ["maindir"] = "",
["version"] = "1.1.0", ["version"] = "1.2.0",
["description"] = "The default package manager for Halyde.", ["description"] = "The default package manager for Halyde.",
["directories"] = { ["directories"] = {
"argentum", "argentum",
+1 -1
View File
@@ -1,6 +1,6 @@
Aargentum/store/ Aargentum/store/
Aargentum/ Aargentum/
V1.1.0 V1.2.0
Aargentum/registry.cfg Aargentum/registry.cfg
Ahalyde/apps/argentum.lua Ahalyde/apps/argentum.lua
Ahalyde/apps/helpdb/argentum.txt Ahalyde/apps/helpdb/argentum.txt
+60 -38
View File
@@ -468,12 +468,40 @@ elseif command == "update" then
end end
end end
while true do 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 if not fs.exists("/argentum/store/" .. packages[i]) then
print("\27[91mPackage " .. packages[i] .. " is not installed.") print("\27[91mPackage " .. packages[i] .. " is not installed.")
table.insert(fails, packages[i]) table.insert(fails, packages[i])
table.remove(packageList, table.find(packageList, packages[i])) table.remove(packageList, table.find(packageList, packages[i]))
table.remove(packages, table.find(packages, packages[i])) table.remove(packages, table.find(packages, packages[i]))
i = i - 1 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 end
i = i + 1 i = i + 1
if i > #packages then if i > #packages then
@@ -481,14 +509,19 @@ elseif command == "update" then
end end
end end
local answer 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, ", ")) print("Packages that will be updated: " .. table.concat(packageList, ", "))
if read(nil, "Would you like to proceed? [Y/n] "):lower() == "n" then if read(nil, "Would you like to proceed? [Y/n] "):lower() == "n" then
return return
end end
elseif #packageList == 0 then
print("None of the packages can be updated.")
return
else else
print("Some packages cannot be updated.") print("Some packages cannot be updated.")
print("Packages that will be updated: " .. table.concat(packageList, ", ")) print("Packages that will be updated: " .. table.concat(packageList, ", "))
@@ -502,40 +535,29 @@ elseif command == "update" then
end end
fails = {} fails = {}
for _, package in pairs(packages) do for _, package in pairs(packages) do
local agcfg = getAgConfig(package, source) -- Previous up-to-date check
if not agcfg then
return false --local agcfg = getAgConfig(package, source)
end --if not agcfg then
local handle, data, tmpdata = fs.open("/argentum/store/" .. package .. "/package.cfg", "r"), "", nil -- return false
repeat --end
tmpdata = handle:read(math.huge) --local handle, data, tmpdata = fs.open("/argentum/store/" .. package .. "/package.cfg", "r"), "", nil
data = data .. (tmpdata or "") --repeat
until not tmpdata -- tmpdata = handle:read(math.huge)
handle:close() -- data = data .. (tmpdata or "")
local version = "0.0.0" --until not tmpdata
for line in (data.."\n"):gmatch("(.-)\n") do --handle:close()
if line:sub(1, 1) == "V" then --local version = "0.0.0"
version = line:sub(2) --for line in (data.."\n"):gmatch("(.-)\n") do
break -- if line:sub(1, 1) == "V" then
end -- version = line:sub(2)
end -- break
local handle, data, tmpdata = fs.open("/argentum/store/" .. package .. "/package.cfg", "r"), "", nil -- end
repeat --end
tmpdata = handle:read(math.huge) --if agcfg[package].version == version then
data = data .. (tmpdata or "") -- print(package .. " is up to date")
until not tmpdata -- goto skip
handle:close() --end
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 if not updatePackage(package) then
table.insert(fails, packages[i]) table.insert(fails, packages[i])
table.remove(packageList, table.find(packageList, packages[i])) table.remove(packageList, table.find(packageList, packages[i]))