Skip to contentSkip to conversation

package_rpm.bbclass: Accomodate dash when using arrays

PATCH Applied Khem Raj 3 participants 4 messages Jul 29, 2012 – Jul 31, 2012

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 package_rpm.bbclass: Accomodate dash when using arrays

we were assigning local variable to an array coming through positional arguments. local is a non posix contruct thats also supported by dash luckily but operates differently in this case it exapnds the array before assignment. so

local pkgs="$@"

turns into pkgs=locale-base-en-us locale-base-en-gb

ant we see errors

run.do_rootfs.25593: 932: local: locale-base-en-gb: bad variable name

So lets not use defining and assigning local in one go first define a local and then the assignment

---
 meta/classes/package_rpm.bbclass |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
meta/classes/package_rpm.bbclass +6 -1
index b4bc52e..50e9b31 100644
@@ -200,7 +200,12 @@ rpm_update_pkg () {
 process_pkg_list_rpm() {
 	local insttype=$1
 	shift
-	local pkgs="$@"
+	# $@ is special POSIX linear array can not be assigned
+	# to a local variable directly in dash since its separated by
+	# space and dash expands it before assignment
+	# and local x=1 2 3 and not x="1 2 3"
+	local pkgs
+	pkgs="$@"
 	local confbase=${INSTALL_CONFBASE_RPM}
 
 	echo -n > ${target_rootfs}/install/base_archs.pkglist
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 7 lines · On Sunday 29 July 2012 14:27:05 Khem Raj wrote:

we were assigning local variable to an array coming through positional arguments. local is a non posix contruct thats also supported by dash luckily but operates differently in this case it exapnds the array before assignment. so

local pkgs="$@"

Quoted 8 lines

turns into pkgs=locale-base-en-us locale-base-en-gb

ant we see errors

run.do_rootfs.25593: 932: local: locale-base-en-gb: bad variable name

So lets not use defining and assigning local in one go first define a local and then the assignment

Oops, sorry about that.

However, in the other thread you said package_rpm.bbclass was "full of bashisms" - is there only this one?

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
author
#2 lore raw

-Khem

Quoted 14 lines · Paul Eggleton
Quoted 13 lines · On Sunday 29 July 2012 14:27:05 Khem Raj wrote:

we were assigning local variable to an array coming through positional arguments. local is a non posix contruct thats also supported by dash luckily but operates differently in this case it exapnds the array before assignment. so

local pkgs="$@"

turns into pkgs=locale-base-en-us locale-base-en-gb

ant we see errors

run.do_rootfs.25593: 932: local: locale-base-en-gb: bad variable name

Quoted 7 lines
Quoted 2 lines

So lets not use defining and assigning local in one go first define a local and then the assignment

Oops, sorry about that.

However, in the other thread you said package_rpm.bbclass was "full of bashisms" - is there only this one?

I was referring to use of local since that is not posix but it seems it's so prevalent that even dash has extension for it so we are ok with dash and bash there

Quoted 8 lines

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#3 lore raw
In reply to Khem Raj
Quoted 13 lines · Khem Raj

we were assigning local variable to an array coming through positional arguments. local is a non posix contruct thats also supported by dash luckily but operates differently in this case it exapnds the array before assignment. so

local pkgs="$@"

turns into pkgs=locale-base-en-us locale-base-en-gb

ant we see errors

run.do_rootfs.25593: 932: local: locale-base-en-gb: bad variable name

Quoted 7 lines

So lets not use defining and assigning local in one go first define a local and then the assignment

---
 meta/classes/package_rpm.bbclass |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Merged to master, thanks.

Richard