buildscript: Remove target binaries from build dir before building

So far, if build fails, but images from last successful build are
present in OpenWrt build directory (build/bin/targets/...), those
are copied even after unsuccessful build.

This results in the old images being copied to the bin folder and
being labelled with the new firmware revision. (!)
As our error check also only looks at whether images are there,
the image copying process will look like a success.

This patch deletes old images of the target/subtarget to be built,
so that the copy-firmware step will find nothing if the build
stop to early.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Reviewed-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
Adrian Schmutzler 2019-10-02 17:42:35 +02:00
parent 199058d110
commit 8edb1689a3
1 changed files with 8 additions and 0 deletions

View File

@ -212,6 +212,8 @@ prebuild() {
build() {
prebuild
rm_firmware
opath=$(pwd)
cd "$target"
cpus=$(grep -c processor /proc/cpuinfo)
@ -269,6 +271,12 @@ config() {
cd "$opath"
}
rm_firmware() {
[ -n "$subtarget" ] || subtarget="generic"
rm -rf $target/bin/targets/${chipset}/${subtarget}
}
cp_firmware() {
[ -n "$subtarget" ] || subtarget="generic"