20170607_jeffrey - silenceuncrio/diary GitHub Wiki

0840

複習一下 monkeyjj 對於 laravel 的 study

1320

參考 20170518_jeffrey

先試著 compile 一份看看能不能在 M300 上 run

先利用 git flow feature 建立一個 vrrp 的 feature branch

➜  etc git:(develop) ✗ git flow feature start vrrp
Branches 'develop' and 'origin/develop' have diverged.
And local branch 'develop' is ahead of 'origin/develop'.
M       proscend/prosrc/webcgi/urlfilter.c
Switched to a new branch 'feature/vrrp'

Summary of actions:
- A new branch 'feature/vrrp' was created, based on 'develop'
- You are now on branch 'feature/vrrp'

Now, start committing on your feature. When done, use:

     git flow feature finish vrrp

➜  etc git:(feature/vrrp) ✗

因為目前 Yocto 並沒有現成的 Keepalived recipe

需要自行編寫 recipe

1340

參考公司 GitLab 上的 M300 的 Wiki

看看我怎麼來寫 vrrp recipe

This section lists variables that are required for recipes.

所以有必要了解這三個 variables

1505

LICENSE

The list of source licenses for the recipe. Follow these rules:

  • Do not use spaces within individual license names.
  • Separate license names using | (pipe) when there is a choice between licenses.
  • Separate license names using & (ampersand) when multiple licenses exist that cover different parts of the source.
  • You can use spaces between license names.
  • For standard licenses, use the names of the files in meta/files/common-licenses/ or the SPDXLICENSEMAP flag names defined in meta/conf/licenses.conf.

這邊說的 the names of the files in meta/files/common-licenses/ 如下

build@2f192722794e:/var/m300/sources/poky/meta/files/common-licenses$ ls
AAL              CC-BY-NC-ND-2.0  Elfutils-Exception                MIT          RPSL-1.0
AFL-1.2          CC-BY-NC-ND-2.5  Entessa                           MPL-1.0      RSCPL
AFL-2.0          CC-BY-NC-ND-3.0  ErlPL-1.1                         MPL-1.1      Ruby
AFL-2.1          CC-BY-NC-SA-1.0  FSF-Unlimited                     MPL-2.0      SAX-PD
AFL-3.0          CC-BY-NC-SA-2.0  Fair                              MS-PL        SGI-1
AGPL-3.0         CC-BY-NC-SA-2.5  Frameworx-1.0                     MS-RL        SMAIL_GPL
ANTLR-PD         CC-BY-NC-SA-3.0  FreeType                          MirOS        SPL-1.0
APL-1.0          CC-BY-ND-1.0     GFDL-1.1                          Motosoto     Simple-2.0
APSL-1.0         CC-BY-ND-2.0     GFDL-1.2                          Multics      Sleepycat
APSL-1.1         CC-BY-ND-2.5     GFDL-1.3                          NASA-1.3     SugarCRM-1
APSL-1.2         CC-BY-ND-3.0     GPL-1.0                           NCSA         SugarCRM-1.1.3
APSL-2.0         CC-BY-SA-1.0     GPL-2-with-bison-exception        NGPL         UCB
Adobe            CC-BY-SA-2.0     GPL-2.0                           NPOSL-3.0    VSL-1.0
Apache-1.0       CC-BY-SA-2.5     GPL-2.0-with-GCC-exception        NTP          W3C
Apache-1.1       CC-BY-SA-3.0     GPL-2.0-with-OpenSSL-exception    Nauman       WXwindows
Apache-2.0       CC0-1.0          GPL-2.0-with-autoconf-exception   Nokia        Watcom-1.0
Artistic-1.0     CDDL-1.0         GPL-2.0-with-classpath-exception  OASIS        XFree86-1.0
Artistic-2.0     CECILL-1.0       GPL-2.0-with-font-exception       OCLC-2.0     XFree86-1.1
BSD              CECILL-2.0       GPL-3.0                           ODbL-1.0     XSL
BSD-0-Clause     CECILL-B         GPL-3.0-with-GCC-exception        OFL-1.1      Xnet
BSD-2-Clause     CECILL-C         GPL-3.0-with-autoconf-exception   OGTSL        YPL-1.1
BSD-3-Clause     CPAL-1.0         HPND                              OLDAP-2.8    ZPL-1.1
BSD-4-Clause     CPL-1.0          ICU                               OSL-1.0      ZPL-2.0
BSL-1.0          CUA-OPL-1.0      IPA                               OSL-2.0      ZPL-2.1
BitstreamVera    ClArtistic       IPL-1.0                           OSL-3.0      Zimbra-1.3
CATOSL-1.1       DSSSL            ISC                               OpenSSL      Zlib
CC-BY-1.0        ECL-1.0          LGPL-2.0                          PD           bzip2
CC-BY-2.0        ECL-2.0          LGPL-2.1                          PHP-3.0      eCos-2.0
CC-BY-2.5        EDL-1.0          LGPL-3.0                          PostgreSQL   gSOAP-1
CC-BY-3.0        EFL-1.0          LPL-1.02                          Proprietary  gSOAP-1.3b
CC-BY-NC-1.0     EFL-2.0          LPPL-1.0                          Python-2.0   tcl
CC-BY-NC-2.0     EPL-1.0          LPPL-1.1                          QPL-1.0      unfs3
CC-BY-NC-2.5     EUDatagrid       LPPL-1.2                          RHeCos-1
CC-BY-NC-3.0     EUPL-1.0         LPPL-1.3c                         RHeCos-1.1
CC-BY-NC-ND-1.0  EUPL-1.1         Libpng                            RPL-1.5

