diff --git a/packages/pm_get.tar b/packages/pm_get.tar index f259609..30473eb 100644 Binary files a/packages/pm_get.tar and b/packages/pm_get.tar differ diff --git a/pm_get/bin/pm-get.lua b/pm_get/bin/pm-get.lua index d5a4f38..394e6e1 100644 --- a/pm_get/bin/pm-get.lua +++ b/pm_get/bin/pm-get.lua @@ -16,12 +16,23 @@ local SOURCE_DIR = SOURCE_FILE .. ".d/" local REPO_MANIFEST_CACHE = CONFIG_DIR .. "manifests.cache" local AUTO_INSTALLED = CONFIG_DIR .. "autoInstalled" +--============================================================================= +---@type table,table +local args, opts = shell.parse(...) +local mode = table.remove(args, 1) --============================================================================= local reposRuntimeCache --============================================================================= +---@alias progOpts +---| 'autoremove' +---| 'purge' +---| 'allow-same-version' + + +--============================================================================= local f = string.format @@ -223,7 +234,11 @@ local function install(package, markAuto, buildDepTree) os.exit(1) end 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)) if (markAuto) then io.open(AUTO_INSTALLED, "a"):write(targetManifest.package):close() @@ -274,6 +289,7 @@ local function printHelp() printf("opts :") printf("\t--autoremove : also remove dependencies non longer required") 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 --============================================================================= @@ -284,6 +300,7 @@ else printferr("Need a internet card") end +--Remove uninstalled files from autoInstalled file if (filesystem.exists(AUTO_INSTALLED)) then do local tokeep = {} @@ -296,9 +313,6 @@ if (filesystem.exists(AUTO_INSTALLED)) then end end -local args, opts = shell.parse(...) -local mode = table.remove(args, 1) - if (mode == "update") then print("Updating repository cache") update() @@ -377,14 +391,29 @@ elseif (mode == "autoremove") then elseif (mode == "upgrade") then local installed = pm.getInstalled(false) local toUpgrade = {} - for pkg, manifest in pairs(installed) do - if (manifest.version == "oppm") then - printf("Found oppm version for %q.", pkg) - table.insert(toUpgrade, pkg) - else - local remoteManifest = getPacket(pkg) - if (remoteManifest and (remoteManifest.version == "oppm" or compareVersion(remoteManifest.version, manifest.version))) then + if (args[1]) then + if (pm.isInstalled(args[1])) then + table.insert(toUpgrade, args[1]) + local manifest = assert(pm.getManifestFromInstalled(args[1])) + if (manifest.dependencies) then + for dep, ver in pairs(manifest.dependencies) do + 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) + 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 diff --git a/programs.cfg b/programs.cfg index b26c785..0c621e0 100644 --- a/programs.cfg +++ b/programs.cfg @@ -332,7 +332,7 @@ dependencies = { ["pm"] = "/" }, - version = "1.2.2" + version = "1.3.0" name = "pm get", description = "Download and install package for pm", authors = "AR2000AR",