From 5c27cf3671d298290a0e6a27936250e971eeb650 Mon Sep 17 00:00:00 2001 From: Hannu Nyman Date: Sat, 2 Nov 2024 18:27:05 +0200 Subject: [PATCH] luci-app-package-manager: Fix upgrade action for apk Fix upgrade action for apk by passing an attribute to differentiate between install and upgrade actions. Adjust acl accordingly. Remove extra whitespace. Signed-off-by: Hannu Nyman --- .../htdocs/luci-static/resources/view/package-manager.js | 8 ++++++-- .../usr/share/rpcd/acl.d/luci-app-package-manager.json | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/applications/luci-app-package-manager/htdocs/luci-static/resources/view/package-manager.js b/applications/luci-app-package-manager/htdocs/luci-static/resources/view/package-manager.js index 74614636ad..bc246f9e29 100644 --- a/applications/luci-app-package-manager/htdocs/luci-static/resources/view/package-manager.js +++ b/applications/luci-app-package-manager/htdocs/luci-static/resources/view/package-manager.js @@ -261,6 +261,7 @@ function display(pattern) btn = E('div', { 'class': 'btn cbi-button-positive', 'data-package': name, + 'data-action': 'upgrade', 'click': handleInstall }, _('Upgrade…')); } @@ -284,12 +285,14 @@ function display(pattern) btn = E('div', { 'class': 'btn cbi-button-action', 'data-package': name, + 'data-action': 'install', 'click': handleInstall }, _('Install…')); else if (inst.installed && inst.version != pkg.version) btn = E('div', { 'class': 'btn cbi-button-positive', 'data-package': name, + 'data-action': 'upgrade', 'click': handleInstall }, _('Upgrade…')); else @@ -661,6 +664,7 @@ function handleReset(ev) function handleInstall(ev) { var name = ev.target.getAttribute('data-package'), + installcmd = ev.target.getAttribute('data-action'), pkg = packages.available.pkgs[name], depcache = {}, size; @@ -800,7 +804,7 @@ function handleInstall(ev) }, _('Cancel')), ' ', E('div', { - 'data-command': 'install', + 'data-command': installcmd, 'data-package': name, 'class': 'btn cbi-button-action', 'click': handlePkg, @@ -872,7 +876,7 @@ function handleConfig(ev) } else if (partials[i].name.match(/\.conf$/)) { files.push(base_dir + '/' + partials[i].name); } - } + } } return Promise.all(files.map(function(file) { diff --git a/applications/luci-app-package-manager/root/usr/share/rpcd/acl.d/luci-app-package-manager.json b/applications/luci-app-package-manager/root/usr/share/rpcd/acl.d/luci-app-package-manager.json index 97150058cc..e421238959 100644 --- a/applications/luci-app-package-manager/root/usr/share/rpcd/acl.d/luci-app-package-manager.json +++ b/applications/luci-app-package-manager/root/usr/share/rpcd/acl.d/luci-app-package-manager.json @@ -20,6 +20,8 @@ "/usr/libexec/package-manager-call install *": [ "exec" ], "/usr/libexec/package-manager-call remove *": [ "exec" ], "/usr/libexec/package-manager-call update": [ "exec" ], + "/usr/libexec/package-manager-call upgrade": [ "exec" ], + "/usr/libexec/package-manager-call upgrade *": [ "exec" ], "/etc/opkg.conf": [ "write" ], "/etc/opkg/*.conf": [ "write" ], "/etc/apk/repositories": [ "write" ], -- 2.30.2