20170620_jeffrey - silenceuncrio/diary GitHub Wiki

0910

參考 [meta-networking,1/3] keepalived: add new recipe

meta-networking-1-3-keepalived-add-new-recipe.patch

diff --git a/meta-networking/recipes-daemons/keepalived/keepalived_1.3.5.bb b/meta-networking/recipes-daemons/keepalived/keepalived_1.3.5.bb
new file mode 100644
index 000000000..5e7e6e49f
--- /dev/null
+++ b/meta-networking/recipes-daemons/keepalived/keepalived_1.3.5.bb
@@ -0,0 +1,49 @@
+SUMMARY = "High Availability monitor built upon LVS, VRRP and service pollers"
+DESCRIPTION = "Keepalived is a routing software written in C. The main goal \
+of this project is to provide simple and robust facilities for loadbalancing \
+and high-availability to Linux system and Linux based infrastructures. \
+Loadbalancing framework relies on well-known and widely used Linux Virtual \
+Server (IPVS) kernel module providing Layer4 loadbalancing \
+"
+HOMEPAGE = "http://www.keepalived.org/"
+
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
+
+SRC_URI = "http://www.keepalived.org/software/${BP}.tar.gz"
+
+SRC_URI[md5sum] = "9964d295ec9d34ed3408b57d28847b68"
+SRC_URI[sha256sum] = "c0114d86ea4c896557beb0d9367819a423ffba772bc5d7c548dc455e6b3bd048"
+
+DEPENDS = "libnfnetlink openssl"
+
+inherit autotools pkgconfig systemd update-rc.d
+
+PACKAGECONFIG ??= "libnl snmp \
+    ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
+"
+PACKAGECONFIG[libnl] = "--enable-libnl,--disable-libnl,libnl"
+PACKAGECONFIG[snmp] = "--enable-snmp,--disable-snmp,net-snmp"
+PACKAGECONFIG[systemd] = "--with-init=systemd --with-systemdsystemunitdir=${systemd_system_unitdir},--with-init=SYSV,systemd"
+
+EXTRA_OECONF = "--disable-libiptc"
+EXTRA_OEMAKE = "initdir=${sysconfdir}/init.d"
+
+do_install_append() {
+    if [ -f ${D}${sysconfdir}/init.d/${BPN} ]; then
+        chmod 0755 ${D}${sysconfdir}/init.d/${BPN}
+        sed -i 's#rc.d/##' ${D}${sysconfdir}/init.d/${BPN}
+    fi
+
+    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
+        install -D -m 0644 ${B}/${BPN}/${BPN}.service ${D}${systemd_system_unitdir}/${BPN}.service
+    fi
+}
+
+FILES_${PN} += "${datadir}/snmp/mibs/KEEPALIVED-MIB.txt"
+
+INITSCRIPT_NAME = "keepalived"
+INITSCRIPT_PARAMS = "remove"
+
+SYSTEMD_SERVICE_${PN} = "keepalived.service"
+SYSTEMD_AUTO_ENABLE ?= "disable"

該 patch 做的事只有單純的新增一個 keepalived recipe

  • meta-networking/recipes-daemons/keepalived/keepalived_1.3.5.bb
SUMMARY = "High Availability monitor built upon LVS, VRRP and service pollers"
DESCRIPTION = "Keepalived is a routing software written in C. The main goal \
of this project is to provide simple and robust facilities for loadbalancing \
and high-availability to Linux system and Linux based infrastructures. \
Loadbalancing framework relies on well-known and widely used Linux Virtual \
Server (IPVS) kernel module providing Layer4 loadbalancing \
"
HOMEPAGE = "http://www.keepalived.org/"

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

SRC_URI = "http://www.keepalived.org/software/${BP}.tar.gz"

SRC_URI[md5sum] = "9964d295ec9d34ed3408b57d28847b68"
SRC_URI[sha256sum] = "c0114d86ea4c896557beb0d9367819a423ffba772bc5d7c548dc455e6b3bd048"

DEPENDS = "libnfnetlink openssl"

