[OpenWrt-Devel] [PATCH] package/boot/uboot-envtools: retry uci-defaults for fw_env.config

Tijs Van Buggenhout tvb at able.be
Mon Oct 27 09:53:52 EDT 2014


Consider a system with uboot-env at first boot after sysupgrade. By
default /etc/config/ubootenv will have been restored, which is not
the case for /etc/fw_env.config (generated, not installed by opkg).

Unfortunately fw_env.config will only be generated when
/etc/config/ubootenv is initialised (there is no uboot-env(tools)
init script. Hence the system may end up with a missing fw_env.config
after a sysupgrade:

* fw_env.config may not have existed, but now it should (added support
  for board)
* fw_env.config existed, but not part of sysupgrade backup (and thus not
  restored)

The following patch will retry uci-defaults for uboot-envtools when
fw_env.config is missing from sysupgrade backup, or it is empty.

Signed-off-by: Tijs Van Buggenhout <tvb at able.be>

--

diff --git a/package/boot/uboot-envtools/files/ar71xx b/package/boot/uboot-envtools/files/ar71xx
index 8d64d43..ea8cf72 100644
--- a/package/boot/uboot-envtools/files/ar71xx
+++ b/package/boot/uboot-envtools/files/ar71xx
@@ -3,14 +3,19 @@
 # Copyright (C) 2011-2014 OpenWrt.org
 #
 
-[ -s /etc/config/ubootenv ] && exit 0
+FWC="/etc/fw_env.config"
+UC="/etc/config/ubootenv"
 
-touch /etc/config/ubootenv
+[ -s $FWC -a -s $UC ] && exit 0
 
-. /lib/ar71xx.sh
 . /lib/uboot-envtools.sh
 . /lib/functions.sh
 
+[ -s $UC ] || {
+touch $UC
+
+. /lib/ar71xx.sh
+
 board=$(ar71xx_board_name)
 
 case "$board" in
@@ -45,6 +50,7 @@ qihoo-c301)
 	ubootenv_add_uci_config "/dev/mtd9" "0x0" "0x10000" "0x10000"
 	;;
 esac
+}
 
 config_load ubootenv
 config_foreach ubootenv_add_app_config ubootenv
diff --git a/package/boot/uboot-envtools/files/cns3xxx b/package/boot/uboot-envtools/files/cns3xxx
index 70521ed..1412d3c 100644
--- a/package/boot/uboot-envtools/files/cns3xxx
+++ b/package/boot/uboot-envtools/files/cns3xxx
@@ -3,14 +3,19 @@
 # Copyright (C) 2013 OpenWrt.org
 #
 
-[ -s /etc/config/ubootenv ] && exit 0
+FWC="/etc/fw_env.config"
+UC="/etc/config/ubootenv"
 
-touch /etc/config/ubootenv
+[ -s $FWC -a -s $UC ] && exit 0
 
-. /lib/cns3xxx.sh
 . /lib/uboot-envtools.sh
 . /lib/functions.sh
 
+[ -s $UC ] || {
+touch $UC
+
+. /lib/cns3xxx.sh
+
 board=$(cns3xxx_board_name)
 
 case "$board" in
@@ -21,6 +26,7 @@ laguna)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x$size" "0x$erasesize"
 	;;
 esac
+}
 
 config_load ubootenv
 config_foreach ubootenv_add_app_config ubootenv
diff --git a/package/boot/uboot-envtools/files/imx6 b/package/boot/uboot-envtools/files/imx6
index a63c8ae..5982c88 100644
--- a/package/boot/uboot-envtools/files/imx6
+++ b/package/boot/uboot-envtools/files/imx6
@@ -3,14 +3,19 @@
 # Copyright (C) 2013-2014 OpenWrt.org
 #
 
-[ -s /etc/config/ubootenv ] && exit 0
+FWC="/etc/fw_env.config"
+UC="/etc/config/ubootenv"
 
-touch /etc/config/ubootenv
+[ -s $FWC -a -s $UC ] && exit 0
 
-. /lib/imx6.sh
 . /lib/uboot-envtools.sh
 . /lib/functions.sh
 
+[ -s $UC ] || {
+touch $UC
+
+. /lib/imx6.sh
+
 board=$(imx6_board_name)
 
 case "$board" in
@@ -18,6 +23,7 @@ case "$board" in
 	ubootenv_add_uci_config "/dev/mmcblk0" "0x60000" "0x2000" "0x2000"
 	;;
 esac
+}
 
 config_load ubootenv
 config_foreach ubootenv_add_app_config ubootenv
diff --git a/package/boot/uboot-envtools/files/kirkwood b/package/boot/uboot-envtools/files/kirkwood
index ec32ec0..020e2f6 100644
--- a/package/boot/uboot-envtools/files/kirkwood
+++ b/package/boot/uboot-envtools/files/kirkwood
@@ -3,14 +3,19 @@
 # Copyright (C) 2012-2014 OpenWrt.org
 #
 
-[ -s /etc/config/ubootenv ] && exit 0
+FWC="/etc/fw_env.config"
+UC="/etc/config/ubootenv"
 
