Script error when using EXTRA_IMAGECMD::append
Hello,
I recently pulled down this change that fixes an issue with EXTRA_IMAGECMD support for squashfs-xz: https://github.com/yoctoproject/poky/commit/70a857b8f3fd3e9b95b903e8313d0014a6ff8c96.
After that change, I now get a script error when running oe_mksquashfs().
This is the append I use:
EXTRA_IMAGECMD:squashfs-xz:append = "-processors 64 -b 262144 -Xdict-size 100% -Xbcj arm"
This is the error I get:
| DEBUG: Executing shell function do_image_squashfs_xz | /home/jmbills/upstream-sync/openbmc-openbmc/build/tmp/work/intel_ast2600-openbmc-linux-gnueabi/intel-platforms/1.0/temp/run.do_image_squashfs_xz.2945674: 157: local: 64: bad variable name | WARNING: exit code 2 from a shell command.
The issue is fixed if I change this line:
local extra_imagecmd="$@"
to this:
local extra_imagecmd="$*"
If that change looks correct, I can submit it as a patch, if that would be helpful.
Thanks for your help,
-Jason
Quoted 5 lines · Jason M via lists.yoctoproject.org
Hello,
I recently pulled down this change that fixes an issue with
EXTRA_IMAGECMDsupport for squashfs-xz: https://github.com/yoctoproject/poky/commit/70a857b8f3fd3e9b95b903e8313d0014a6ff8c96.
Looking at this commit, it's using the 'local' keyword which is a bash extension and I wonder if that
is right, since we support posix compliant shell syntax for executing shell tasks.
what is your defautl shell, is it bash or dash ?
Quoted 10 lines
After that change, I now get a script error when running
oe_mksquashfs().This is the append I use:
EXTRA_IMAGECMD:squashfs-xz:append = "-processors 64 -b 262144 -Xdict-size 100% -Xbcj arm"This is the error I get:
| DEBUG: Executing shell function do_image_squashfs_xz | /home/jmbills/upstream-sync/openbmc-openbmc/build/tmp/work/intel_ast2600-openbmc-linux-gnueabi/intel-platforms/1.0/temp/run.do_image_squashfs_xz.2945674: 157: local: 64: bad variable name | WARNING: exit code 2 from a shell command.
Quoted 7 lines
The issue is fixed if I change this line:
local extra_imagecmd="$@"
to this:
local extra_imagecmd="$*"If that change looks correct, I can submit it as a patch, if that would be helpful.
since "$*" Combines all arguments into a single string, separated by IFS compared to
"$@" which keeps individual ariguments, it may result in same behaviour since we are not
looping over these argument etc.
what happens if you use single quotes around $@
Quoted 13 lines
Thanks for your help,
-Jason-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
You automatically follow any topics you start or reply to. View/Reply Online (#64569): https://lists.yoctoproject.org/g/yocto/message/64569
Mute This Topic: https://lists.yoctoproject.org/mt/110653777/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Khem Raj via lists.yoctoproject.org schrieb am Do 16. Jan, 17:45 (-0800):
Quoted 9 lines
Quoted 5 lines · Jason M via lists.yoctoproject.org
Hello,
I recently pulled down this change that fixes an issue with
EXTRA_IMAGECMDsupport for squashfs-xz: https://github.com/yoctoproject/poky/commit/70a857b8f3fd3e9b95b903e8313d0014a6ff8c96.
Quoted 6 lines
Looking at this commit, it's using the 'local' keyword which is a bash extension and I wonder if that
is right, since we support posix compliant shell syntax for executing shell tasks.what is your defautl shell, is it bash or dash ?
Dash supports *local*.
From dash(1):
Variables may be declared to be local to a function by using a local command. This should appear as the first statement of a function, and the syntax is
local [variable | -] ...
Local is implemented as a builtin command.
This is the append I use:
EXTRA_IMAGECMD:squashfs-xz:append = "-processors 64 -b 262144 -Xdict-size 100% -Xbcj arm"
Shouldn’t there be a leading space, given that you use “append”?
BR,
Heinz
Quoted 4 lines · Heinz Wrobel via lists.yoctoproject.org
This is the append I use:
EXTRA_IMAGECMD:squashfs-xz:append = "-processors 64 -b 262144 -Xdict-size 100% -Xbcj arm"Shouldn’t there be a leading space, given that you use “append”?
Yes, unless that isn’t a direct copy-and-paste, this is almost certainly from a missing leading whitespace causing sh parsing to fail in interesting ways.
Ross
Quoted 1 line
what is your defautl shell, is it bash or dash ?
I use bash
Quoted 1 line
what happens if you use single quotes around $@
I made this change:
poky/meta/classes-recipe/image_types.bbclass +0 -0
@@ -113,7 +113,7 @@ IMAGE_CMD:btrfs () {
oe_mksquashfs () {
local comp=$1; shift
- local extra_imagecmd="$@"
+ local extra_imagecmd='$@'
if [ "$comp" = "zstd" ]; then
suffix="zst"
and got this result:
| DEBUG: Executing shell function do_image_squashfs_xz | mksquashfs: invalid option | | SYNTAX:mksquashfs source1 source2 ... FILESYSTEM [OPTIONS] [-e list of | exclude dirs/files]
....
Quoted 3 lines
Quoted 1 line
Shouldn’t there be a leading space, given that you use “append”?
Yes, unless that isn’t a direct copy-and-paste, this is almost certainly from a missing leading whitespace causing sh parsing to fail in interesting ways.
I made this change:
poky/meta/classes-recipe/image_types.bbclass +0 -0
@@ -112,6 +112,8 @@ IMAGE_CMD:btrfs () {
}oe_mksquashfs () {
+ echo "oe_mksquashfs params:"
+ echo "$@"
local comp=$1; shift
local extra_imagecmd="$@"
With
EXTRA_IMAGECMD:squashfs-xz:append = "-processors 64 -b 262144 -Xdict-size 100% -Xbcj arm" I get
| DEBUG: Executing shell function do_image_squashfs_xz | oe_mksquashfs params: | xz -processors 64 -b 262144 -Xdict-size 100% -Xbcj arm | WARNING: exit code 2 from a shell command. | /home/jmbills/upstream-sync/openbmc-openbmc/build/tmp/work/intel_ast2600-openbmc-linux-gnueabi/intel-platforms/1.0/temp/run.do_image_squashfs_xz.37111: 159: local: 64: bad variable name
ERROR: Task (/home/jmbills/upstream-sync/openbmc-openbmc/openbmc-meta-intel/meta-common/recipes-intel/images/intel-platforms.bb:do_image_squashfs_xz) failed with exit code '1'
With
EXTRA_IMAGECMD:squashfs-xz:append = " -processors 64 -b 262144 -Xdict-size 100% -Xbcj arm" I get
| DEBUG: Executing shell function do_image_squashfs_xz | oe_mksquashfs params: | xz -processors 64 -b 262144 -Xdict-size 100% -Xbcj arm | WARNING: exit code 2 from a shell command. | /home/jmbills/upstream-sync/openbmc-openbmc/build/tmp/work/intel_ast2600-openbmc-linux-gnueabi/intel-platforms/1.0/temp/run.do_image_squashfs_xz.37665: 159: local: 64: bad variable name
ERROR: Task (/home/jmbills/upstream-sync/openbmc-openbmc/openbmc-meta-intel/meta-common/recipes-intel/images/intel-platforms.bb:do_image_squashfs_xz) failed with exit code '1'
Thanks again for all your help!
-Jason
Quoted 6 lines
The issue is fixed if I change this line:
local extra_imagecmd="$@"
to this:
local extra_imagecmd="$*"
I also found that the issue is fixed if I wrap my appended parameters in single quotes. This is my new append:
EXTRA_IMAGECMD:squashfs-xz:append = " '-processors 64 -b 262144 -Xdict-size 100% -Xbcj arm'"