Skip to content

Commit

Permalink
luci-app-attendedsysupgrade: apply changes to package list
Browse files Browse the repository at this point in the history
Utilize the 'package_changes' from the ASU server to update the package list
for the build request.

Links: openwrt/asu@2bff208
Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
  • Loading branch information
efahl authored and aparcar committed Feb 8, 2025
1 parent 432dbf8 commit 5a79a57
Showing 1 changed file with 51 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
});
});
}),
},
Expand Down

0 comments on commit 5a79a57

Please sign in to comment.