Sourcing a shell script within a bbclass


Elvis Dowson
 

Hi,
      How can I source a shell script within a bbclass? For example, in meta-xilinx/classes/xilinx-boot.bbclass, I need to source a script file called settings64.sh, which setups the environment variables for the Xilinx ISE 14.1 design tools, in order to generate a system ace image file.

For the following code snippet:

if   [ "${XILINX_VER}" \> "14" ]; then
bbnote "XILINX_VER ${XILINX_VER}, script location ${XILINX_LOC}/${EDK_SCRIPT}"
source ${XILINX_LOC}/${EDK_SCRIPT} ${XILINX_LOC}
fi

I get the following error:

DEBUG: Executing python function sstate_task_prefunc
DEBUG: Python function sstate_task_prefunc finished
DEBUG: Executing shell function do_deploy
ERROR: Function failed: do_deploy (see /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/log.do_deploy.15616 for further information)
NOTE: Deploying uboot elf image to /project/xilinx-ml507
NOTE: Xilinx design tools installed in /tool/xilinx/14.1/ISE_DS
NOTE: Generate system ace image
NOTE: EDK_SCRIPT settings64.sh
NOTE: XILINX_VER 14.1, script location /tool/xilinx/14.1/ISE_DS/settings64.sh
/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.15616: 129: /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.15616: source: not found

if I replace the source keyword with a . (dot) 

if   [ "${XILINX_VER}" \> "14" ]; then
bbnote "XILINX_VER ${XILINX_VER}, script location ${XILINX_LOC}/${EDK_SCRIPT}"
. ${XILINX_LOC}/${EDK_SCRIPT} ${XILINX_LOC}
fi

it executes the scripts but gives the following error:

