From: Eric Fahlgren Date: Fri, 7 Feb 2025 21:02:24 +0000 (-0800) Subject: luci-app-attendedsysupgrade: apply changes to package list X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=5a79a578aad01f5ad51b79ecb8c6c2d6658c28ec;p=project%2Fluci.git luci-app-attendedsysupgrade: apply changes to package list Utilize the 'package_changes' from the ASU server to update the package list for the build request. Links: https://github.com/openwrt/asu/commit/2bff208387d69a5a1723032a45e672650c17de62 Signed-off-by: Eric Fahlgren --- diff --git a/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js b/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js index 32698b3d02..03244a8652 100644 --- a/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js +++ b/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js @@ -78,6 +78,44 @@ return view.extend({ request_hash: '', sha256_unsigned: '', + applyPackageChanges: async function(packages, data, firmware) { + const overview_url = `${data.url}/api/v1/overview`; + const revision_url = `${data.url}/api/v1/revision/${firmware.version}/${firmware.target}`; + + let changes, target_revision; + + await Promise.all([ + request.get(overview_url).then( + (response) => { + let json = response.json(); + changes = json.branches[get_branch(firmware.version)].package_changes; + }, + (failed) => { + ui.addNotification(null, E('p', _(`Get overview failed ${failed}`))); + } + ), + request.get(revision_url).then( + (response) => { + target_revision = get_revision_count(response.json().revision); + }, + (failed) => { + ui.addNotification(null, E('p', _(`Get revision failed ${failed}`))); + } + ), + ]); + + for (const change of changes) { + let idx = packages.indexOf(change.source); + if (idx >= 0 && change.revision <= target_revision) { + if (change.target) + packages[idx] = change.target; + else + packages.splice(idx, 1); + } + } + return packages; + }, + selectImage: function (images, data, firmware) { var filesystemFilter = function(e) { return (e.filesystem == firmware.filesystem); @@ -543,17 +581,19 @@ return view.extend({ class: 'btn cbi-button cbi-button-positive important', click: ui.createHandlerFn(this, function () { map.save().then(() => { - const content = { - ...firmware, - packages: mapdata.request.packages, - version: mapdata.request.version, - profile: mapdata.request.profile - }; - this.pollFn = L.bind(function () { - this.handleRequest(url, true, content, data, firmware); - }, this); - poll.add(this.pollFn, 5); - poll.start(); + this.applyPackageChanges(mapdata.request.packages, data, firmware).then((packages) => { + const content = { + ...firmware, + packages: packages, + version: mapdata.request.version, + profile: mapdata.request.profile + }; + this.pollFn = L.bind(function () { + this.handleRequest(url, true, content, data, firmware); + }, this); + poll.add(this.pollFn, 5); + poll.start(); + }); }); }), },