環境:
Red Hat Enterprise Linux Server release 7.5 (Maipo)
git version 1.8.3.1
Python 2.7.6
tar (GNU tar) 1.26
操作步驟:
git clone git://git.yoctoproject.org/poky
cd poky/
source oe-init-build-env
bitbake core-image-minimal 報錯:
Traceback (most recent call last):
File "/var/fpwork/alice/poky/bitbake/bin/bitbake", line 31, in <module>
import bb
File "/var/fpwork/alice/poky/bitbake/lib/bb/__init__.py", line 77, in <module>
import bb.msg
File "/var/fpwork/alice/poky/bitbake/lib/bb/msg.py", line 32, in <module>
import bb.event
File "/var/fpwork/alice/poky/bitbake/lib/bb/event.py", line 35, in <module>
import bb.utils
File "/var/fpwork/alice/poky/bitbake/lib/bb/utils.py", line 37, in <module>
from commands import getstatusoutput
ImportError: cannot import name getstatusoutput
檢查並重新配置python環境, 重新執行core-image-minimal target,執行成功:
$ python -V
Python 2.7.5
$ unset PYTHONPATH
$ export PATH="${PATH}:/build/ltesdkroot/Tools/Tools/python/python-3.3.2/bin/"
$ export PATH=/build/ltesdkroot/Tools/Tools/7za/7za-9.20/:$PATH
$ export PATH=/build/ltesdkroot/Tools/Tools/python/python-2.7.6/bin/:$PATH
$ source oe-init-build-env
$ bitbake core-image-minimal
創建新的recipe:
嘗試創建空的myapp.bb,報錯:
$ mkdir meta/recipes-devtools/myapp
$ touch meta/recipes-devtools/myapp/myapp.bb
$ bitbake myapp
WARNING: Host distribution "RedHatEnterpriseLinuxServer-7.5" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |############################################################################################################################################################################| ETA: 00:00:00
Loaded 1309 entries from dependency cache.
ERROR: /var/fpwork/alice/poky/meta/recipes-devtools/myapp/myapp.bb: This recipe does not have the LICENSE field set (myapp) | ETA: --:--:--
ERROR: Failed to parse recipe: /var/fpwork/alice/poky/meta/recipes-devtools/myapp/myapp.bb
Summary: There was 1 WARNING message shown.
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
配置license,參考https://www.yoctoproject.org/docs/latest/ref-manual/ref-manual.html#var-LICENSE:
增加 LICENSE =
"CLOSED"到myapp.bb,重新build myapp:
$ bitbake myapp
WARNING: Host distribution "RedHatEnterpriseLinuxServer-7.5" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |############################################################################################################################################################################| ETA: 00:00:00
Loaded 1309 entries from dependency cache.
Parsing recipes: 100% |##########################################################################################################################################################################| Time: 00:00:00
Parsing of 879 .bb files complete (878 cached, 1 parsed). 1309 targets, 49 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.30.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "i586-poky-linux"
MACHINE = "qemux86"
DISTRO = "poky"
DISTRO_VERSION = "2.1.3"
TUNE_FEATURES = "m32 i586"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "krogoth:73cc31c11a9d75a2f4204a9a8c6832c6e505a86a"
troubleshooting = "master:fb9516fe7061768493165386ea29c8b631d3bfb1"
NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 379 tasks of which 366 didn't need to be rerun and all succeeded.
Summary: There was 1 WARNING message shown.
設置SRC_URI和SRCREV,嘗試bitbake myapp,看do_fetch 任務是否執行,無報錯:
SRC_URI = "git://gerrite1.ext.net.nokia.com/p/yoctoscm/hello.git;protocol=https"
SRCREV = "7b470517d1a53a2fffa800edf0341e11fa9a8385"
增加如下內容,看do_compile任務是否執行:
${CXX} source.cpp
$ bitbake myapp
WARNING: Host distribution "RedHatEnterpriseLinuxServer-7.5" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |############################################################################################################################################################################| ETA: 00:00:00
Loaded 1310 entries from dependency cache.
ERROR: ParseError at /var/fpwork/alice/poky/meta/recipes-devtools/myapp/myapp.bb:7: unparsed line: '${CXX} source.cpp' | ETA: --:--:--
Summary: There was 1 WARNING message shown.
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
增加do_compile()方法,報錯:
do_compile(){
${CXX} source.cpp
}
$ bitbake myapp
WARNING: Host distribution "RedHatEnterpriseLinuxServer-7.5" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |############################################################################################################################################################################| ETA: 00:00:00
Loaded 1310 entries from dependency cache.
Parsing recipes: 100% |##########################################################################################################################################################################| Time: 00:00:00
Parsing of 879 .bb files complete (878 cached, 1 parsed). 1309 targets, 49 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.30.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "i586-poky-linux"
MACHINE = "qemux86"
DISTRO = "poky"
DISTRO_VERSION = "2.1.3"
TUNE_FEATURES = "m32 i586"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "krogoth:73cc31c11a9d75a2f4204a9a8c6832c6e505a86a"
troubleshooting = "master:fb9516fe7061768493165386ea29c8b631d3bfb1"
NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: myapp-1.0-r0 do_compile: Function failed: do_compile (log file is located at /var/fpwork/alice/poky/build/tmp/work/i586-poky-linux/myapp/1.0-r0/temp/log.do_compile.36714)
ERROR: Logfile of failure stored in: /var/fpwork/alice/poky/build/tmp/work/i586-poky-linux/myapp/1.0-r0/temp/log.do_compile.36714
Log data follows:
| DEBUG: Executing shell function do_compile
| i586-poky-linux-g++: error: source.cpp: No such file or directory
| i586-poky-linux-g++: fatal error: no input files
| compilation terminated.
| WARNING: /var/fpwork/alice/poky/build/tmp/work/i586-poky-linux/myapp/1.0-r0/temp/run.do_compile.36714:1 exit 1 from 'i586-poky-linux-g++ -m32 -march=i586 --sysroot=/var/fpwork/alice/poky/build/tmp/sysroots/qemux86 source.cpp'
| ERROR: Function failed: do_compile (log file is located at /var/fpwork/alice/poky/build/tmp/work/i586-poky-linux/myapp/1.0-r0/temp/log.do_compile.36714)
ERROR: Task 6 (/var/fpwork/alice/poky/meta/recipes-devtools/myapp/myapp.bb, do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 372 tasks of which 368 didn't need to be rerun and 1 failed.
No currently running tasks (372 of 379)
Summary: 1 task failed:
/var/fpwork/alice/poky/meta/recipes-devtools/myapp/myapp.bb, do_compile
Summary: There was 1 WARNING message shown.
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
增加S =
"${WORKDIR}/git",即可:
LICENSE = "CLOSED"
SRC_URI = "git://gerrite1.ext.net.nokia.com/p/yoctoscm/hello.git;protocol=https"
SRCREV = "7b470517d1a53a2fffa800edf0341e11fa9a8385"
S = "${WORKDIR}/git"
do_compile(){
${CXX} source.cpp
}
$ bitbake myapp
WARNING: Host distribution "RedHatEnterpriseLinuxServer-7.5" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |############################################################################################################################################################################| ETA: 00:00:00
Loaded 1310 entries from dependency cache.
Parsing recipes: 100% |##########################################################################################################################################################################| Time: 00:00:00
Parsing of 879 .bb files complete (878 cached, 1 parsed). 1309 targets, 49 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.30.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "i586-poky-linux"
MACHINE = "qemux86"
DISTRO = "poky"
DISTRO_VERSION = "2.1.3"
TUNE_FEATURES = "m32 i586"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "krogoth:73cc31c11a9d75a2f4204a9a8c6832c6e505a86a"
troubleshooting = "master:fb9516fe7061768493165386ea29c8b631d3bfb1"
NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 379 tasks of which 367 didn't need to be rerun and all succeeded.
Summary: There was 1 WARNING message shown.
使用-c參數,指定執行compile任務:
$ bitbake myapp -c compile
WARNING: Host distribution "RedHatEnterpriseLinuxServer-7.5" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |############################################################################################################################################################################| ETA: 00:00:00
Loaded 1310 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.30.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "i586-poky-linux"
MACHINE = "qemux86"
DISTRO = "poky"
DISTRO_VERSION = "2.1.3"
TUNE_FEATURES = "m32 i586"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "krogoth:73cc31c11a9d75a2f4204a9a8c6832c6e505a86a"
troubleshooting = "master:fb9516fe7061768493165386ea29c8b631d3bfb1"
NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 219 tasks of which 215 didn't need to be rerun and all succeeded.
Summary: There was 1 WARNING message shown.
增加do_install 任務,bitbake myapp -c compile 執行:
do_install(){
install -d ${D}/${bindir}
}
安裝在tmp/work/目錄:
$ find tmp/work -name myapp*
tmp/work/i586-poky-linux/myapp
tmp/work/i586-poky-linux/myapp/1.0-r0/packages-split/myapp-dbg
tmp/work/i586-poky-linux/myapp/1.0-r0/packages-split/myapp-staticdev
tmp/work/i586-poky-linux/myapp/1.0-r0/packages-split/myapp-dev
tmp/work/i586-poky-linux/myapp/1.0-r0/packages-split/myapp-doc
tmp/work/i586-poky-linux/myapp/1.0-r0/packages-split/myapp-locale
tmp/work/i586-poky-linux/myapp/1.0-r0/packages-split/myapp
tmp/work/i586-poky-linux/myapp/1.0-r0/myapp.spec
tmp/work/i586-poky-linux/myapp/1.0-r0/myapp-1.0
tmp/work/i586-poky-linux/myapp/1.0-r0/sysroot-destdir/sysroot-providers/myapp
tmp/work/i586-poky-linux/myapp/1.0-r0/license-destdir/myapp
tmp/work/i586-poky-linux/myapp/1.0-r0/deploy-rpms/i586/myapp-dbg-1.0-r0.i586.rpm
tmp/work/i586-poky-linux/myapp/1.0-r0/deploy-rpms/i586/myapp-dev-1.0-r0.i586.rpm
tmp/work/i586-poky-linux/myapp/1.0-r0/pkgdata/runtime/myapp-dbg
tmp/work/i586-poky-linux/myapp/1.0-r0/pkgdata/runtime/myapp-dbg.packaged
tmp/work/i586-poky-linux/myapp/1.0-r0/pkgdata/runtime/myapp-staticdev
tmp/work/i586-poky-linux/myapp/1.0-r0/pkgdata/runtime/myapp-dev
tmp/work/i586-poky-linux/myapp/1.0-r0/pkgdata/runtime/myapp-dev.packaged
tmp/work/i586-poky-linux/myapp/1.0-r0/pkgdata/runtime/myapp-doc
tmp/work/i586-poky-linux/myapp/1.0-r0/pkgdata/runtime/myapp-locale
tmp/work/i586-poky-linux/myapp/1.0-r0/pkgdata/runtime/myapp
tmp/work/i586-poky-linux/myapp/1.0-r0/pkgdata/runtime-reverse/myapp-dev
tmp/work/i586-poky-linux/myapp/1.0-r0/pkgdata/runtime-reverse/myapp-dbg
tmp/work/i586-poky-linux/myapp/1.0-r0/pkgdata/myapp
執行bitbake myapp,則myapp相關的 ipk (or rpm) packages在tmp/deploy目錄:
$ find tmp/deploy/ -name myapp*
tmp/deploy/licenses/myapp
tmp/deploy/rpm/i586/myapp-dbg-1.0-r0.i586.rpm
tmp/deploy/rpm/i586/myapp-dev-1.0-r0.i586.rpm