luci-app-attendedsysupgrade: request filesystem
authorPaul Spooren <mail@aparcar.org>
Mon, 21 Mar 2022 11:44:11 +0000 (11:44 +0000)
committerPaul Spooren <mail@aparcar.org>
Thu, 31 Mar 2022 15:28:19 +0000 (16:28 +0100)
It is possible to request a specific filesystem so no other filesystems
are used. This speeds up the build process and may prevent failures in
edge cases.

A recent edge case is installing more packages than ext4 can handle
while squashfs works fine due to compression.

Backport `procd` detection of `rootfs_type` to JavaScript:
https://git.openwrt.org/?p=project/procd.git;a=blob;f=system.c;h=93eac59c3b01ce3729dc27539ac483f5314759d3;hb=HEAD#l49

Signed-off-by: Paul Spooren <mail@aparcar.org>
applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js

index a82f7bdbed83d3581aad989c33abf4af56607855..1b794545e20b672bd59ba5f9b9f2ee2c54e5cc88 100644 (file)
@@ -79,13 +79,14 @@ return view.extend({
                version: '',
                packages: [],
                diff_packages: true,
+               filesystem: '',
        },
 
        handle200: function (response) {
                res = response.json();
                var image;
                for (image of res.images) {
-                       if (this.data.rootfs_type == image.filesystem) {
+                       if (this.firmware.filesystem == image.filesystem) {
                                if (this.data.efi) {
                                        if (image.type == 'combined-efi') {
                                                break;
@@ -402,7 +403,6 @@ return view.extend({
                        L.resolveDefault(callPackagelist(), {}),
                        L.resolveDefault(callSystemBoard(), {}),
                        L.resolveDefault(fs.stat("/sys/firmware/efi"), null),
-                       fs.read("/proc/mounts"),
                        uci.load('attendedsysupgrade'),
                ]);
        },
@@ -418,9 +418,27 @@ return view.extend({
                this.data.revision = res[1].release.revision;
                this.data.efi = res[2];
                if (res[1].rootfs_type) {
-                       this.data.rootfs_type = res[1].rootfs_type;
+                       this.firmware.filesystem = res[1].rootfs_type;
                } else {
-                       this.data.rootfs_type = res[3].split(/\r?\n/)[0].split(' ')[2]
+                       L.resolveDefault(fs.read("/proc/mounts"), '')
+                       .then(mounts => {
+                               mounts = mounts.split(/\r?\n/);
+                               var mount_point = '/';
+                               for (var i = 0; i < mounts.length; i++) {
+                                       // /dev/root /rom squashfs ro,relatime 0 0
+                                       var [ ,path,type,,, ] = mounts[i].split(' ')
+                                       if (path == mount_point) {
+                                               if (type != 'overlay') {
+                                                       this.firmware.filesystem = type;
+                                                       break;
+                                               } else {
+                                                       // restart search for root mountpoint
+                                                       i = -1;
+                                                       mount_point = '/rom';
+                                               }
+                                       }
+                               }
+                       });
                }
 
                this.data.url = uci.get_first('attendedsysupgrade', 'server', 'url');