-touch /etc/config/ubootenv
+[ -s $FWC -a -s $UC ] && exit 0
 
-. /lib/kirkwood.sh
 . /lib/uboot-envtools.sh
 . /lib/functions.sh
 
+[ -s $UC ] || {
+touch $UC
+
+. /lib/kirkwood.sh
+
 board=$(kirkwood_board_name)
 
 case "$board" in
@@ -20,6 +25,7 @@ case "$board" in
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
 	;;
 esac
+}
 
 config_load ubootenv
 config_foreach ubootenv_add_app_config ubootenv
diff --git a/package/boot/uboot-envtools/files/lantiq b/package/boot/uboot-envtools/files/lantiq
index 79526c0..aced7e9 100644
--- a/package/boot/uboot-envtools/files/lantiq
+++ b/package/boot/uboot-envtools/files/lantiq
@@ -3,14 +3,19 @@
 # Copyright (C) 2012 OpenWrt.org
 #
 
-[ -s /etc/config/ubootenv ] && exit 0
+FWC="/etc/fw_env.config"
+UC="/etc/config/ubootenv"
 
-touch /etc/config/ubootenv
+[ -s $FWC -a -s $UC ] && exit 0
 
-. /lib/functions/lantiq.sh
 . /lib/uboot-envtools.sh
 . /lib/functions.sh
 
+[ -s $UC ] || {
+touch $UC
+
+. /lib/functions/lantiq.sh
+
 board=$(lantiq_board_name)
 
 case "$board" in
@@ -21,6 +26,7 @@ BTHOMEHUBV2B)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" "1"
 	;;
 esac
+}
 
 config_load ubootenv
 config_foreach ubootenv_add_app_config ubootenv
diff --git a/package/boot/uboot-envtools/files/mvebu b/package/boot/uboot-envtools/files/mvebu
index bfec1e5..9565e5a 100644
--- a/package/boot/uboot-envtools/files/mvebu
+++ b/package/boot/uboot-envtools/files/mvebu
@@ -3,14 +3,19 @@
 # Copyright (C) 2014 OpenWrt.org
 #
 
-[ -s /etc/config/ubootenv ] && exit 0
+FWC="/etc/fw_env.config"
+UC="/etc/config/ubootenv"
 
-touch /etc/config/ubootenv
+[ -s $FWC -a -s $UC ] && exit 0
 
-. /lib/mvebu.sh
 . /lib/uboot-envtools.sh
 . /lib/functions.sh
 
+[ -s $UC ] || {
+touch $UC
+
+. /lib/mvebu.sh
+
 board=$(mvebu_board_name)
 
 case "$board" in
@@ -18,6 +23,7 @@ case "$board" in
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x20000"
 	;;
 esac
+}
 
 config_load ubootenv
 config_foreach ubootenv_add_app_config ubootenv
diff --git a/package/boot/uboot-envtools/files/mxs b/package/boot/uboot-envtools/files/mxs
index ee66e8e..8d30fc1 100644
--- a/package/boot/uboot-envtools/files/mxs
+++ b/package/boot/uboot-envtools/files/mxs
@@ -3,14 +3,18 @@
 # Copyright (C) 2013 OpenWrt.org
 #
 
-[ -s /etc/config/ubootenv ] && exit 0
+FWC="/etc/fw_env.config"
+UC="/etc/config/ubootenv"
+[ -s $FWC -a -s $UC ] && exit 0
 
-touch /etc/config/ubootenv
-
-. /lib/mxs.sh
 . /lib/uboot-envtools.sh
 . /lib/functions.sh
 
+[ -s $UC ] || {
+touch $UC
+
+. /lib/mxs.sh
+
 board=$(mxs_board_name)
 
 case "$board" in
@@ -19,6 +23,7 @@ duckbill)
 	ubootenv_add_uci_config "/dev/mmcblk0" "0x40000" "0x20000"
 	;;
 esac
+}
 
 config_load ubootenv
 config_foreach ubootenv_add_app_config ubootenv
diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips
index 6dffbb6..848baf6 100644
--- a/package/boot/uboot-envtools/files/ramips
+++ b/package/boot/uboot-envtools/files/ramips
@@ -3,14 +3,19 @@
 # Copyright (C) 2011-2012 OpenWrt.org
 #
 
-[ -s /etc/config/ubootenv ] && exit 0
+FWC="/etc/fw_env.config"
+UC="/etc/config/ubootenv"
 
-touch /etc/config/ubootenv
+[ -s $FWC -a -s $UC ] && exit 0
 
-. /lib/ramips.sh
 . /lib/uboot-envtools.sh
 . /lib/functions.sh
 
+[ -s $UC ] || {
+touch $UC
+
+. /lib/ramips.sh
+
 board=$(ramips_board_name)
 
 case "$board" in
@@ -23,6 +28,7 @@ br6425)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
 	;;
 esac
+}
 
 config_load ubootenv
 config_foreach ubootenv_add_app_config ubootenv
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list