NOTE: XILINX_VER 14.1, script location /tool/xilinx/14.1/ISE_DS/settings64.sh
/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.7879: 12: [: /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.7879: unexpected operator
. /tool/xilinx/14.1/ISE_DS/common/.settings64.sh /tool/xilinx/14.1/ISE_DS/common
. /tool/xilinx/14.1/ISE_DS/EDK/.settings64.sh /tool/xilinx/14.1/ISE_DS/EDK
. /tool/xilinx/14.1/ISE_DS/common/CodeSourcery/.settings64.sh /tool/xilinx/14.1/ISE_DS/common/CodeSourcery
. /tool/xilinx/14.1/ISE_DS/PlanAhead/.settings64.sh /tool/xilinx/14.1/ISE_DS/PlanAhead
. /tool/xilinx/14.1/ISE_DS/../../Vivado/2012.1/.settings64.sh /tool/xilinx/14.1/ISE_DS/../../Vivado/2012.1
. /tool/xilinx/14.1/ISE_DS/ISE/.settings64.sh /tool/xilinx/14.1/ISE_DS/ISE
. /tool/xilinx/14.1/ISE_DS/SysGen/.settings64.sh /tool/xilinx/14.1/ISE_DS/SysGen


What should I do to source the settings64.sh file properly within the bbclass?

Best regards,

Elvis Dowson


Elvis Dowson
 

Hi,

On Jun 24, 2012, at 6:24 PM, Elvis Dowson wrote:

How can I source a shell script within a bbclass? For example, in meta-xilinx/classes/xilinx-boot.bbclass, I need to source a script file called settings64.sh, which setups the environment variables for the Xilinx ISE 14.1 design tools, in order to generate a system ace image file.

For the following code snippet:

if   [ "${XILINX_VER}" \> "14" ]; then
bbnote "XILINX_VER ${XILINX_VER}, script location ${XILINX_LOC}/${EDK_SCRIPT}"
source ${XILINX_LOC}/${EDK_SCRIPT} ${XILINX_LOC}
fi

I get the following error:

DEBUG: Executing python function sstate_task_prefunc
DEBUG: Python function sstate_task_prefunc finished
DEBUG: Executing shell function do_deploy
ERROR: Function failed: do_deploy (see /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/log.do_deploy.15616 for further information)
NOTE: Deploying uboot elf image to /project/xilinx-ml507
NOTE: Xilinx design tools installed in /tool/xilinx/14.1/ISE_DS
NOTE: Generate system ace image
NOTE: EDK_SCRIPT settings64.sh
NOTE: XILINX_VER 14.1, script location /tool/xilinx/14.1/ISE_DS/settings64.sh
/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.15616: 129: /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.15616: source: not found

if I replace the source keyword with a . (dot) 

if   [ "${XILINX_VER}" \> "14" ]; then
bbnote "XILINX_VER ${XILINX_VER}, script location ${XILINX_LOC}/${EDK_SCRIPT}"
. ${XILINX_LOC}/${EDK_SCRIPT} ${XILINX_LOC}
fi

it executes the scripts but gives the following error:

NOTE: XILINX_VER 14.1, script location /tool/xilinx/14.1/ISE_DS/settings64.sh
/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.7879: 12: [: /tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.7879: unexpected operator
. /tool/xilinx/14.1/ISE_DS/common/.settings64.sh /tool/xilinx/14.1/ISE_DS/common
. /tool/xilinx/14.1/ISE_DS/EDK/.settings64.sh /tool/xilinx/14.1/ISE_DS/EDK
. /tool/xilinx/14.1/ISE_DS/common/CodeSourcery/.settings64.sh /tool/xilinx/14.1/ISE_DS/common/CodeSourcery
. /tool/xilinx/14.1/ISE_DS/PlanAhead/.settings64.sh /tool/xilinx/14.1/ISE_DS/PlanAhead
. /tool/xilinx/14.1/ISE_DS/../../Vivado/2012.1/.settings64.sh /tool/xilinx/14.1/ISE_DS/../../Vivado/2012.1
. /tool/xilinx/14.1/ISE_DS/ISE/.settings64.sh /tool/xilinx/14.1/ISE_DS/ISE
. /tool/xilinx/14.1/ISE_DS/SysGen/.settings64.sh /tool/xilinx/14.1/ISE_DS/SysGen


What should I do to source the settings64.sh file properly within the bbclass?


The problem was because of Ubuntu 12.04 shell being configured by default to use dash, instead of bash. 

After I reconfigured the shell to use bash using the command:

$ sudo dpkg-reconfigure dash

everything works fine. However, Yocto 1.2 defaults or assumes that the user will use dash. 

Is there anyway I can fix this issue, so that the bbclass works for both dash and bash. Using the . (dot) to source the script doesn't seem to work, so I was wondering if there are any other workarounds that I can use to emulate bash's sourcing behaviour in dash.

Best regards,

Elvis Dowson



McClintock Matthew-B29882 <B29882@...>
 

On Sun, Jun 24, 2012 at 10:20 AM, Elvis Dowson <elvis.dowson@...> wrote:
Hi,

On Jun 24, 2012, at 6:24 PM, Elvis Dowson wrote:

How can I source a shell script within a bbclass? For example, in
meta-xilinx/classes/xilinx-boot.bbclass, I need to source a script file
called settings64.sh, which setups the environment variables for the Xilinx
ISE 14.1 design tools, in order to generate a system ace image file.

For the following code snippet:

if   [ "${XILINX_VER}" \> "14" ]; then
bbnote "XILINX_VER ${XILINX_VER}, script location
${XILINX_LOC}/${EDK_SCRIPT}"
source ${XILINX_LOC}/${EDK_SCRIPT} ${XILINX_LOC}
fi
ubuntu likes the . operator

. ${XILINX_LOC}/${EDK_SCRIPT} ${XILINX_LOC}
-M


I get the following error:

DEBUG: Executing python function sstate_task_prefunc
DEBUG: Python function sstate_task_prefunc finished
DEBUG: Executing shell function do_deploy
ERROR: Function failed: do_deploy (see
/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/log.do_deploy.15616
for further information)
NOTE: Deploying uboot elf image to /project/xilinx-ml507
NOTE: Xilinx design tools installed in /tool/xilinx/14.1/ISE_DS
NOTE: Generate system ace image
NOTE: EDK_SCRIPT settings64.sh
NOTE: XILINX_VER 14.1, script location
/tool/xilinx/14.1/ISE_DS/settings64.sh
/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.15616:
129:
/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.15616:
source: not found

if I replace the source keyword with a . (dot)

if   [ "${XILINX_VER}" \> "14" ]; then
bbnote "XILINX_VER ${XILINX_VER}, script location
${XILINX_LOC}/${EDK_SCRIPT}"
. ${XILINX_LOC}/${EDK_SCRIPT} ${XILINX_LOC}
fi

it executes the scripts but gives the following error:

NOTE: XILINX_VER 14.1, script location
/tool/xilinx/14.1/ISE_DS/settings64.sh
/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.7879:
12: [:
/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.7879:
unexpected operator
. /tool/xilinx/14.1/ISE_DS/common/.settings64.sh
/tool/xilinx/14.1/ISE_DS/common
. /tool/xilinx/14.1/ISE_DS/EDK/.settings64.sh /tool/xilinx/14.1/ISE_DS/EDK
. /tool/xilinx/14.1/ISE_DS/common/CodeSourcery/.settings64.sh
/tool/xilinx/14.1/ISE_DS/common/CodeSourcery
. /tool/xilinx/14.1/ISE_DS/PlanAhead/.settings64.sh
/tool/xilinx/14.1/ISE_DS/PlanAhead
. /tool/xilinx/14.1/ISE_DS/../../Vivado/2012.1/.settings64.sh
/tool/xilinx/14.1/ISE_DS/../../Vivado/2012.1
. /tool/xilinx/14.1/ISE_DS/ISE/.settings64.sh /tool/xilinx/14.1/ISE_DS/ISE
. /tool/xilinx/14.1/ISE_DS/SysGen/.settings64.sh
/tool/xilinx/14.1/ISE_DS/SysGen


What should I do to source the settings64.sh file properly within the
bbclass?


The problem was because of Ubuntu 12.04 shell being configured by default to
use dash, instead of bash.

After I reconfigured the shell to use bash using the command:

$ sudo dpkg-reconfigure dash

everything works fine. However, Yocto 1.2 defaults or assumes that the user
will use dash.

Is there anyway I can fix this issue, so that the bbclass works for both
dash and bash. Using the . (dot) to source the script doesn't seem to work,
so I was wondering if there are any other workarounds that I can use to
emulate bash's sourcing behaviour in dash.

Best regards,

Elvis Dowson



_______________________________________________
yocto mailing list
yocto@...
https://lists.yoctoproject.org/listinfo/yocto


Elvis Dowson
 

Hi,

On Jun 25, 2012, at 7:10 PM, McClintock Matthew-B29882 wrote:


For the following code snippet:

if [ "${XILINX_VER}" \> "14" ]; then
bbnote "XILINX_VER ${XILINX_VER}, script location
${XILINX_LOC}/${EDK_SCRIPT}"
source ${XILINX_LOC}/${EDK_SCRIPT} ${XILINX_LOC}
fi
ubuntu likes the . operator

. ${XILINX_LOC}/${EDK_SCRIPT} ${XILINX_LOC}
-M

if I replace the source keyword with a . (dot)

if [ "${XILINX_VER}" \> "14" ]; then
bbnote "XILINX_VER ${XILINX_VER}, script location
${XILINX_LOC}/${EDK_SCRIPT}"
. ${XILINX_LOC}/${EDK_SCRIPT} ${XILINX_LOC}
fi

it executes the scripts but gives the following error:

NOTE: XILINX_VER 14.1, script location
/tool/xilinx/14.1/ISE_DS/settings64.sh
/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.7879:
12: [:
/tool/yocto/poky/build/tmp/work/ppc440-poky-linux/u-boot-xilinx-v2012.04.01-r16/temp/run.do_deploy.7879:
unexpected operator
. /tool/xilinx/14.1/ISE_DS/common/.settings64.sh
/tool/xilinx/14.1/ISE_DS/common
. /tool/xilinx/14.1/ISE_DS/EDK/.settings64.sh /tool/xilinx/14.1/ISE_DS/EDK
. /tool/xilinx/14.1/ISE_DS/common/CodeSourcery/.settings64.sh
/tool/xilinx/14.1/ISE_DS/common/CodeSourcery
. /tool/xilinx/14.1/ISE_DS/PlanAhead/.settings64.sh
/tool/xilinx/14.1/ISE_DS/PlanAhead
. /tool/xilinx/14.1/ISE_DS/../../Vivado/2012.1/.settings64.sh
/tool/xilinx/14.1/ISE_DS/../../Vivado/2012.1
. /tool/xilinx/14.1/ISE_DS/ISE/.settings64.sh /tool/xilinx/14.1/ISE_DS/ISE
. /tool/xilinx/14.1/ISE_DS/SysGen/.settings64.sh
/tool/xilinx/14.1/ISE_DS/SysGen
As you can see, I tried the . (dot) operator. The settings64.sh script from Xilinx, when run stand-alone runs perfectly fine in Dash, so I don't think there is any bashism there. The problem is with the yocto build system I think, because it gives a unexpected error message as show above.

Best regards,

Elvis Dowson