inherit autotools pkgconfig systemd update-rc.d

PACKAGECONFIG ??= "libnl snmp \
    ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
"
PACKAGECONFIG[libnl] = "--enable-libnl,--disable-libnl,libnl"
PACKAGECONFIG[snmp] = "--enable-snmp,--disable-snmp,net-snmp"
PACKAGECONFIG[systemd] = "--with-init=systemd --with-systemdsystemunitdir=${systemd_system_unitdir},--with-init=SYSV,systemd"

EXTRA_OECONF = "--disable-libiptc"
EXTRA_OEMAKE = "initdir=${sysconfdir}/init.d"

do_install_append() {
    if [ -f ${D}${sysconfdir}/init.d/${BPN} ]; then
        chmod 0755 ${D}${sysconfdir}/init.d/${BPN}
        sed -i 's#rc.d/##' ${D}${sysconfdir}/init.d/${BPN}
    fi

    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
        install -D -m 0644 ${B}/${BPN}/${BPN}.service ${D}${systemd_system_unitdir}/${BPN}.service
    fi
}

FILES_${PN} += "${datadir}/snmp/mibs/KEEPALIVED-MIB.txt"

INITSCRIPT_NAME = "keepalived"
INITSCRIPT_PARAMS = "remove"

SYSTEMD_SERVICE_${PN} = "keepalived.service"
SYSTEMD_AUTO_ENABLE ?= "disable"

0940

之前參考同仁寫的 meta-proscend/recipes-extended/keepalived/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 ac_cv_func_realloc_0_nonnull=yes ac_cv_func_malloc_0_nonnull=yes
}

do_compile() {
    oe_runmake
}

do_install() {
    install -d ${D}${sbindir}
    install -m 755 ${S}/bin/keepalived ${D}${sbindir}
}

直接套新的吧

source bimage 時出現以下錯誤

ERROR: ExpansionError during parsing /var/m300/meta-proscend/recipes-extended/keepalived/keepalived_1.3.5.bb: Failure expanding variable PACKAGECONFIG, expression was libnl snmp     ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}  which triggered exception AttributeError: 'module' object has no attribute 'filter'

Summary: There was 1 ERROR message shown, returning a non-zero exit code.

1010

先幫忙 ariel 處理一下 簡訊裡 unicode 的問題

放棄剛剛 keepalived_1.3.5.bb 的修改

切到 branch develop

pull 最新的 code - 包含 ariel 的修改

1040

compile 花了一些時間

先把從 ariel 那邊借得有 SIM 卡的 M300 upgrade 成我自己 local 的 code 吧

1140

參考 How do I decode a string with escaped unicode? 解決了 ariel 的困擾

上 code

commit b627706363b0b1ef1bd58d8e01557706aa7f8657                                                        
Refs: [develop], {origin/develop}                                                                      
Author: jeffrey <[email protected]>                                                                 
Date:   Tue Jun 20 11:50:05 2017 +0800                                                                 

    Convert the escaped unicode sms message back to normal

 proscend/prosrc/www/app/feature/alarm.js | 22 ++++++++++++++++++++++                                  
 1 file changed, 22 insertions(+)

1155

切回 branch feature/vrrp

1300

試著解析一下 [meta-networking,1/3] keepalived: add new recipe 提供的 keepalived_1.3.5.bb

SUMMARY = "High Availability monitor built upon LVS, VRRP and service pollers"
DESCRIPTION = "Keepalived is a routing software written in C. The main goal \
of this project is to provide simple and robust facilities for loadbalancing \
and high-availability to Linux system and Linux based infrastructures. \
Loadbalancing framework relies on well-known and widely used Linux Virtual \
Server (IPVS) kernel module providing Layer4 loadbalancing \
"
HOMEPAGE = "http://www.keepalived.org/"

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

SRC_URI = "http://www.keepalived.org/software/${BP}.tar.gz"

SRC_URI[md5sum] = "9964d295ec9d34ed3408b57d28847b68"
SRC_URI[sha256sum] = "c0114d86ea4c896557beb0d9367819a423ffba772bc5d7c548dc455e6b3bd048"

