Skip to content
Snippets Groups Projects
Commit d5653558 authored by Felix Fietkau's avatar Felix Fietkau
Browse files

base-files: properly escape strings for version info


Make sure they don't break the sed command, and also make device_info
and openwrt_release more robust for parsing by scripts

Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>

SVN-Revision: 41885
parent dbb77e39
No related branches found
No related tags found
No related merge requests found
...@@ -17,28 +17,31 @@ PKG_CONFIG_DEPENDS += \ ...@@ -17,28 +17,31 @@ PKG_CONFIG_DEPENDS += \
CONFIG_VERSION_PRODUCT \ CONFIG_VERSION_PRODUCT \
CONFIG_VERSION_HWREV \ CONFIG_VERSION_HWREV \
VERSION_NUMBER:=$(call qstrip,$(CONFIG_VERSION_NUMBER)) qstrip_escape=$(subst ','\'',$(call qstrip,$(1)))
#'
VERSION_NUMBER:=$(call qstrip_escape,$(CONFIG_VERSION_NUMBER))
VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),$(REVISION)) VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),$(REVISION))
VERSION_CODE:=$(call qstrip,$(CONFIG_VERSION_NUMBER)) VERSION_CODE:=$(call qstrip_escape,$(CONFIG_VERSION_NUMBER))
VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),Bleeding Edge) VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),Bleeding Edge)
VERSION_NICK:=$(call qstrip,$(CONFIG_VERSION_NICK)) VERSION_NICK:=$(call qstrip_escape,$(CONFIG_VERSION_NICK))
VERSION_NICK:=$(if $(VERSION_NICK),$(VERSION_NICK),$(RELEASE)) VERSION_NICK:=$(if $(VERSION_NICK),$(VERSION_NICK),$(RELEASE))
VERSION_REPO:=$(call qstrip,$(CONFIG_VERSION_REPO)) VERSION_REPO:=$(call qstrip_escape,$(CONFIG_VERSION_REPO))
VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),http://downloads.openwrt.org/snapshots/trunk/%T/packages) VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),http://downloads.openwrt.org/snapshots/trunk/%T/packages)
VERSION_DIST:=$(call qstrip,$(CONFIG_VERSION_DIST)) VERSION_DIST:=$(call qstrip_escape,$(CONFIG_VERSION_DIST))
VERSION_DIST:=$(if $(VERSION_DIST),$(VERSION_DIST),OpenWrt) VERSION_DIST:=$(if $(VERSION_DIST),$(VERSION_DIST),OpenWrt)
VERSION_MANUFACTURER:=$(call qstrip,$(CONFIG_VERSION_MANUFACTURER)) VERSION_MANUFACTURER:=$(call qstrip_escape,$(CONFIG_VERSION_MANUFACTURER))
VERSION_MANUFACTURER:=$(if $(VERSION_MANUFACTURER),$(VERSION_MANUFACTURER),OpenWrt) VERSION_MANUFACTURER:=$(if $(VERSION_MANUFACTURER),$(VERSION_MANUFACTURER),OpenWrt)
VERSION_PRODUCT:=$(call qstrip,$(CONFIG_VERSION_PRODUCT)) VERSION_PRODUCT:=$(call qstrip_escape,$(CONFIG_VERSION_PRODUCT))
VERSION_PRODUCT:=$(if $(VERSION_PRODUCT),$(VERSION_PRODUCT),Generic) VERSION_PRODUCT:=$(if $(VERSION_PRODUCT),$(VERSION_PRODUCT),Generic)
VERSION_HWREV:=$(call qstrip,$(CONFIG_VERSION_HWREV)) VERSION_HWREV:=$(call qstrip_escape,$(CONFIG_VERSION_HWREV))
VERSION_HWREV:=$(if $(VERSION_HWREV),$(VERSION_HWREV),v0) VERSION_HWREV:=$(if $(VERSION_HWREV),$(VERSION_HWREV),v0)
define taint2sym define taint2sym
...@@ -80,3 +83,5 @@ VERSION_SED:=$(SED) 's,%U,$(VERSION_REPO),g' \ ...@@ -80,3 +83,5 @@ VERSION_SED:=$(SED) 's,%U,$(VERSION_REPO),g' \
-e 's,%M,$(VERSION_MANUFACTURER),g' \ -e 's,%M,$(VERSION_MANUFACTURER),g' \
-e 's,%P,$(VERSION_PRODUCT),g' \ -e 's,%P,$(VERSION_PRODUCT),g' \
-e 's,%h,$(VERSION_HWREV),g' -e 's,%h,$(VERSION_HWREV),g'
VERSION_SED_SCRIPT:=$(subst '\'','\'\\\\\'\'',$(VERSION_SED))
...@@ -110,7 +110,9 @@ define Package/base-files/install ...@@ -110,7 +110,9 @@ define Package/base-files/install
$(VERSION_SED) \ $(VERSION_SED) \
$(1)/etc/banner \ $(1)/etc/banner \
$(1)/etc/openwrt_version \ $(1)/etc/openwrt_version
$(VERSION_SED_SCRIPT) \
$(1)/etc/openwrt_release \ $(1)/etc/openwrt_release \
$(1)/etc/device_info $(1)/etc/device_info
......
DEVICE_MANUFACTURER="%M" DEVICE_MANUFACTURER='%M'
DEVICE_PRODUCT="%P" DEVICE_PRODUCT='%P'
DEVICE_REVISION="%h" DEVICE_REVISION='%h'
DISTRIB_ID="%D" DISTRIB_ID='%D'
DISTRIB_RELEASE="%C" DISTRIB_RELEASE='%C'
DISTRIB_REVISION="%R" DISTRIB_REVISION='%R'
DISTRIB_CODENAME="%n" DISTRIB_CODENAME='%n'
DISTRIB_TARGET="%S" DISTRIB_TARGET='%S'
DISTRIB_DESCRIPTION="%D %N %V" DISTRIB_DESCRIPTION='%D %N %V'
DISTRIB_TAINTS="%t" DISTRIB_TAINTS='%t'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment