天天看點

poky:一些筆記

轉載來自:http://blog.csdn.net/xiaofeng_yan/article/details/6757725

1 當你已經編完一個系統比如sato映像,在編一個meta-toolchain的映像如何重用已經下載下傳的源碼。

  修改build/local.conf變量

  DL_DIR=<source 的路徑>

2 如果你用ctl+c中斷了編譯過程,在重新編譯的時候poky可能出現了一些問題。你個以這樣做來避免出現問題。

  PC$rm -rf tmp/cache/default-glibc

  PC$rm -rf tmp/stamps/出現問題的包

3 增加編譯的速度

  如果你是多核的計算機修改build/local.conf變量

  BB_NUMBER_THREADS = "4" 或 “2”

  PARALLEL_MAKE = "-j 4" 或 “-j 2”

4 TOPDIR=poky/build

5 git更新本地檔案

  git checkout -f

  git clone git://git.pokylinux.org/poky.git

  cd poky/

  git remote add contrib git://git.pokylinux.org/poky-contrib.git

  git remote update

  git branch -r | grep 'xf/distro'

  git push [email protected]:poky-contrib.git contrbute-xiaofeng.yan:xiaofeng/distro

  git commit --amend --author='Xiaofeng Yan <[email protected]>'

  ./create-pull-request -r origin/master -b xiaofeng/distro

   send-pull-request -t [email protected] -a -p pull-29801

  git checkout branch-->切換分支

 git

6 -sh: source: poky-init-build-env: file not found

  可能目前的使用者環境有問題。這是可以換一個使用者。但不是根使用者。應該不是bash環境,詳細請看/etc/passwd,看看是用那個shell

7 CLFLAGS_append = "-fPIC"

  如果要給gcc添加參數,可以用這個變量追加。

8 為什麼檔案的後面要加入這個變量BBCLASSEXTEND = "native"

  在解壓源碼包的時候出現了兩個檔案。而程式會進入隻有patchs的目錄下。

  這個不知道是什麼原因?有待調查。

  這是因為在命名.bb檔案的時候,一定按下列方式進行。例如:

  man-1.5.bb(錯)

  man_1.5.bb(對)

  命名方式:名字_版本.bb

9 如果在編譯的過程中要使用root使用者怎麼辦呢?

   在方法的前面加fakeroot

   例如:

   fakeroot do_configure(){

   }

10 fakeroot: FAKEROOTKEY set to 1844291688

  fakeroot: nested operation not yet supported

  上述的錯誤是因為如果在.bb 檔案中使用了fakeroot的和環境,那麼你就不能在單獨的指令用fakeroot

  例如:

   fakeroot do_configure(){

   }

   do_compile(){

    fakeroot make -f Makefile //因為do_configure使用了fakeroot那麼這裡再用fakeroot就有問題了。正确的使用方法如下

   }  

   fakeroot do_dompile(){

    make -f Makefile

   }

11  .bb檔案的文法

   do_configure (){

   }//正确的使用方法

   do_configure ()

   {

   }//錯誤的使用方法

12 如何在poky的環境下打更新檔

   file://XXX.patch;patch=1  這種方法好像對傳統的patch行不通。有待調查。

   可以用這種方式用以前的方式打patch

   do_configure_prepend() {

                patch -p0 < ${WORKDIR}/man-1.5k-confpath.patch

                patch -p1 < ${WORKDIR}/man-1.5h1-make.patch

}

13 do_configure 方法可能和bitbake預設的不一樣,具體差異有待調查。

14 如何列印環境變量

   環境變量隻有在compile和install階段在能夠通過echo指令在螢幕上輸出。

   如果想在其他階段看環境變量的值可以用下面的方法:例如

   do_configure (){

           ${S}/configure

           echo ${S} > 1.log

           echo ${D} >> 1.log

}

PC$bitbake PACKAGENAME -c devshell

devshell$vim 1.log

/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4

/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/image

15 如何開各個過程具體過程以及bb檔案隐含的變量值和預設的 build過程。

   看build/tmp/work/arch/package/temp/run.do_*的其中一個檔案有詳細的說明。

16 貌似函數與函數之間要有一行空行。

17 通常修改的是packages/tasks裡的一個描述任務的bb檔案。

你可以通過

bitbake -g 映像名稱

生成映像的依賴關系。然後在生成的depends.dot中找到映像依賴packages/tasks目錄的哪些bb檔案。然後在這些bb檔案中找一個合适的位置加入your_bb。

假設映像依賴task-base.bb,你隻要在task-base.bb中的

RDEPENDS_task-base = "\

下增加一行your_bb就可以了。

當然最好找一個與要增加的package比較相近的bb檔案和任務。例如在poky中我在task-poky.bb