DEPENDS = "libnfnetlink openssl"

inherit autotools pkgconfig systemd update-rc.d

PACKAGECONFIG ??= "libnl snmp \
    ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
"
PACKAGECONFIG[libnl] = "--enable-libnl,--disable-libnl,libnl"
PACKAGECONFIG[snmp] = "--enable-snmp,--disable-snmp,net-snmp"
PACKAGECONFIG[systemd] = "--with-init=systemd --with-systemdsystemunitdir=${systemd_system_unitdir},--with-init=SYSV,systemd"

EXTRA_OECONF = "--disable-libiptc"
EXTRA_OEMAKE = "initdir=${sysconfdir}/init.d"

do_install_append() {
    if [ -f ${D}${sysconfdir}/init.d/${BPN} ]; then
        chmod 0755 ${D}${sysconfdir}/init.d/${BPN}
        sed -i 's#rc.d/##' ${D}${sysconfdir}/init.d/${BPN}
    fi

    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
        install -D -m 0644 ${B}/${BPN}/${BPN}.service ${D}${systemd_system_unitdir}/${BPN}.service
    fi
}

FILES_${PN} += "${datadir}/snmp/mibs/KEEPALIVED-MIB.txt"

INITSCRIPT_NAME = "keepalived"
INITSCRIPT_PARAMS = "remove"

SYSTEMD_SERVICE_${PN} = "keepalived.service"
SYSTEMD_AUTO_ENABLE ?= "disable"

看看該如何來解決 source bimage 時出現的錯誤

ERROR: ExpansionError during parsing /var/m300/meta-proscend/recipes-extended/keepalived/keepalived_1.3.5.bb: Failure expanding variable PACKAGECONFIG, expression was libnl snmp     ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}  which triggered exception AttributeError: 'module' object has no attribute 'filter'

Summary: There was 1 ERROR message shown, returning a non-zero exit code.
SUMMARY = "High Availability monitor built upon LVS, VRRP and service pollers"
DESCRIPTION = "Keepalived is a routing software written in C. The main goal \
of this project is to provide simple and robust facilities for loadbalancing \
and high-availability to Linux system and Linux based infrastructures. \
Loadbalancing framework relies on well-known and widely used Linux Virtual \
Server (IPVS) kernel module providing Layer4 loadbalancing \
"

SUMMARY

The short (72 characters or less) summary of the binary package for packaging systems such as opkg, rpm or dpkg. By default, SUMMARY is used to define the DESCRIPTION variable if DESCRIPTION is not set in the recipe.

HOMEPAGE = "http://www.keepalived.org/"

HOMEPAGE

Website where more information about the software the recipe is building can be found.

LICENSE = "GPLv2"

LICENSE - mega-manual / var-LICENSE

The list of source licenses for the recipe.

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

LIC_FILES_CHKSUM - mega-manual / var-LIC_FILES_CHKSUM

Checksums of the license text in the recipe source code.

SRC_URI = "http://www.keepalived.org/software/${BP}.tar.gz"

SRC_URI - mega-manual / var-SRC_URI

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.

這邊 ${BP} 的解釋如下

The base recipe name and version but without any special package name suffix.

在 recipe name 為 keepalived_1.3.5.bb 的情況下

${BP}keepalived_1.3.5

也就是 SRC_URI = "http://www.keepalived.org/software/keepalived_1.3.5.tar.gz"

利用 http://www.keepalived.org/software 便可看到列表了

SRC_URI[md5sum] = "9964d295ec9d34ed3408b57d28847b68"
SRC_URI[sha256sum] = "c0114d86ea4c896557beb0d9367819a423ffba772bc5d7c548dc455e6b3bd048"

mega-manual / new-recipe-fetching-code 提到

If your SRC_URI statement includes URLs pointing to individual files fetched from a remote server other than a version control system, BitBake attempts to verify the files against checksums defined in your recipe to ensure they have not been tampered with or otherwise modified since the recipe was written. Two checksums are used: SRC_URI[md5sum] and SRC_URI[sha256sum].