參考 keepalived/COPYING

keepalived 這 source licenses for the recipe 為 GPL-2.0

在 recipe 的寫法為

LICENSE = "GPL-2.0"

1510

LIC_FILES_CHKSUM

Checksums of the license text in the recipe source code.

This variable tracks changes in license text of the source code files. If the license text is changed, it will trigger a build failure, which gives the developer an opportunity to review any license change.

This variable must be defined for all recipes (unless LICENSE is set to "CLOSED").

For more information, see the " Tracking License Changes" section.

都說是 Checksums of the license text

就拿 keepalived/COPYING 來用吧

利用 md5sum 計算一下載下來的 ChangeLog

➜  ~ md5sum COPYING
b234ee4d69f5fce4486a80fdaf4a4263  COPYING

在 recipe 的寫法為

LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"

1520

SRC_URI - used in recipes that fetch local or remote files.

The list of source files - local or remote. This variable tells the OpenEmbedded build system which bits to pull in for the build and how to pull them in. For example, if the recipe or append file only needs to fetch a tarball from the Internet, the recipe or append file uses a single SRC_URI entry. On the other hand, if the recipe or append file needs to fetch a tarball, apply two patches, and include a custom file, the recipe or append file would include four instances of the variable.

The following list explains the available URI protocols. URI protocols are highly dependent on particular BitBake Fetcher submodules. Depending on the fetcher BitBake uses, various URL parameters are employed. For specifics on the supported Fetchers, see the "Fetchers" section in the BitBake User Manual.

  • ...
  • git:// - Fetches files from a Git revision control repository.
  • ...

因為 keepalived 來自 github

所以繼續參考 BitBake User Manual 的相關文件

This fetcher submodule fetches code from the Git source control system. The fetcher works by creating a bare clone of the remote into GITDIR, which is usually DL_DIR/git2. This bare clone is then cloned into the work directory during the unpack stage when a specific tree is checked out. This is done using alternates and by reference to minimize the amount of duplicate data on the disk and make the unpack process fast. The executable used can be set with FETCHCMD_git.

This fetcher supports the following parameters:

  • "protocol": The protocol used to fetch the files. The default is "git" when a hostname is set. If a hostname is not set, the Git protocol is "file". You can also use "http", "https", "ssh" and "rsync".
  • ...
  • "rev": The revision to use for the checkout. The default is "master".
  • "tag": Specifies a tag to use for the checkout. To correctly resolve tags, BitBake must access the network. For that reason, tags are often not used. As far as Git is concerned, the "tag" parameter behaves effectively the same as the "rev" parameter.
  • ...