RDEPENDS_task-poky-apps-x11-core = "\

中增加我的package。

假設你修改了task-base.bb,隻要重新bitbake 這個bb檔案再bitbake 映像就可以了。

18 如何在bb檔案中使用bash程式設計

   例如:

pkg_postinst_dpkg () {

#!/bin/sh

if [ "x$D" != "x" ]; then

        install -d $D/${sysconfdir}/rcS.d

        # this happens at S98 where our good 'ole packages script used to run

        echo -e "#!/bin/sh

        dpkg --configure -a

        rm -f /${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}configure

" > ${IMAGE_ROOTFS}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}configure

        chmod 0755 $D/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}configure

fi

}

19  變量指派和引号:

    所有的變量指派時,内容要用雙引号括起來。(如果不用可能現在能工作,但後面就不一定能工作

    了)

        VAR1 = "${OTHERVAR}"

        VAR2 = "The version is ${PV}"

20  變量值追加(有空格):+=

    你可以給已經有值的變量使用符号“+=”追加一個值。注意這個操作會在原值和你追加的值中間添

    上空格:

        SRC_URI += "file://fix-makefile.patch;patch=1"       

變量值前加:=+

    你可以給已有值的變量内容前面加上一個值,使用符号"=+".注意這個操作會在原值和你追加的值中間添

    上空格:

        VAR =+ "Starts"

變量值追加:_append方式

    你可以使用_append方式來給一個已經存在的變量追加值,跟+=不一樣的是這種方式不會在原值和

    你要追加的值中間加上空格。下面的例子中自己添上了空格,這樣就不會跟原來的值直接合在一起。

        SRC_URI_append = " file://fix-makefile.patch;patch=1"

    _append方式也可以用來覆寫某個值,但是僅僅是在指定目标機器和平台的時候有用:

        SRC_URI_append_sh4 = " file://fix-makefile.patch;patch=1"

    你可以把追加符了解為變量自己本身。是以+=和=+符号可以和_append一起來使用,比如:

    SRC_URI_append = " file://fix-makefile.patch;patch=1"

    SRC_URI_append += "file://fix-install.patch;patch=1"

變量值前加:_prepend 方式

    使用_prepend在已有的變量前面加上一個值。和_apend一樣,這裡_prepend和=+的差別就是沒有

    空格。

    例如:CFLAGS_prepend = "-I${S}/myincludes "

    同樣在指定機器名的時候_prepend也是覆寫的意思。如:

        CFLAGS_prepend_sh4 = " file://fix-makefile.patch;patch=1"

    同樣_prepend也可以和+=,=+一起來使用,例如:

        CFLAGS_prepend = "-I${S}/myincludes "

        CFLAGS_prepend += "-I${S}/myincludes2 "

空格和制表符

    縮進應該使用空格,而不是制表符。是以說現在制表符也可以工作,但是OE隻是承諾過支援空格。

代碼風格:oe-stylize.py

    為了幫助你在“配方“中使用正确的(譯者注:标準的可能更合适些)格式,oe在contrib目錄裡

    提供了一個oe-stylize.py腳本,使用它你可以把你的“配方”格式化成标準的格式.運作腳本的

    時候會輸出一些警告資訊,你需要手動把這些删除.

        contrib/oe-stylize.py myrecipe.bb > fixed-recipe.bb

        vi fixed-recipe.bb

        mv fixed.recipe.bb myrecipe.bb

使用python的進階操作:${@...}

    為了擷取更進階的功能,你可以使用python語句,比如變量替換和搜尋。

    Python語句在聲明變量之前要添加@符号。

        CXXFLAGS := "${@'${CXXFLAGS}'.replace('-frename-registers', '')}"

21 sysroot目錄是存放中間過程的頭檔案和庫等。用于其他包編譯所需的依賴。

22 The BBCLASSEXTEND = "native" says this package can be built both as a native host package, as well as a target package.

23 PC$bitbake man-pages

    ......

Log data follows:

| NOTE: make -e MAKEFLAGS=

| mkdir not_installed

