mirror of
https://github.com/AR2000AR/openComputers_codes.git
synced 2025-09-09 07:01:14 +02:00
[pm-get] allow same version update/install
This commit is contained in:
Binary file not shown.
@@ -16,12 +16,23 @@ local SOURCE_DIR = SOURCE_FILE .. ".d/"
|
|||||||
local REPO_MANIFEST_CACHE = CONFIG_DIR .. "manifests.cache"
|
local REPO_MANIFEST_CACHE = CONFIG_DIR .. "manifests.cache"
|
||||||
local AUTO_INSTALLED = CONFIG_DIR .. "autoInstalled"
|
local AUTO_INSTALLED = CONFIG_DIR .. "autoInstalled"
|
||||||
|
|
||||||
|
--=============================================================================
|
||||||
|
---@type table<string>,table<progOpts>
|
||||||
|
local args, opts = shell.parse(...)
|
||||||
|
local mode = table.remove(args, 1)
|
||||||
--=============================================================================
|
--=============================================================================
|
||||||
|
|
||||||
local reposRuntimeCache
|
local reposRuntimeCache
|
||||||
|
|
||||||
--=============================================================================
|
--=============================================================================
|
||||||
|
|
||||||
|
---@alias progOpts
|
||||||
|
---| 'autoremove'
|
||||||
|
---| 'purge'
|
||||||
|
---| 'allow-same-version'
|
||||||
|
|
||||||
|
|
||||||
|
--=============================================================================
|
||||||
|
|
||||||
local f = string.format
|
local f = string.format
|
||||||
|
|
||||||
@@ -223,7 +234,11 @@ local function install(package, markAuto, buildDepTree)
|
|||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
io.open(f("%s/%s", DOWNLOAD_DIR, targetManifest.archiveName), "w"):write(data):close()
|
io.open(f("%s/%s", DOWNLOAD_DIR, targetManifest.archiveName), "w"):write(data):close()
|
||||||
local _, code = shell.execute(f("pm install %s", f("%s/%s", DOWNLOAD_DIR, targetManifest.archiveName)))
|
local pmOptions = ""
|
||||||
|
if (opts["allow-same-version"]) then
|
||||||
|
pmOptions = "--allow-same-version"
|
||||||
|
end
|
||||||
|
local _, code = shell.execute(f("pm install %s %s", pmOptions, f("%s/%s", DOWNLOAD_DIR, targetManifest.archiveName)))
|
||||||
filesystem.remove(f("%s/%s", DOWNLOAD_DIR, targetManifest.archiveName))
|
filesystem.remove(f("%s/%s", DOWNLOAD_DIR, targetManifest.archiveName))
|
||||||
if (markAuto) then
|
if (markAuto) then
|
||||||
io.open(AUTO_INSTALLED, "a"):write(targetManifest.package):close()
|
io.open(AUTO_INSTALLED, "a"):write(targetManifest.package):close()
|
||||||
@@ -274,6 +289,7 @@ local function printHelp()
|
|||||||
printf("opts :")
|
printf("opts :")
|
||||||
printf("\t--autoremove : also remove dependencies non longer required")
|
printf("\t--autoremove : also remove dependencies non longer required")
|
||||||
printf("\t--purge : purge removed packages")
|
printf("\t--purge : purge removed packages")
|
||||||
|
printf("\t--allow-same-version : allow the same package version to be installed over the currently installed one")
|
||||||
end
|
end
|
||||||
|
|
||||||
--=============================================================================
|
--=============================================================================
|
||||||
@@ -284,6 +300,7 @@ else
|
|||||||
printferr("Need a internet card")
|
printferr("Need a internet card")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--Remove uninstalled files from autoInstalled file
|
||||||
if (filesystem.exists(AUTO_INSTALLED)) then
|
if (filesystem.exists(AUTO_INSTALLED)) then
|
||||||
do
|
do
|
||||||
local tokeep = {}
|
local tokeep = {}
|
||||||
@@ -296,9 +313,6 @@ if (filesystem.exists(AUTO_INSTALLED)) then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local args, opts = shell.parse(...)
|
|
||||||
local mode = table.remove(args, 1)
|
|
||||||
|
|
||||||
if (mode == "update") then
|
if (mode == "update") then
|
||||||
print("Updating repository cache")
|
print("Updating repository cache")
|
||||||
update()
|
update()
|
||||||
@@ -377,14 +391,29 @@ elseif (mode == "autoremove") then
|
|||||||
elseif (mode == "upgrade") then
|
elseif (mode == "upgrade") then
|
||||||
local installed = pm.getInstalled(false)
|
local installed = pm.getInstalled(false)
|
||||||
local toUpgrade = {}
|
local toUpgrade = {}
|
||||||
for pkg, manifest in pairs(installed) do
|
if (args[1]) then
|
||||||
if (manifest.version == "oppm") then
|
if (pm.isInstalled(args[1])) then
|
||||||
printf("Found oppm version for %q.", pkg)
|
table.insert(toUpgrade, args[1])
|
||||||
table.insert(toUpgrade, pkg)
|
local manifest = assert(pm.getManifestFromInstalled(args[1]))
|
||||||
else
|
if (manifest.dependencies) then
|
||||||
local remoteManifest = getPacket(pkg)
|
for dep, ver in pairs(manifest.dependencies) do
|
||||||
if (remoteManifest and (remoteManifest.version == "oppm" or compareVersion(remoteManifest.version, manifest.version))) then
|
local remoteManifest = getPacket(dep) --TODO : add target repo
|
||||||
|
if (remoteManifest and (remoteManifest.version == "oppm" or compareVersion(remoteManifest.version, manifest.version) or opts["allow-same-version"])) then
|
||||||
|
table.insert(toUpgrade, dep)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for pkg, manifest in pairs(installed) do
|
||||||
|
if (manifest.version == "oppm") then
|
||||||
|
printf("Found oppm version for %q.", pkg)
|
||||||
table.insert(toUpgrade, pkg)
|
table.insert(toUpgrade, pkg)
|
||||||
|
else
|
||||||
|
local remoteManifest = getPacket(pkg)
|
||||||
|
if (remoteManifest and (remoteManifest.version == "oppm" or compareVersion(remoteManifest.version, manifest.version))) then
|
||||||
|
table.insert(toUpgrade, pkg)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -332,7 +332,7 @@
|
|||||||
dependencies = {
|
dependencies = {
|
||||||
["pm"] = "/"
|
["pm"] = "/"
|
||||||
},
|
},
|
||||||
version = "1.2.2"
|
version = "1.3.0"
|
||||||
name = "pm get",
|
name = "pm get",
|
||||||
description = "Download and install package for pm",
|
description = "Download and install package for pm",
|
||||||
authors = "AR2000AR",
|
authors = "AR2000AR",
|
||||||
|
Reference in New Issue
Block a user