1
0
mirror of https://github.com/AR2000AR/openComputers_codes.git synced 2025-09-04 12:45:58 +02:00

[pm-get] update pm/pm--get with fixes made while porting it for CC

This commit is contained in:
2025-01-25 16:13:21 +01:00
parent 3bf19fb24b
commit 69918492dd
8 changed files with 29 additions and 32 deletions

View File

@@ -22,7 +22,7 @@
["pm_get"] = {
["manifestVersion"] = "1.0",
["package"] = "pm_get",
["version"] = "1.4.4",
["version"] = "1.4.5",
["name"] = "pm get",
["repo"] = "tree/master/pm_get",
["description"] = "Download and install package for pm",
@@ -148,7 +148,7 @@
["pm"] = {
["manifestVersion"] = "1.0",
["package"] = "pm",
["version"] = "1.2.6",
["version"] = "1.2.7",
["name"] = "pm Package Manager",
["repo"] = "tree/master/pm",
["description"] = "Package manager for OpenOS",

Binary file not shown.

Binary file not shown.

View File

@@ -77,6 +77,7 @@ function pm.getInstalled(includeNonPurged)
local prefix = "%.files$"
if (includeNonPurged) then prefix = "%.manifest$" end
local installed = {}
if (not filesystem.exists("/etc/pm/info")) then filesystem.makeDirectory("/etc/pm/info") end
for file in filesystem.list("/etc/pm/info/") do
local packageName = file:match("(.+)" .. prefix)
if (packageName) then

View File

@@ -1,7 +1,7 @@
{
["manifestVersion"] = "1.0",
["package"] = "pm",
["version"] = "1.2.6",
["version"] = "1.2.7",
["name"] = "pm Package Manager",
["repo"] = "tree/master/pm",
["description"] = "Package manager for OpenOS",

View File

@@ -225,6 +225,17 @@ local function markManual(package)
autoFile:close()
end
local function needUpgrade(pkg)
local remoteManifest = getCachedPackageManifest(pkg)
if not remoteManifest then return false end
local localManifest = pm.getManifestFromInstalled(pkg)
if not localManifest then return false end
if remoteManifest.version == "oppm" or localManifest == "oppm" then return true end
if compareVersion(remoteManifest.version, localManifest.version) > 0 then return true end
if compareVersion(remoteManifest.version, localManifest.version) == 0 and opts["allow-same-version"] then return true end
return false
end
--=============================================================================
---Install a package
@@ -302,9 +313,10 @@ local function install(packages, markAuto, buildDepTree)
local display = {}
for _, v in pairs(toInstall) do table.insert(display, v) end
for _, v in pairs(packages) do table.insert(display, v) end
printf("Will be installed :\n %s", table.concat(display, ', '))
if (#display > 0) then printf("Will be installed :\n %s", table.concat(display, ', ')) end
if (#toUpgrade > 0) then printf("Will be updated :\n %s", table.concat(toUpgrade, ', ')) end
printf("%d upgraded, %d newly installed", #toUpgrade, #toInstall + #packages)
printf("%d upgraded, %d newly installed", #toUpgrade, #display)
if (#display == 0 and #toUpgrade == 0) then return end
if not confirm("Proceed") then return end
if (not opts['dry-run']) then
@@ -360,22 +372,11 @@ local function update()
local repos = getSources()
local manifests = {}
for _, repoURL in pairs(repos) do
local request = internet.request(repoURL .. "/manifest")
local ready, reason
repeat
ready, reason = request.finishConnect()
until ready or reason
if (not ready) then
local data, reason = wget(repoURL .. "/manifest")
if (not data) then
printferr("Could not get manifest from %s\ns", repoURL, reason)
request.close()
else
printf("Found repository : %s", repoURL)
local data = ""
repeat
local read = request.read()
if (read) then data = data .. read end
until not read
request.close()
local pcalled
pcalled, data = pcall(serialization.unserialize, data)
if (pcalled == false) then
@@ -391,14 +392,9 @@ local function update()
local canBeUpgraded = 0
local remotePackages = getCachedPackageList()
local installedPackages = pm.getInstalled()
for pkgName, pkgManifest in pairs(installedPackages) do
for src, srcManifests in pairs(remotePackages) do
if (srcManifests[pkgName]) then
if (compareVersion(srcManifests[pkgName].version, pkgManifest.version)) then
canBeUpgraded = canBeUpgraded + 1
break --next package
end
end
for pkgName in pairs(installedPackages) do
if (needUpgrade(pkgName)) then
canBeUpgraded = canBeUpgraded + 1
end
end
printf("%s package(s) can be upgraded", canBeUpgraded)
@@ -537,13 +533,13 @@ elseif (mode == "upgrade") then
local manifest = assert(pm.getManifestFromInstalled(args[1]))
if (manifest.dependencies) then
for dep, ver in pairs(manifest.dependencies) do
local remoteManifest = getCachedPackageManifest(dep) --TODO : add target repo
local localManifest = pm.getManifestFromInstalled(dep)
if (remoteManifest and (remoteManifest.version == "oppm" or compareVersion(remoteManifest.version, localManifest.version) or opts["allow-same-version"])) then
if (needUpgrade(dep)) then
table.insert(toUpgrade, dep)
end
end
end
else
--TODO : pkg not installed
end
else
for pkg, manifest in pairs(installed) do

View File

@@ -1,7 +1,7 @@
{
["manifestVersion"] = "1.0",
["package"] = "pm_get",
["version"] = "1.4.4",
["version"] = "1.4.5",
["name"] = "pm get",
["repo"] = "tree/master/pm_get",
["description"] = "Download and install package for pm",

View File

@@ -21,7 +21,7 @@
}
},
["pm_get"] = {
version = "1.4.4",
version = "1.4.5",
name = "pm get",
repo = "tree/master/pm_get",
description = "Download and install package for pm",
@@ -152,7 +152,7 @@
}
},
["pm"] = {
version = "1.2.6",
version = "1.2.7",
name = "pm Package Manager",
repo = "tree/master/pm",
description = "Package manager for OpenOS",