| for i in man?/*; do \

|         if [ /usr/share/man/"$i" -nt "$i" ]; then \

|             cmp -s /usr/share/man/"$i" "$i">  /dev/null 2>&1; \

|             if [ "$?" != 0 ]; then mv "$i" not_installed; fi; \

|         fi; \

|     done

| for i in man?/*; do \

|         rm -f /usr/share/man/"$i" /usr/share/man/"$i".gz /usr/share/man/"$i".bz2; \

|     done

| rm: cannot remove `/usr/share/man/man1/intro.1.gz': Permission denied

| rm: cannot remove `/usr/share/man/man1/ldd.1.gz': Permission denied

| rm: cannot remove `/usr/share/man/man1/time.1.gz': Permission denied

| rm: cannot remove `/usr/share/man/man2/_Exit.2.gz': Permission denied

| rm: cannot remove `/usr/share/man/man2/__clone2.2.gz': Permission denied

| rm: cannot remove `/usr/share/man/man2/_exit.2.gz': Permission denied

   ......

解決辦法是增加了MANDIR

do_compile() {

        oe_runmake -f Makefile DESTDIR=${D} MANDIR=${D}${mandir}

}

24 有這樣的問題:

do_configure (){

        ${S}/configure

}

do_compile (){

        oe_runmake -f Makefile mandir=${D}${mandir}

}

fakeroot do_install(){

        mkdir -p ${D}/usr/local/man/man1

        mkdir -p ${D}/usr/local/man/man5

        mkdir -p ${D}/usr/local/man/man7

        oe_runmake install DESTDIR=${D}

}

NOTE: make install DESTDIR=/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/image

make[1]: Entering directory `/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4'

make[2]: Entering directory `/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/src/include'

test -d /usr/local/man || /home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/mkinstalldirs /usr/local/man

test -d /usr/local/man/man1 || /home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/mkinstalldirs /usr/local/man/man1

mkdir /usr/local/man/man1

mkdir: cannot create directory `/usr/local/man/man1': Permission denied

make[2]: [install_man] Error 1 (ignored)

test -d /usr/local/man/man5 || /home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/mkinstalldirs /usr/local/man/man5

mkdir /usr/local/man/man5

mkdir: cannot create directory `/usr/local/man/man5': Permission denied

make[2]: [install_man] Error 1 (ignored)

test -d /usr/local/man/man7 || /home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/mkinstalldirs /usr/local/man/man7

mkdir /usr/local/man/man7

mkdir: cannot create directory `/usr/local/man/man7': Permission denied

make[2]: [install_man] Error 1 (ignored)

make[2]: Leaving directory `/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/src/include'

make[2]: Entering directory `/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/src/libs/libgroff'

make[2]: Leaving directory `/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/src/libs/libgroff'

make[2]: Entering directory `/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/src/libs/libdriver'

make[2]: Leaving directory `/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/src/libs/libdriver'

make[2]: Entering directory `/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/src/libs/libbib'

make[2]: Leaving directory `/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/src/libs/libbib'

make[2]: Entering directory `/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/src/roff/groff'

test -d /usr/local/bin || /home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/mkinstalldirs /usr/local/bin

rm -f /usr/local/bin/groff

/usr/bin/install -c groff /usr/local/bin/groff

/usr/bin/install: cannot create regular file `/usr/local/bin/groff': Permission denied

make[2]: *** [install_prog] Error 1

make[2]: Leaving directory `/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4/src/roff/groff'

make[1]: *** [src/roff/groff] Error 2

make[1]: Leaving directory `/home/yxfyanxiaofengyxf/mydata/poky/green-3.3/build/tmp/work/i586-poky-linux/groff-1.18.1.4-r0/groff-1.18.1.4'

make: *** [install] Error 2

FATAL: oe_runmake failed

ERROR: Function do_install failed

這個問題是這樣解決的

do_configure (){

        mkdir -p ${D}/usr/local

        ${S}/configure --prefix=${D}/usr/local

}

do_compile (){

        oe_runmake -f Makefile mandir=${D}${mandir}

}

fakeroot do_install(){

        mkdir -p ${D}/usr/local/man/man1

        mkdir -p ${D}/usr/local/man/man5

        mkdir -p ${D}/usr/local/man/man7

        oe_runmake install DESTDIR=${D}

}

25 ipk的包的形成是怎麼形成的,貌似自動install的好多檔案沒有打進ipk包中。不知道這個問題怎麼解決。

   目前暫時解決的辦法,${PN}-locale的包預設貌似沒有打進image中。如果想要把想要的東西打進image中可以 這樣做:

   FILES_${PN} += "${datadir}/locale"

26 下列是一些重要變量的值。

   ${datadir}=/usr/share

   ${sysconfdir}=/etc

   sharedstatedir = /com

   ${STAGING_DIR_HOST} = sysroot

   --host=${BUILD_SYS}

   TARGET_ARCH

27 如何定義自己的目錄變量

   PC$vim conf/bitbake.conf

   在合适的位置上添加自己的變量。

28 _prepend和_append注意家空格。

29 do_postinst_${PN}(){

    裝載後進行的動作,包的内容可用

   }

   do_preinst_${PN}(){

     裝載前進行的動作,包的内容不可用。

   }

   do_prerm_${PN}(){

     解除安裝前進行的動作,包的内容可用

   }

   do_postrm_${PN}(){

     解除安裝後進行的動作,包的内容不可用。

   }

30 對于patch問題,貌似隻有在

    PC$bitbake packagename -c devshell

   PC$quilt new xxx.patch

   PC$quilt add file

   PC$quilt refresh

  這樣形成的patch,才能夠先這樣運用

  file://xxx.patch;patch=1

  其他隻能用do_configure_prepend(){}中實作。

31 doc locale 形成的ipk包貌似不會預設打入image.這個開關在哪裡還需調查。

32 如何用gcc的參數定義一個宏的字元串

   gcc -DVAR='"hello"'

   注意單雙引号的用法,先單好在雙号。

33  EXTRA_OEMAKE = "CC='${CC}'"有時候在編譯的過程中會出現錯誤。可以用這個選項。

34 a patch line would be changed from:

file://some.patch;patch=1;pnum=2

to:

file://some.patch;striplevel=2

and a patch line:

file://another.diff;patch=1;pnum=1

could be changed to:

file://another.diff

35 ${HOST_ARCH}表示目前的體系結構 ${BUILD_ARCH}

36 LIC_FILES_CHKSUM = "file://README;beginline=5;endline=29;md5=af80f631f3848bd0e9478df399015287"

   如何得到校驗和。

   将一個錯誤的校驗和放在md5=xxx

   在運作bitbake man-pages 的時候回報錯,并傳回一個正确的校驗值。

37 update-alternatives --install ${bindir}/last last last.${PN} 200

   這句話的意思是:先install last,然後mv last last.${PN},然後ln -s last.${PN} last. 200是優先級貌似越大優先級越高。

38 PARALLEL_MAKE = ""

   當你看到并行編譯的時候出現了問題,但是log裡卻沒有錯誤,可是又編譯不過去,那麼就用上面的變量加入PARALLEL_MAKE = "-j 1"不讓并行編譯。

39 如果在編譯的過程中,出現了這樣的提示;

   No rule to make target "aaa", needed by `bbb`. Stop

   一般出的問題是由于你的bbb 需要用到你的aaa, 而makefile中你的aaa的路徑是錯誤的。 把aaa的路徑修改為正确的路徑就OK了。

   還有一種可能就是在編譯bbb的時候需要 aaa,但是卻沒有aaa這個庫檔案。解決的辦法就是,就是先編譯這個庫檔案。

   do_compile_prepend(){

        if [ -d tools ];then

                make -C tools/gnulib/lib

        fi

   }

40 如果在連結清單中增加了包,比如在poky-iamge-lsb的情況下。

   你需要增加這些步驟

   PC#bitbake task-poky-lsb -c clean

   PC#bitbake poky-image-lsb -c clean

   PC#rm sstate-contorl/sstate-package-name

   PC#bitbake poky-image-lsb

41 放送patch

   1. install the msmtp

      PC#sudo apt-get install msmtp

   2. create the msmtp config file like

      PC#vim /home/yan/.msmtprc:

      tls on

      tls_certcheck off

      tls_starttls on

      port 25

      host prod-webmail.windriver.com

      from  [email protected]

      auth on

      user xyan

      password !yan1223

  3. You can double check if /usr/sbin/sendmail links to msmtp, If not, just link it

      PC# sudo ln -sf `which msmtp` /usr/sbin/sendmail

42 bitbake eglibc -e

   看打包時,eglibc裡的變量的值,比如PACKAGE

43   

bitbake -b qt-x11-free-native_3.3.5.bb -e | grep ^PROVIDES

bitbake -b qt-x11-free-native_3.3.5.bb -e | grep ^PN

44 提供者的錯誤解決。

NOTE: Resolving any missing task queue dependencies

ERROR: Nothing RPROVIDES 'gtk+-demo' (but /buildarea/yxf/poky.gtk_direectfb/meta/recipes-graphics/tasks/task-gtk-directfb.bb RDEPENDS on or otherwise requires it)

NOTE: Runtime target 'gtk+-demo' is unbuildable, removing...

Missing or unbuildable dependency chain was: ['gtk+-demo']

ERROR: Required build target 'core-image-gtk-directfb' has no buildable providers.

這個就是說,沒有找到gtk+-demo這個包的提供者。

$vi meta/recipes-gnome/gtk+/gtk+.inc

加入下面的語句

PACKAGES += "libgail gtk+-demo"

FILES_gtk+-demo = " \

        ${datadir}/gtk-2.0/demo/* \

        ${bindir}/gtk-demo \

        "

其實,bitbake提供者就是看PACKAGES裡定義的包的名字。