[v2] buildscript: copy all squashfs images for one device

Submitted by Adrian Schmutzler on April 2, 2020, 2:23 p.m.

Details

Message ID 20200402142315.15209-1-freifunk@adrianschmutzler.de
State Accepted
Headers show

Commit Message

Adrian Schmutzler April 2, 2020, 2:23 p.m.
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. To achieve that, the
image names in the bsp files are changed to contain a wildcard
that will be evaluated in buildscript.

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

---

Changes in v2:
- Don't put wildcard in buildscript, but adjust bsp files. This
  will allow to use different wildcards for individual devices,
  e.g. when initramfs is desired
---
 bsp/board_ar71xx.bsp  | 76 +++++++++++++++++++++----------------------
 bsp/board_ipq806x.bsp |  2 +-
 bsp/board_mpc85xx.bsp |  2 +-
 bsp/board_mt7621.bsp  |  4 +--
 buildscript           | 26 ++++++++-------
 5 files changed, 57 insertions(+), 53 deletions(-)

Patch hide | download patch | download mbox

diff --git a/bsp/board_ar71xx.bsp b/bsp/board_ar71xx.bsp
index 46c5df2f..344e2e53 100644
--- a/bsp/board_ar71xx.bsp
+++ b/bsp/board_ar71xx.bsp
@@ -1,42 +1,42 @@ 
 machine=ar71xx
 chipset=ar71xx
 subtarget=tiny
-images=("openwrt-${chipset}-${subtarget}-archer-c25-v1-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-archer-c60-v1-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-archer-c60-v2-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-archer-c7-v2-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-archer-c7-v5-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-cpe210-220-v1-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-cpe210-v2-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-cpe210-v3-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-cpe510-520-v1-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-gl-ar150-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-mr3020-v1-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wa850re-v1-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wa860re-v1-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wa901nd-v2-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wdr3500-v1-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wdr3600-v1-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wdr4300-v1-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wdr4310-v1-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr1043nd-v1-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr1043nd-v2-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr1043nd-v3-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr1043nd-v4-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr1043n-v5-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr740n-v4-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr741nd-v2-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr741nd-v4-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr841-v7-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr841-v8-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr841-v9-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr841-v10-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr841-v11-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr841-v12-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-tl-wr842n-v2-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-ubnt-bullet-m-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-ubnt-loco-m-xw-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-ubnt-nano-m-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-ubnt-unifi-squashfs-sysupgrade.bin"
-        "openwrt-${chipset}-${subtarget}-ubnt-unifiac-lite-squashfs-sysupgrade.bin"
+images=("openwrt-${chipset}-${subtarget}-archer-c25-v1-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-archer-c60-v1-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-archer-c60-v2-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-archer-c7-v2-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-archer-c7-v5-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-cpe210-220-v1-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-cpe210-v2-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-cpe210-v3-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-cpe510-520-v1-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-gl-ar150-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-mr3020-v1-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wa850re-v1-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wa860re-v1-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wa901nd-v2-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wdr3500-v1-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wdr3600-v1-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wdr4300-v1-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wdr4310-v1-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr1043nd-v1-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr1043nd-v2-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr1043nd-v3-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr1043nd-v4-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr1043n-v5-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr740n-v4-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr741nd-v2-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr741nd-v4-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr841-v7-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr841-v8-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr841-v9-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr841-v10-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr841-v11-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr841-v12-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-tl-wr842n-v2-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-ubnt-bullet-m-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-ubnt-loco-m-xw-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-ubnt-nano-m-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-ubnt-unifi-squashfs-*"
+        "openwrt-${chipset}-${subtarget}-ubnt-unifiac-lite-squashfs-*"
         )
diff --git a/bsp/board_ipq806x.bsp b/bsp/board_ipq806x.bsp
index 1cff488c..194049aa 100644
--- a/bsp/board_ipq806x.bsp
+++ b/bsp/board_ipq806x.bsp
@@ -3,5 +3,5 @@  chipset=ipq806x
 subtarget=generic
 
 images=(
-        "openwrt-${chipset}-${subtarget}-tplink_c2600-squashfs-sysupgrade.bin"
+        "openwrt-${chipset}-${subtarget}-tplink_c2600-squashfs-*"
        )
diff --git a/bsp/board_mpc85xx.bsp b/bsp/board_mpc85xx.bsp
index 79725d5c..6e100355 100644
--- a/bsp/board_mpc85xx.bsp
+++ b/bsp/board_mpc85xx.bsp
@@ -3,5 +3,5 @@  chipset=mpc85xx
 subtarget=generic
 
 images=(
-        "openwrt-${chipset}-${subtarget}-tl-wdr4900-v1-squashfs-sysupgrade.bin"
+        "openwrt-${chipset}-${subtarget}-tl-wdr4900-v1-squashfs-*"
        )
diff --git a/bsp/board_mt7621.bsp b/bsp/board_mt7621.bsp
index 1c91bf5f..aef3800d 100644
--- a/bsp/board_mt7621.bsp
+++ b/bsp/board_mt7621.bsp
@@ -3,6 +3,6 @@  chipset=ramips
 subtarget=mt7621
 
 images=(
-        "openwrt-ramips-mt7621-ubnt-erx-squashfs-sysupgrade.bin"
-        "openwrt-ramips-mt7621-ubnt-erx-sfp-squashfs-sysupgrade.bin"
+        "openwrt-ramips-mt7621-ubnt-erx-squashfs-*"
+        "openwrt-ramips-mt7621-ubnt-erx-sfp-squashfs-*"
        )
diff --git a/buildscript b/buildscript
index b0935a4c..3aa262db 100755
--- a/buildscript
+++ b/buildscript
@@ -292,18 +292,22 @@  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
+        # This assumes the set of images names is given with a wildcard
+        fullsrcpath=$imagesrcpath/$image
+        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
 }

Comments

Fabian Blaese April 15, 2020, 1:20 p.m.
Find ich gut. Das hier ersetzt dann meinen Patch, der die tftp images hinzugefügt hat.
Beim applien bitte dran denken, dass das einen Konflikt mit den neuen Geräten (C50, 841c13) gibt.

Reviewed-by: Fabian Bläse <fabian@blaese.de>

Kleinkram inline.

Gruß
Fabian

On 02.04.20 16:23, Adrian Schmutzler wrote:
> diff --git a/buildscript b/buildscript
> index b0935a4c..3aa262db 100755
> --- a/buildscript
> +++ b/buildscript
> @@ -292,18 +292,22 @@ 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
> +        # This assumes the set of images names is given with a wildcard
> +        fullsrcpath=$imagesrcpath/$image
fullsrcpattern= ?

> +        if ! ls $fullsrcpath >/dev/null 2>/dev/null; then
> +            echo "Warning: $image not found."
> +            continue
> +        fi
> +        for f in $fullsrcpath; do
> +            filename_build=${f##*/}
Kann man so machen, ich würde aber eher zu $(basename "$f") tendieren.

> +            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
>  }
>
Adrian Schmutzler April 15, 2020, 2 p.m.
Hallo,

> Subject: Re: [PATCH v2] buildscript: copy all squashfs images for one device

Applied.

> > +        fullsrcpath=$imagesrcpath/$image 
> fullsrcpattern= ? 

Geändert.

> > +            filename_build=${f##*/} 
> Kann man so machen, ich würde aber eher zu $(basename "$f") tendieren. 

Nicht geändert.