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:
+1
-1
@@ -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,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
|
||||||
|
|||||||
+59
-37
@@ -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 #packageList == 0 then
|
||||||
if #fails == 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]))
|
||||||
|
|||||||
Reference in New Issue
Block a user