uboot-envtools: check for config prior to append
authorImran Khan <gururug@gmail.com>
Tue, 17 Dec 2019 13:59:28 +0000 (05:59 -0800)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 17 Dec 2019 17:35:16 +0000 (19:35 +0200)
In the rare event a pre-populated fw_env.config exists in the rootfs prior
to firstboot, calling fw_setenv after the system has initialised will
annihilate the devices environment due to two identical lines in
fw_env.config.

Check for existence prior to blind appendage.

Signed-off-by: Imran Khan <gururug@gmail.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
[daniel@makrotopia.org: fixed patch format, improved grep, cosmetics]

package/boot/uboot-envtools/Makefile
package/boot/uboot-envtools/files/uboot-envtools.sh

index f880698e9cb8b2f59136a6030cd89d61cd61c2d5..1c6b7897161404d299011946a643e4e9762e6f1b 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=uboot-envtools
 PKG_DISTNAME:=u-boot
 PKG_VERSION:=2019.07
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.xz
index e21b28367751fdd86897f3a47911f3a3ffbdbdfb..9218bc4e391297a29778c961d1564a4c1766aa37 100644 (file)
@@ -31,6 +31,6 @@ ubootenv_add_app_config() {
        config_get envsize "$1" envsize
        config_get secsize "$1" secsize
        config_get numsec "$1" numsec
-       echo "$dev $offset $envsize $secsize $numsec" >>/etc/fw_env.config
+       grep -q "^[[:space:]]*${dev}[[:space:]]*${offset}" /etc/fw_env.config || echo "$dev $offset $envsize $secsize $numsec" >>/etc/fw_env.config
 }