[yocto] Sourcing a shell script within a bbclass

Elvis Dowson elvis.dowson at gmail.com
Sun Jun 24 08:20:49 PDT 2012


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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20120624/2a552556/attachment.html>


More information about the yocto mailing list