[[PATCH v5] 1/2] use custom names for binary builds. fixes #9

Tobias Klaus tk+ff at meskal.net
Fr Mär 11 16:52:38 CET 2016


Hallo Jan,

zum Code selber hatte Steffen ja schon Anmerkungen gemacht.
Was ich mich aber immer frage ist, ob es nicht einfacher wäre eine Funktion 
wie 
diese bereitzustellen:

cpFirmware() {
  BASEFILE="$(basename $0)"
  TARGETFILE=$(echo "$BASEFILE" | sed -e "s/^openwrt/fff_${community}_$
{version}/g")
  cp "$0" ./bin/${TARGETFILE}
}

Pro: - Man hätte eine Stelle an der das Namenschema gesetzt wird.
         - Unterstützung modelle/Socs/... ist einfacher.

Kontra: - man wird das meiste der openwrt-Dateinamen nicht los. Insbesondere
                  den Chipsatz nicht. (squasfs und so würde man auch noch weg 
kriegen....)

Ist nur ein Vorschlag bzw eben das was ich gemacht hätte.    Vielleicht 
gefällts dir ja auch.

Grüße
Tobias


Am Donnerstag, 10. März 2016, 22:11:50 CET schrieb Jan Kraus:
> From: mojoaxel <alex at wunschik.net>
> 
> Signed-off-by: mojoaxel <alex at wunschik.net>
> Signed-off-by: Jan Kraus <mayosemmel at gmail.com>
> ---
>  bsp/board_ar71xx.bsp                               | 57
> +++++++++++----------- bsp/board_wdr4300.bsp                              |
> 30 ++++++------ bsp/board_wdr4900.bsp                              | 16
> ++++--
>  .../root_file_system/etc/config/firmware.tpl       |  2 +-
>  bsp/default/root_file_system/etc/sysupgrade.sh     | 26 +++++-----
>  buildscript                                        |  4 +-
>  6 files changed, 74 insertions(+), 61 deletions(-)
> 
> diff --git a/bsp/board_ar71xx.bsp b/bsp/board_ar71xx.bsp
> index 4876631..bbee59c 100644
> --- a/bsp/board_ar71xx.bsp
> +++ b/bsp/board_ar71xx.bsp
> @@ -1,5 +1,24 @@
>  machine=ar71xx
> +chipset=ar71xx
>  target=$builddir/$machine
> +boards=(
> +    ubnt-nano-m
> +    ubnt-loco-m-xw
> +    tl-wr740n-v4
> +    tl-wr741nd-v2
> +    tl-wr741nd-v4
> +    tl-wr841nd-v7
> +    tl-wr841n-v8
> +    tl-wr841n-v9
> +    tl-wr841n-v10
> +    tl-wr842n-v2
> +    tl-wr1043nd-v1
> +    tl-wr1043nd-v2
> +    tl-wr1043nd-v3
> +    tl-wa850re-v1
> +    tl-wa860re-v1
> +    gl-ar150
> +)
> 
>  board_prepare() {
>      echo "nothing todo" > /dev/null
> @@ -10,32 +29,14 @@ board_prebuild() {
>  }
> 
>  board_postbuild() {
> -    cp $target/bin/ar71xx/openwrt-ar71xx-generic-ubnt-nano-m-squashfs-*.bin
> ./bin/ -
> -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-ubnt-loco-m-xw-squashfs-*.bin
> ./bin/ -
> -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wr740n-v4-squashfs-*.bin
> ./bin/ -
> -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wr741nd-v2-squashfs-*.bin
> ./bin/ -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wr741nd-v4-squashfs-*.bin
> ./bin/ -
> -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wr841nd-v7-squashfs-*.bin
> ./bin/ -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wr841n-v8-squashfs-*.bin
> ./bin/ -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wr841n-v9-squashfs-*.bin
> ./bin/ -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wr841n-v10-squashfs-*.bin
> ./bin/ -
> -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wr842n-v2-squashfs-*.bin
> ./bin/ -
> -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wr1043nd-v1-squashfs-*.bin
> ./bin/ -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wr1043nd-v2-squashfs-*.bin
> ./bin/ -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wr1043nd-v3-squashfs-*.bin
> ./bin/ -
> -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wa860re-v1-squashfs-*.bin
> ./bin/ -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wa850re-v1-squashfs-*.bin
> ./bin/ -
> -    cp $target/bin/ar71xx/openwrt-ar71xx-generic-gl-ar150-squashfs-*.bin
> ./bin/ -}
> -
> -board_clean() {
> -    /bin/rm -rf $target bin/*$machine*
> +    for board in ${boards[@]}; do
> +        filename_openwrt=openwrt-${chipset}-generic-${board}-squashfs
> +        filename_build=fff-${community}_${version}_${board}
> +
> +	if [ -f $target/bin/${chipset}/${filename_openwrt}-factory.bin ]
> +	then
> +		cp $target/bin/${chipset}/${filename_openwrt}-factory.bin
> ./bin/${filename_build}_factory.bin +	fi
> +        cp $target/bin/${chipset}/${filename_openwrt}-sysupgrade.bin
> ./bin/${filename_build}_sysupgrade.bin +    done
>  }
> diff --git a/bsp/board_wdr4300.bsp b/bsp/board_wdr4300.bsp
> index 7e6c66e..f2821ae 100644
> --- a/bsp/board_wdr4300.bsp
> +++ b/bsp/board_wdr4300.bsp
> @@ -1,28 +1,28 @@
>  machine=wdr4300
> +chipset=ar71xx
>  target=$builddir/$machine
> +boards=(
> +    tl-wdr3500-v1
> +    tl-wdr3600-v1
> +    tl-wdr4300-v1
> +    tl-wdr4310-v1
> +)
> 
>  board_prepare() {
> -	echo "nothing todo" > /dev/null
> +    echo "nothing todo" > /dev/null
>  }
> 
>  board_prebuild() {
> -	echo "nothing todo" > /dev/null
> +    echo "nothing todo" > /dev/null
>  }
> 
>  board_postbuild() {
> -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wdr3500-v1-squashfs-factory.bi
> n ./bin/ -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wdr3500-v1-squashfs-sysupgrade
> .bin ./bin/ +    for board in ${boards[@]}; do
> +        filename_openwrt=openwrt-${chipset}-generic-${board}-squashfs
> +        filename_build=fff-${community}_${version}_${board}
> 
> -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wdr3600-v1-squashfs-factory.bi
> n ./bin/ -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wdr3600-v1-squashfs-sysupgrade
> .bin ./bin/ -
> -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wdr4300-v1-squashfs-factory.bi
> n ./bin/ -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wdr4300-v1-squashfs-sysupgrade
> .bin ./bin/ -
> -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wdr4310-v1-squashfs-factory.bi
> n ./bin/ -    cp
> $target/bin/ar71xx/openwrt-ar71xx-generic-tl-wdr4310-v1-squashfs-sysupgrade
> .bin ./bin/ +        cp
> $target/bin/${chipset}/${filename_openwrt}-factory.bin
> ./bin/${filename_build}_factory.bin +        cp
> $target/bin/${chipset}/${filename_openwrt}-sysupgrade.bin
> ./bin/${filename_build}_sysupgrade.bin +    done
>  }
> 
> -board_clean() {
> -	/bin/rm -rf $target bin/*$machine*
> -}
> \ No newline at end of file
> diff --git a/bsp/board_wdr4900.bsp b/bsp/board_wdr4900.bsp
> index 777b3b5..4954739 100644
> --- a/bsp/board_wdr4900.bsp
> +++ b/bsp/board_wdr4900.bsp
> @@ -1,5 +1,9 @@
>  machine=wdr4900
> +chipset=mpc85xx
>  target=$builddir/$machine
> +boards=(
> +    tl-wdr4900-v1
> +)
> 
>  board_prepare() {
>  	echo "nothing todo" > /dev/null
> @@ -10,10 +14,12 @@ board_prebuild() {
>  }
> 
>  board_postbuild() {
> -    cp
> $target/bin/mpc85xx/openwrt-mpc85xx-generic-tl-wdr4900-v1-squashfs-factory.
> bin ./bin/ -    cp
> $target/bin/mpc85xx/openwrt-mpc85xx-generic-tl-wdr4900-v1-squashfs-sysupgra
> de.bin ./bin/ +    for board in ${boards[@]}; do
> +        filename_openwrt=openwrt-${chipset}-generic-${board}-squashfs
> +        filename_build=fff-${community}_${version}_${board}
> +
> +        cp $target/bin/${chipset}/${filename_openwrt}-factory.bin
> ./bin/${filename_build}_factory.bin +        cp
> $target/bin/${chipset}/${filename_openwrt}-sysupgrade.bin
> ./bin/${filename_build}_sysupgrade.bin +    done
>  }
> 
> -board_clean() {
> -	/bin/rm -rf $target bin/*$machine*
> -}
> \ No newline at end of file
> diff --git a/bsp/default/root_file_system/etc/config/firmware.tpl
> b/bsp/default/root_file_system/etc/config/firmware.tpl index
> 1c2e7d6..49c61bd 100644
> --- a/bsp/default/root_file_system/etc/config/firmware.tpl
> +++ b/bsp/default/root_file_system/etc/config/firmware.tpl
> @@ -1,4 +1,4 @@
>  config upgrade 'upgrade'
>  	option path '${UPGRADE_PATH}'
>  	option auto 0
> -	option remote 1
> \ No newline at end of file
> +	option remote 1
> diff --git a/bsp/default/root_file_system/etc/sysupgrade.sh
> b/bsp/default/root_file_system/etc/sysupgrade.sh index e954514..a90164d
> 100755
> --- a/bsp/default/root_file_system/etc/sysupgrade.sh
> +++ b/bsp/default/root_file_system/etc/sysupgrade.sh
> @@ -1,21 +1,25 @@
>  #!/bin/sh
> +cd /tmp/
> 
> -BOARD=`uci get board.model.name`
> +. /etc/firmware_release
> 
> -case $BOARD in
> -    tl-wdr4900-v1 )
> -        SOC="mpc85xx" ;;
> -    * )
> -        SOC="ar71xx" ;;
> -esac
> +BOARD=$(uci get board.model.name)
> +echo -ne "\nHardware: $BOARD\n"
> 
> -FILE="openwrt-${SOC}-generic-${BOARD}-squashfs-sysupgrade.bin"
> +wget $(uci get firmware.upgrade.path)/release.nfo
> +if [ ! -f release.nfo ]; then
> +  echo -ne "Latest release information not found. Please try to update
> manually.\n\n" +  exit 1
> +fi
> +VERSION=$(grep -Po '(?<=^VERSION:).*' release.nfo)
> +rm -f release.nfo
> +echo -ne "Firmware found on server: $VERSION\n"
> 
> -echo -ne "\nHardware: $BOARD\n"
> +FILE="fff-${FIRMWARE_COMMUNITY}_${VERSION}_${BOARD}-sysupgrade.bin"
>  echo -ne "Downloading $FILE\n\n"
> -cd /tmp/
>  wget $(uci get firmware.upgrade.path)/${FILE}
>  wget $(uci get firmware.upgrade.path)/${FILE}.md5
> +
>  echo -ne "\ndone. Comparing md5 sums: "
>  md5sum -c ${FILE}.md5
>  ret=$?
> @@ -32,4 +36,4 @@ else
>          [Nn]|* ) echo -ne "\nAborting firmware upgrade.\n\n"; rm -f
> ${FILE}*; exit 0;; esac
>    done
> -fi
> \ No newline at end of file
> +fi
> diff --git a/buildscript b/buildscript
> index dd68254..6510450 100755
> --- a/buildscript
> +++ b/buildscript
> @@ -272,10 +272,12 @@ config() {
> 
>  postbuild() {
>      board_postbuild
> +
> +    # add version info at the top of the release file; needed by
> etc/sysupgrade.sh +    echo -e "VERSION:$version\n\n" > ./bin/release.nfo
>  }
> 
>  clean() {
> -    board_clean
>      /bin/rm -rf bin $builddir src/openwrt
> 
>      # remove downloaded package feeds

-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname   : signature.asc
Dateityp    : application/pgp-signature
Dateigröße  : 819 bytes
Beschreibung: This is a digitally signed message part.
URL         : <http://lists.freifunk.net/pipermail/franken-dev-freifunk.net/attachments/20160311/90ccd922/attachment-0002.sig>


Mehr Informationen über die Mailingliste franken-dev