[OpenWrt-Devel] [PATCH] buildscript: copy all squashfs images for one device

Adrian Schmutzler freifunk at adrianschmutzler.de
Thu Apr 2 09:50:58 EDT 2020


So far, we are selecting specific squashfs images to be copied
from openwrt bin folder to our "final" bin directory. This has
the disadvantage that additional image types/names have to be
added explicitly, bloating the relevant code in buildscript.

With this patch, this behavior is changed in order to copy all
squashfs images for a particular device. As before, this will
_not_ copy initramfs images.

Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---

This has been tested with my firmware, but not after porting to official.

---
 buildscript | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/buildscript b/buildscript
index b0935a4c..bbfb2f92 100755
--- a/buildscript
+++ b/buildscript
@@ -292,18 +292,23 @@ cp_firmware() {
 
     mkdir -p "bin/$variant"
 
+    imagesrcpath="$builddir/bin/targets/${chipset}/${subtarget}"
+    imagedestpath="./bin/$variant"
+
     for image in ${images[@]}; do
-        filename_build=${image//openwrt/fff-${version}}
-        filename_build=${filename_build//squashfs-/}
-        filename_build=${filename_build//${chipset}-${subtarget}-/}
-        cp "$builddir/bin/targets/${chipset}/${subtarget}/$image" "./bin/$variant/$filename_build"
-
-        for region in "" "-eu" "-us"; do
-            image_factory=${image/sysupgrade/factory$region}
-            if [[ -f "$builddir/bin/targets/${chipset}/${subtarget}/$image_factory" ]]; then
-              filename_build_factory=${filename_build/sysupgrade/factory$region}
-              cp "$builddir/bin/targets/${chipset}/${subtarget}/$image_factory" "./bin/$variant/$filename_build_factory"
-            fi
+        # the following line is no mistake, since the first expression
+        # is evaluated, while the second is used literally
+        fullsrcpath=$imagesrcpath/${image//squashfs-*/squashfs-*}
+        if ! ls $fullsrcpath >/dev/null 2>/dev/null; then
+            echo "Warning: $image not found."
+            continue
+        fi
+        for f in $fullsrcpath; do
+            filename_build=${f##*/}
+            filename_build=${filename_build//openwrt/fff-${version}}
+            filename_build=${filename_build//squashfs-/}
+            filename_build=${filename_build//${chipset}-${subtarget}-/}
+            cp "$f" "$imagedestpath/$filename_build"
         done
     done
 }
-- 
2.20.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list