From 0b222207ba512d5c8248252b46665c99accce2e9 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Wed, 3 Jul 2019 10:44:30 -0400 Subject: [PATCH] package manager improvements --- sys/apps/PackageManager.lua | 26 ++++++++++++++++++++++---- sys/apps/Welcome.lua | 7 +++++-- sys/apps/package.lua | 27 ++++++++++++++++++++++----- sys/autorun/complete.lua | 2 +- sys/init/6.packages.lua | 6 ------ sys/modules/opus/packages.lua | 3 +++ 6 files changed, 53 insertions(+), 18 deletions(-) diff --git a/sys/apps/PackageManager.lua b/sys/apps/PackageManager.lua index de8af57..1329ec7 100644 --- a/sys/apps/PackageManager.lua +++ b/sys/apps/PackageManager.lua @@ -33,6 +33,12 @@ local page = UI.Page { operationText = 'Remove', help = 'Remove', }, + updateall = UI.Button { + ex = -2, y = -3, width = 12, + text = 'Update All', + event = 'updateall', + help = 'Update all installed packages', + }, description = UI.TextArea { x = 16, y = 3, ey = -5, marginRight = 0, marginLeft = 0, @@ -138,6 +144,13 @@ function page:eventHandler(event) self.description:draw() self:updateSelection(event.selected) + elseif event.type == 'updateall' then + self.operation = 'updateall' + self.action.button.text = ' Begin ' + self.action.button.event = 'begin' + self.action.titleBar.title = 'Update All' + self.action:show() + elseif event.type == 'action' then local selected = self.grid:getSelected() if selected then @@ -153,11 +166,16 @@ function page:eventHandler(event) self.action:hide() elseif event.type == 'begin' then - local selected = self.grid:getSelected() - self:run(self.operation, selected.name) - selected.installed = Packages:isInstalled(selected.name) + if self.operation == 'updateall' then + self:run(self.operation, '') + else + local selected = self.grid:getSelected() + self:run(self.operation, selected.name) + selected.installed = Packages:isInstalled(selected.name) + + self:updateSelection(selected) + end - self:updateSelection(selected) self.action.button.text = ' Done ' self.action.button.event = 'hide-action' self.action.button:draw() diff --git a/sys/apps/Welcome.lua b/sys/apps/Welcome.lua index 5405174..47c658f 100644 --- a/sys/apps/Welcome.lua +++ b/sys/apps/Welcome.lua @@ -25,7 +25,10 @@ Anavrins: Encryption/security/custom apps Community: Several selected applications hugeblank: Startup screen improvements LDDestroier: Art design + custom apps -Lemmmy: Application improvements]] +Lemmmy: Application improvements + +%sContribute at:%s +https://github.com/kepler155c/opus]] local page = UI.Page { wizard = UI.Wizard { @@ -108,7 +111,7 @@ local page = UI.Page { textColor = colors.yellow, inactive = true, x = 3, ex = -3, y = 2, ey = -2, - value = string.format(contributorsIntro, Ansi.white), + value = string.format(contributorsIntro, Ansi.white, Ansi.yellow, Ansi.white), }, }, }, diff --git a/sys/apps/package.lua b/sys/apps/package.lua index 864f4fd..3d95c17 100644 --- a/sys/apps/package.lua +++ b/sys/apps/package.lua @@ -35,13 +35,15 @@ local function progress(max) end end -local function install(name, isUpdate) +local function install(name, isUpdate, ignoreDeps) local manifest = Packages:downloadManifest(name) or error('Invalid package') - if manifest.required then - for _, v in pairs(manifest.required) do - if isUpdate or not Packages:isInstalled(v) then - install(v, isUpdate) + if not ignoreDeps then + if manifest.required then + for _, v in pairs(manifest.required) do + if isUpdate or not Packages:isInstalled(v) then + install(v, isUpdate) + end end end end @@ -89,6 +91,21 @@ if action == 'install' then return end +if action == 'refresh' then + print('Downloading...') + Packages:downloadList() + print('refresh complete') + return +end + +if action == 'updateall' then + for name in pairs(Packages:installed()) do + install(name, true, true) + end + print('updateall complete') + return +end + if action == 'update' then local name = args[1] or Syntax('Invalid package') if not Packages:isInstalled(name) then diff --git a/sys/autorun/complete.lua b/sys/autorun/complete.lua index 82b2fe5..31a6bd9 100644 --- a/sys/autorun/complete.lua +++ b/sys/autorun/complete.lua @@ -17,6 +17,6 @@ end _ENV.shell.setCompletionFunction("sys/apps/package.lua", function(_, index, text) if index == 1 then - return completeMultipleChoice(text, { "install ", "update ", "uninstall " }) + return completeMultipleChoice(text, { "install ", "update ", "uninstall ", "updateall ", "refresh" }) end end) diff --git a/sys/init/6.packages.lua b/sys/init/6.packages.lua index c991821..b1e6ef7 100644 --- a/sys/init/6.packages.lua +++ b/sys/init/6.packages.lua @@ -5,12 +5,6 @@ local fs = _G.fs local help = _G.help local shell = _ENV.shell -if not fs.exists('usr/config/packages') then - pcall(function() - Packages:downloadList() - end) -end - local appPaths = Util.split(shell.path(), '(.-):') local helpPaths = Util.split(help.path(), '(.-):') diff --git a/sys/modules/opus/packages.lua b/sys/modules/opus/packages.lua index c54bb65..a3890da 100644 --- a/sys/modules/opus/packages.lua +++ b/sys/modules/opus/packages.lua @@ -21,6 +21,9 @@ function Packages:installed() end function Packages:list() + if not fs.exists('usr/config/packages') then + self:downloadList() + end return Util.readTable('usr/config/packages') or { } end