Hi Daniel,

please check, if this really creates multiple entries in /etc/fw_env.config if 
they are defined in the uci config.
This is required for (other) boards using a redundant environment.

I think, your current code will only leave a file with the last entry
(each call to create_fwenv_config will overwrite the file)

Please correct ;-)

Thanks,
Thomas

-------- Original-Nachricht --------
> Datum: Thu, 27 Oct 2011 16:39:49 +0200
> Von: Daniel Golle <dgo...@allnet.de>
> An: OpenWrt Development List <openwrt-devel@lists.openwrt.org>
> Betreff: [OpenWrt-Devel] [PATCHv2] package/uboot-envtools: generate 
> config-file from UCI and make fw_setenv symlink optional

> This adds an init-script for generating /etc/fw_env.config from UCI in
> case it
> doesn't exist yet.
> 
> I also made the creation of the fw_set-symlink option, so it can be
> disabled in
> user-builds so only people who know what they are doing will mess with
> uboot-env
> 
> Ah, and zlib is a build-dependency, but in runtime zlib is not required,
> see
> root@OpenWrt:/# ldd /usr/sbin/fw_printenv 
>         libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x2abb2000)
>         libc.so.0 => /lib/libc.so.0 (0x2abd4000)
>         ld-uClibc.so.0 => /lib/ld-uClibc.so.0 (0x2ab9a000)
> 
> I therefore made it PKG_BUILD_DEPENDS instead of PKG_DEPENDS.
> 
> Signed-off-by: Daniel Golle <dgo...@allnet.de>
> 
> Index: package/uboot-envtools/files/uboot-envtools.init
> ===================================================================
> --- package/uboot-envtools/files/uboot-envtools.init  (revision 0)
> +++ package/uboot-envtools/files/uboot-envtools.init  (revision 0)
> @@ -0,0 +1,31 @@
> +#!/bin/sh /etc/rc.common
> +# (C) 2011 OpenWrt.org
> +# Creates /etc/fw_env.conf for fw_printenv (and fw_setenv)
> +
> +START=80
> +
> +create_fwenv_config() {
> +     local dev
> +     local offset
> +     local envsize
> +     local secsize
> +     local numsec
> +
> +     config_get dev "$1" dev
> +     config_get offset "$1" offset "0x0000"
> +     config_get envsize "$1" envsize
> +     config_get secsize "$1" secsize
> +     config_get numsec "$1" numsec
> +
> +     cat >/etc/fw_env.config <<EOF
> +# MTD device name    Device offset   Env. size       Flash sector size       
> Number of
> sectors
> +$dev         $offset         $envsize                $secsize                
> $numsec
> +EOF
> +}
> +
> +start() {
> +     [ ! -e /etc/fw_env.config ] && {
> +             config_load ubootenv
> +             config_foreach create_fwenv_config ubootenv
> +     }
> +}
> 
> Property changes on: package/uboot-envtools/files/uboot-envtools.init
> ___________________________________________________________________
> Added: svn:executable
>    + *
> 
> Index: package/uboot-envtools/Makefile
> ===================================================================
> --- package/uboot-envtools/Makefile   (revision 28625)
> +++ package/uboot-envtools/Makefile   (working copy)
> @@ -10,7 +10,7 @@
>  PKG_NAME:=uboot-envtools
>  PKG_DISTNAME:=u-boot
>  PKG_VERSION:=2011.06
> -PKG_RELEASE:=1
> +PKG_RELEASE:=2
>  
>  PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2
>  PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
> @@ -24,18 +24,27 @@
>    SECTION:=utils
>    CATEGORY:=Utilities
>    TITLE:=read/modify U-Boot bootloader environment
> -  DEPENDS:= +zlib
>    URL:=http://www.denx.de/wiki/U-Boot
> +  PKG_BUILD_DEPENDS:=zlib
>  endef
>  
>  define Package/uboot-envtools/description
>   This package includes tools to read and modify U-Boot bootloader
> environment.
>  endef
>  
> +define Package/uboot-envtools/config
> +        config PACKAGE_uboot-envtools_setenv_symlink
> +                bool "create fw_setenv symlink (write support)"
> +endef
> +
>  define Package/uboot-envtools/install
>       $(INSTALL_DIR) $(1)/usr/sbin
>       $(INSTALL_BIN) $(PKG_BUILD_DIR)/fw_printenv $(1)/usr/sbin/
> -     ln -sf fw_printenv $(1)/usr/sbin/fw_setenv
> +     $(INSTALL_DIR) $(1)/etc/init.d
> +     $(INSTALL_BIN) ./files/uboot-envtools.init
> $(1)/etc/init.d/uboot-envtools
> +ifneq ($(CONFIG_PACKAGE_uboot-envtools_setenv_symlink),)
> +     ln -s fw_printenv $(1)/usr/sbin/fw_setenv
> +endif
>  endef
>  
>  define Build/Prepare
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

-- 
Zwei Dinge sind unendlich: Das Universum und die menschliche Dummheit.
Aber bei dem Universum bin ich mir nicht ganz sicher.
A. Einstein

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to