base-files: mtd_get_mac_ascii bugfix
authorGabor Juhos <juhosg@openwrt.org>
Fri, 8 Nov 2013 12:16:21 +0000 (12:16 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Fri, 8 Nov 2013 12:16:21 +0000 (12:16 +0000)
The mtd_get_mac_ascii utility function was broken. This fixes it.

  - Remove the superfluous include of /lib/functions.sh. The
    function is already in that file so it is pointless,
  - only use a variable if the whole key word matches,
  - don't try to process the MAC address if it is empty,
  - use 'tr' to canonicalize the MAC address,

Signed-off-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
[juhosg: add more fixes, update commit message]
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
SVN-Revision: 38690

package/base-files/Makefile
package/base-files/files/lib/functions.sh

index 3ba30c3abc7288c86e2f31aed048c3335b0445ae..f0b2e37d5b03a848045164e10271b6a4cd580b66 100644 (file)
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
 include $(INCLUDE_DIR)/version.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=146
+PKG_RELEASE:=147
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
 PKG_BUILD_DEPENDS:=opkg/host
index 19cfbae172a00730db80383386399f9eca1afe80..6cb6df92fd66954cf8b5d5a02ce87784d67eee12 100755 (executable)
@@ -248,17 +248,16 @@ mtd_get_mac_ascii()
        local part
        local mac_dirty
 
-       . /lib/functions.sh
-
        part=$(find_mtd_part "$mtdname")
        if [ -z "$part" ]; then
                echo "mtd_get_mac_ascii: partition $mtdname not found!" >&2
                return
        fi
 
-       mac_dirty=$(strings "$part" | sed -n 's/'"$key"'=//p')
+       mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')
+
        # "canonicalize" mac
-       printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${mac_dirty//:/ 0x}
+       [ -n "$mac_dirty" ] && echo ${mac_dirty} | tr [A-F] [a-f]
 }
 
 mtd_get_mac_binary() {