Here are some example URLs:
SRC_URI = "git://git.oe.handhelds.org/git/vip.git;tag=version-1"
SRC_URI = "git://git.oe.handhelds.org/git/vip.git;protocol=http"

在 recipe 的寫法為

SRC_URI = "git://github.com/acassen/keepalived.git;protocl=https;tag=v1.3.5"

1540

看來可以寫個簡單的 keepalived recipe 來玩玩看了 - keepalived_1.3.5.bb

➜  keepalived git:(feature/vrrp) ✗ pwd
/home/jeffrey/M300_git/M300/meta-proscend/recipes-extended/keepalived
➜  keepalived git:(feature/vrrp) ✗ cat keepalived_1.3.5.bb
LICENSE = "GPL-2.0"
LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
SRC_URI = "git://github.com/acassen/keepalived.git;protocl=https;tag=v1.3.5"

先用 bitbake keepalived 試試

build@2f192722794e:/var/m300/build_small$ bitbake keepalived
...
ERROR: Logfile of failure stored in: /var/m300/build_small/tmp/work/cortexa7hf-vfp-neon-poky-linux-gnueabi/keepali
ved/1.3.5-r0/temp/log.do_configure.1993
Log data follows:
...
| ERROR: Function failed: keepalived: LIC_FILES_CHKSUM points to an invalid file: /var/m300/build_small/tmp/work/c
ortexa7hf-vfp-neon-poky-linux-gnueabi/keepalived/1.3.5-r0/keepalived-1.3.5/COPYING
ERROR: Task 5 (/var/m300/meta-proscend/recipes-extended/keepalived/keepalived_1.3.5.bb, do_configure) failed with
exit code '1'
...

看來是 COPYING 這個 file 的位置錯了

修正如下

➜  keepalived git:(feature/vrrp) ✗ cat keepalived_1.3.5.bb
LICENSE = "GPL-2.0"
LIC_FILES_CHKSUM = "file://${WORKDIR}/git/COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
SRC_URI = "git://github.com/acassen/keepalived.git;protocl=https;tag=v1.3.5"

繼續

build@2f192722794e:/var/m300/build_small$ bitbake keepalived
...
NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 371 tasks of which 361 didn't need to be rerun and all succeeded.

看來是沒啥問題

1620

幫 keepalived_1.3.5.bb 加上 do_configure()do_compile()

➜  keepalived git:(feature/vrrp) ✗ cat keepalived_1.3.5.bb
LICENSE = "GPL-2.0"
LIC_FILES_CHKSUM = "file://${WORKDIR}/git/COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
SRC_URI = "git://github.com/acassen/keepalived.git;protocl=https;tag=v1.3.5"

S = "${WORKDIR}/git"

do_configure() {
    ${S}/configure --host=arm
}

do_compile() {
    oe_runmake
}

compile 時出現錯誤

${WORKDIR}/temp/log.do_compile

...
make[2]: Entering directory `/var/m300/build_small/tmp/work/cortexa7hf-vfp-neon-poky-linux-gnueabi/keepalived/1.3.5-r0/git/keepalived'
  CC       main.o
  CCLD     keepalived
vrrp/libvrrp.a(vrrp_iproute.o): In function `alloc_route':
/var/m300/build_small/tmp/work/cortexa7hf-vfp-neon-poky-linux-gnueabi/keepalived/1.3.5-r0/git/keepalived/vrrp/vrrp_iproute.c:1568: undefined reference to `rpl_malloc'
../lib/liblib.a(memory.o): In function `xalloc':
/var/m300/build_small/tmp/work/cortexa7hf-vfp-neon-poky-linux-gnueabi/keepalived/1.3.5-r0/git/lib/memory.c:56: undefined reference to `rpl_malloc'
../lib/liblib.a(vector.o): In function `vector_alloc_slot':
/var/m300/build_small/tmp/work/cortexa7hf-vfp-neon-poky-linux-gnueabi/keepalived/1.3.5-r0/git/lib/vector.c:96: undefined reference to `rpl_realloc'
collect2: error: ld returned 1 exit status
make[2]: *** [keepalived] Error 1
...

看來要花時間找出錯誤原因了

1630

回到 monkeyjj

1730

參考 iperf crosee compilier