mirror of
https://github.com/openwrt/luci.git
synced 2026-01-13 20:00:29 +04:00
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: 2bff208387
Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
This commit is contained in:
committed by
Paul Spooren
parent
432dbf82d3
commit
5a79a578aa
@@ -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();
|
||||
});
|
||||
});
|
||||
}),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user