DEPENDS = "libnfnetlink openssl"

DEPENDS - mega-manual / var-DEPENDS

Lists a recipe's build-time dependencies.

inherit autotools pkgconfig systemd update-rc.d

inherit - mega-manual / var-INHERIT

PACKAGECONFIG ??= "libnl snmp \
    ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
"

PACKAGECONFIG - mega-manual / var-PACKAGECONFIG

這就是錯誤出現的地方

ERROR: ExpansionError during parsing /var/m300/meta-proscend/recipes-extended/keepalived/keepalived_1.3.5.bb: Failure expanding variable PACKAGECONFIG, expression was libnl snmp     ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}  which triggered exception AttributeError: 'module' object has no attribute 'filter'

Summary: There was 1 ERROR message shown, returning a non-zero exit code.

這著字面上來看的話其實發生錯誤的是 bb.utils.filter('DISTRO_FEATURES', 'systemd', d) 這個敘述

1350

aaron 表示他之前在寫 strongswan recipe 也有遇過類似的問題 參考下述兩個 strongswan recipe 的差別

strongswan_5.5.1.bb

PACKAGECONFIG ??= "charon curl gmp openssl stroke sqlite3 \
        ${@bb.utils.filter('DISTRO_FEATURES', 'ldap', d)} \
"
PACKAGECONFIG[aesni] = "--enable-aesni,--disable-aesni,,${PN}-plugin-aesni"
PACKAGECONFIG[charon] = "--enable-charon,--disable-charon,"
PACKAGECONFIG[curl] = "--enable-curl,--disable-curl,curl,${PN}-plugin-curl"
PACKAGECONFIG[gmp] = "--enable-gmp,--disable-gmp,gmp,${PN}-plugin-gmp"
PACKAGECONFIG[ldap] = "--enable-ldap,--disable-ldap,openldap,${PN}-plugin-ldap"
PACKAGECONFIG[mysql] = "--enable-mysql,--disable-mysql,mysql5,${PN}-plugin-mysql"
PACKAGECONFIG[openssl] = "--enable-openssl,--disable-openssl,openssl,${PN}-plugin-openssl"
PACKAGECONFIG[scep] = "--enable-scepclient,--disable-scepclient,"
PACKAGECONFIG[soup] = "--enable-soup,--disable-soup,libsoup-2.4,${PN}-plugin-soup"
PACKAGECONFIG[sqlite3] = "--enable-sqlite,--disable-sqlite,sqlite3,${PN}-plugin-sqlite"
PACKAGECONFIG[stroke] = "--enable-stroke,--disable-stroke,,${PN}-plugin-stroke"
PACKAGECONFIG[swanctl] = "--enable-swanctl,--disable-swanctl,,libgcc"

strongswan_5.5.0.bb

PACKAGECONFIG ??= "charon curl gmp openssl stroke sqlite3 \
        ${@bb.utils.contains('DISTRO_FEATURES', 'ldap', 'ldap', '', d)} \
"
PACKAGECONFIG[aesni] = "--enable-aesni,--disable-aesni,"
PACKAGECONFIG[charon] = "--enable-charon,--disable-charon,"
PACKAGECONFIG[curl] = "--enable-curl,--disable-curl,curl,"
PACKAGECONFIG[gmp] = "--enable-gmp,--disable-gmp,gmp,"
PACKAGECONFIG[ldap] = "--enable-ldap,--disable-ldap,openldap,"
PACKAGECONFIG[mysql] = "--enable-mysql,--disable-mysql,mysql5,"
PACKAGECONFIG[openssl] = "--enable-openssl,--disable-openssl,openssl,"
PACKAGECONFIG[scep] = "--enable-scepclient,--disable-scepclient,"
PACKAGECONFIG[soup] = "--enable-soup,--disable-soup,libsoup-2.4,"
PACKAGECONFIG[sqlite3] = "--enable-sqlite,--disable-sqlite,sqlite3,"
PACKAGECONFIG[stroke] = "--enable-stroke,--disable-stroke,"
PACKAGECONFIG[swanctl] = "--enable-swanctl,--disable-swanctl,,libgcc"

