luci-app-package-manager: Fix upgrade action for apk
authorHannu Nyman <hannu.nyman@iki.fi>
Sat, 2 Nov 2024 16:27:05 +0000 (18:27 +0200)
committerHannu Nyman <hannu.nyman@iki.fi>
Sun, 3 Nov 2024 13:56:03 +0000 (15:56 +0200)
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 <hannu.nyman@iki.fi>
applications/luci-app-package-manager/htdocs/luci-static/resources/view/package-manager.js
applications/luci-app-package-manager/root/usr/share/rpcd/acl.d/luci-app-package-manager.json

index 74614636adf26ac5c5e3fdecd454990873976be2..bc246f9e294c309f0771e2fe1761023afcb27e46 100644 (file)
@@ -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) {
index 97150058ccc663980240998b8db5400848ce51d3..e4212389597dbb1385f0e86cff48a8de6bd1e8a8 100644 (file)
@@ -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" ],