summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js
diff options
context:
space:
mode:
authorPaul Spooren <mail@aparcar.org>2021-05-05 18:09:08 +0200
committerPaul Spooren <mail@aparcar.org>2021-05-05 06:14:32 -1000
commit85e9ee31239c4e912613005f4c222f13c34e9a36 (patch)
treecd74aab4edb1a972bab23b254c3d07973b158270 /applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js
parentc1c92b5506c1a1b97bbd6bc285b106c205e96e40 (diff)
luci-app-attendedsysupgrade: fix branch detection
The running branch determines which upgrades are suggested. A jump to a newer branch (e.g. 19.07.8 to 21.02.1) is only suggested if the advanced mode is enable, since it may break the router. OpenWrt versions end in either `-SNAPSHOT`, `.X-rcY` or `.x`. All these suffixes are removed, resulting in the branch name. Previously the `-SNAPSHOT` suffix wasn't removed resulting in wrong branch names. Also clean up some log spam. Signed-off-by: Paul Spooren <mail@aparcar.org>
Diffstat (limited to 'applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js')
-rw-r--r--applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js17
1 files changed, 12 insertions, 5 deletions
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 c5d21c2f3a..f6d31a35be 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
@@ -24,6 +24,15 @@ var callUpgradeStart = rpc.declare({
params: ["keep"]
});
+function get_branch(version) {
+ // determine branch of a version
+ // SNAPSHOT -> SNAPSHOT
+ // 21.02-SNAPSHOT -> 21.02
+ // 21.02.0-rc1 -> 21.02
+ // 19.07.8 -> 19.07
+ return version.replace("-SNAPSHOT", "").split(".").slice(0, 2).join(".");
+}
+
function install_sysupgrade(url, keep, sha256) {
displayStatus("notice spinning", E('p', _('Downloading firmware from server to browser')));
request.get(url, {
@@ -89,7 +98,6 @@ function request_sysupgrade(server_url, data) {
case 200:
var res = response.json()
var image;
- console.log(res)
for (image of res.images) {
if (image.type == "sysupgrade") {
break;
@@ -216,9 +224,10 @@ function request_sysupgrade(server_url, data) {
function check_sysupgrade(server_url, current_version, target, board_name, packages) {
displayStatus("notice spinning", E('p', _('Searching for an available sysupgrade')));
- var current_branch = current_version.split(".").slice(0, 2).join(".");
+ var current_branch = get_branch(current_version);
var advanced_mode = uci.get_first('attendedsysupgrade', 'client', 'advanced_mode') || 0;
var candidates = [];
+
fetch(server_url + "/api/latest")
.then(response => response.json())
.then(response => {
@@ -226,7 +235,7 @@ function check_sysupgrade(server_url, current_version, target, board_name, packa
candidates.push("SNAPSHOT");
} else {
for (let version of response["latest"]) {
- var branch = version.split(".").slice(0, 2).join(".");
+ var branch = get_branch(version);
// already latest version installed
if (current_version == version) {
@@ -249,8 +258,6 @@ function check_sysupgrade(server_url, current_version, target, board_name, packa
if (candidates) {
var m, s, o;
- console.log(candidates);
-
var mapdata = {
request: {
board_name: board_name,