keepalived_1.3.5.bbPACKAGECONFIG

PACKAGECONFIG ??= "libnl snmp \
    ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
"

修正成

PACKAGECONFIG ??= "libnl snmp \
    ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
"

得到的 keepalived_1.3.5.bb 如下

SUMMARY = "High Availability monitor built upon LVS, VRRP and service pollers"
DESCRIPTION = "Keepalived is a routing software written in C. The main goal \
of this project is to provide simple and robust facilities for loadbalancing \
and high-availability to Linux system and Linux based infrastructures. \
Loadbalancing framework relies on well-known and widely used Linux Virtual \
Server (IPVS) kernel module providing Layer4 loadbalancing \
"
HOMEPAGE = "http://www.keepalived.org/"

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

SRC_URI = "http://www.keepalived.org/software/${BP}.tar.gz"

SRC_URI[md5sum] = "9964d295ec9d34ed3408b57d28847b68"
SRC_URI[sha256sum] = "c0114d86ea4c896557beb0d9367819a423ffba772bc5d7c548dc455e6b3bd048"

DEPENDS = "libnfnetlink openssl"

inherit autotools pkgconfig systemd update-rc.d

PACKAGECONFIG ??= "libnl snmp \
    ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
"
PACKAGECONFIG[libnl] = "--enable-libnl,--disable-libnl,libnl"
PACKAGECONFIG[snmp] = "--enable-snmp,--disable-snmp,net-snmp"
PACKAGECONFIG[systemd] = "--with-init=systemd --with-systemdsystemunitdir=${systemd_system_unitdir},--with-init=SYSV,systemd"

EXTRA_OECONF = "--disable-libiptc"
EXTRA_OEMAKE = "initdir=${sysconfdir}/init.d"

do_install_append() {
    if [ -f ${D}${sysconfdir}/init.d/${BPN} ]; then
        chmod 0755 ${D}${sysconfdir}/init.d/${BPN}
        sed -i 's#rc.d/##' ${D}${sysconfdir}/init.d/${BPN}
    fi

    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
        install -D -m 0644 ${B}/${BPN}/${BPN}.service ${D}${systemd_system_unitdir}/${BPN}.service
    fi
}

FILES_${PN} += "${datadir}/snmp/mibs/KEEPALIVED-MIB.txt"

INITSCRIPT_NAME = "keepalived"
INITSCRIPT_PARAMS = "remove"

SYSTEMD_SERVICE_${PN} = "keepalived.service"
SYSTEMD_AUTO_ENABLE ?= "disable"

1400

這次產生的錯誤如下

| ERROR: oe_runconf failed
| ERROR: Function failed: do_configure (log file is located at /var/m300/build_small/tmp/work/cortexa7hf-vfp-neon-poky-linux-gnueabi/keepalived/1.3.5-r0/temp/log.do_configure.28776)
ERROR: Task 1406 (/var/m300/meta-proscend/recipes-extended/keepalived/keepalived_1.3.5.bb, do_configure) failed with exit code '1'

1710

還好有 aaron 的幫忙

參考 [meta-networking,1/3] keepalived: add new recipe 得到的 keepalived_1.3.5.bb 還需要把 bb.utils.filter 修正成 bb.utils.contains 的寫法

另外還要搭配一支 keepalived_1.3.5.bbappend

PACKAGECONFIG_remove = "snmp"

do_install_append() {
  rm -rf ${D}/usr/share/snmp
}

PACKAGECONFIG_remove = "snmp" 可以解決 do_configure() 失敗的問題

do_install_append() 做的 rm -rf ${D}/usr/share/snmp 可以解決下述的 ERROR: QA Issue

ERROR: QA Issue: keepalived: Files/directories were installed but not shipped in any package:
  /usr/share/snmp
  /usr/share/snmp/mibs
Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installi
ng them or delete them within do_install.
keepalived: 2 installed and not shipped files. [installed-vs-shipped]

upgrade 這次的 firmware 試試