[meta-oe] pcapplusplus: add new recipe

Message ID 20220217144533.23247-1-ceggers@arri.de
State New
Headers show
Series [meta-oe] pcapplusplus: add new recipe | expand

Commit Message

Christian Eggers Feb. 17, 2022, 2:45 p.m. UTC
"A multiplatform C++ library for capturing, parsing and crafting of
network packets"

PcapPlusPlus uses as custom build system (shell script + Makefile).
There were attempts for using cmake but this work has never been
finished.

Signed-off-by: Christian Eggers <ceggers@arri.de>
---
 .../pcapplusplus/pcapplusplus_21.11.bb        | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb

Comments

Clément Péron Feb. 19, 2022, 9:05 a.m. UTC | #1
Hi Christian,

On Thu, 17 Feb 2022 at 15:45, Christian Eggers <ceggers@arri.de> wrote:
>
> "A multiplatform C++ library for capturing, parsing and crafting of
> network packets"
>
> PcapPlusPlus uses as custom build system (shell script + Makefile).
> There were attempts for using cmake but this work has never been
> finished.

Work is still ongoing by me
(https://github.com/seladb/PcapPlusPlus/pull/652), Review and help is
welcome :)

>
> Signed-off-by: Christian Eggers <ceggers@arri.de>
> ---
>  .../pcapplusplus/pcapplusplus_21.11.bb        | 40 +++++++++++++++++++
>  1 file changed, 40 insertions(+)
>  create mode 100644 meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
>
> diff --git a/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
> new file mode 100644
> index 000000000000..0d2f83cf4af7
> --- /dev/null
> +++ b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
> @@ -0,0 +1,40 @@
> +SUMMARY = "A multiplatform C++ library for capturing, parsing and crafting of network packets"
> +HOMEPAGE = "https://pcapplusplus.github.io/"
> +BUGTRACKER = "https://github.com/seladb/PcapPlusPlus/issues"
> +SECTION = "libs/network"
> +LICENSE = "Unlicense"
> +LIC_FILES_CHKSUM = "file://LICENSE;md5=911690f51af322440237a253d695d19f"
> +
> +DEPENDS = "libpcap"
> +
> +SRC_URI = "git://github.com/seladb/PcapPlusPlus.git;protocol=https;branch=master"
> +SRCREV = "ddce58723a4ef7ab19bf1507e6323990b4d2d15e"
> +
> +S = "${WORKDIR}/git"
> +
> +EXTRA_CONF:libc-musl += "--musl"
I think there is one fix required to build musl
https://github.com/seladb/PcapPlusPlus/commit/0607f5ccb7a26bc1567908507e46603e7c16b1ac

> +# PcapPlusPlus uses a custom shell script for configuration
> +do_configure () {
> +    # must use the --default switch only if no other switches are set
> +    mkdir -p "${D}${prefix}"
> +    ./configure-linux.sh --install-dir "${D}${prefix}" ${EXTRA_CONF}
> +}
> +
> +do_compile () {
> +    # build only libs
> +    oe_runmake libs
> +}
> +
> +do_install () {
> +    # install script uses PKG_CONFIG_PATH as destination path for .pc files
> +    export PKG_CONFIG_PATH="${D}${libdir}/pkgconfig"
> +    oe_runmake install
> +    # remove example makefile
> +    rm -rf "${D}${prefix}/etc"
> +    # remove ${D} in .pc file
> +    sed -i "s@${D}@@g" ${D}${libdir}/pkgconfig/*.pc
> +    chown -R root:root ${D}${libdir}/pkgconfig/*.pc
> +}
> +
> +# main package is empty
> +RDEPENDS:${PN}-dev = ""

Why not use ALLOW_EMPTY here ?

> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#95358): https://lists.openembedded.org/g/openembedded-devel/message/95358
> Mute This Topic: https://lists.openembedded.org/mt/89210336/4240582
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [peron.clem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Khem Raj Feb. 19, 2022, 6:24 p.m. UTC | #2
On Sat, Feb 19, 2022 at 1:05 AM Clément Péron <peron.clem@gmail.com> wrote:
>
> Hi Christian,
>
> On Thu, 17 Feb 2022 at 15:45, Christian Eggers <ceggers@arri.de> wrote:
> >
> > "A multiplatform C++ library for capturing, parsing and crafting of
> > network packets"
> >
> > PcapPlusPlus uses as custom build system (shell script + Makefile).
> > There were attempts for using cmake but this work has never been
> > finished.
>
> Work is still ongoing by me
> (https://github.com/seladb/PcapPlusPlus/pull/652), Review and help is
> welcome :)

this fails on riscv32 which has 64bit time_t on by default unlike
older 32bit architectures
see
https://errors.yoctoproject.org/Errors/Details/629829/

>
> >
> > Signed-off-by: Christian Eggers <ceggers@arri.de>
> > ---
> >  .../pcapplusplus/pcapplusplus_21.11.bb        | 40 +++++++++++++++++++
> >  1 file changed, 40 insertions(+)
> >  create mode 100644 meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
> >
> > diff --git a/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
> > new file mode 100644
> > index 000000000000..0d2f83cf4af7
> > --- /dev/null
> > +++ b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
> > @@ -0,0 +1,40 @@
> > +SUMMARY = "A multiplatform C++ library for capturing, parsing and crafting of network packets"
> > +HOMEPAGE = "https://pcapplusplus.github.io/"
> > +BUGTRACKER = "https://github.com/seladb/PcapPlusPlus/issues"
> > +SECTION = "libs/network"
> > +LICENSE = "Unlicense"
> > +LIC_FILES_CHKSUM = "file://LICENSE;md5=911690f51af322440237a253d695d19f"
> > +
> > +DEPENDS = "libpcap"
> > +
> > +SRC_URI = "git://github.com/seladb/PcapPlusPlus.git;protocol=https;branch=master"
> > +SRCREV = "ddce58723a4ef7ab19bf1507e6323990b4d2d15e"
> > +
> > +S = "${WORKDIR}/git"
> > +
> > +EXTRA_CONF:libc-musl += "--musl"
> I think there is one fix required to build musl
> https://github.com/seladb/PcapPlusPlus/commit/0607f5ccb7a26bc1567908507e46603e7c16b1ac
>

additionally we should be using

EXTRA_CONF:append:libc-musl = " --musl"

> > +# PcapPlusPlus uses a custom shell script for configuration
> > +do_configure () {
> > +    # must use the --default switch only if no other switches are set
> > +    mkdir -p "${D}${prefix}"
> > +    ./configure-linux.sh --install-dir "${D}${prefix}" ${EXTRA_CONF}
> > +}
> > +
> > +do_compile () {
> > +    # build only libs
> > +    oe_runmake libs
> > +}
> > +
> > +do_install () {
> > +    # install script uses PKG_CONFIG_PATH as destination path for .pc files
> > +    export PKG_CONFIG_PATH="${D}${libdir}/pkgconfig"
> > +    oe_runmake install
> > +    # remove example makefile
> > +    rm -rf "${D}${prefix}/etc"
> > +    # remove ${D} in .pc file
> > +    sed -i "s@${D}@@g" ${D}${libdir}/pkgconfig/*.pc
> > +    chown -R root:root ${D}${libdir}/pkgconfig/*.pc
> > +}
> > +
> > +# main package is empty
> > +RDEPENDS:${PN}-dev = ""
>
> Why not use ALLOW_EMPTY here ?

lesser of two evils.

>
> > --
> > 2.34.1
> >
> >
> >
> >
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#95390): https://lists.openembedded.org/g/openembedded-devel/message/95390
> Mute This Topic: https://lists.openembedded.org/mt/89210336/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Khem Raj Feb. 21, 2022, 4:59 a.m. UTC | #3
it seems to suffer from build race as well see
https://autobuilder.yoctoproject.org/typhoon/#/builders/88/builds/1447

 DEBUG: Executing shell function do_compile
| NOTE: make -j 16 -l 52 libs
| ==== Building target: Common++ ====
| Building file: src/MacAddress.cpp
| Assembler messages:
| Fatal error: can't create Obj/MacAddress.o: No such file or
directory
| make[1]: *** [Makefile:51: Obj/MacAddress.o] Error 2
| make: *** [Makefile:91: libs] Error 2
| ERROR: oe_runmake failed

On Thu, Feb 17, 2022 at 6:45 AM Christian Eggers <ceggers@arri.de> wrote:
>
> "A multiplatform C++ library for capturing, parsing and crafting of
> network packets"
>
> PcapPlusPlus uses as custom build system (shell script + Makefile).
> There were attempts for using cmake but this work has never been
> finished.
>
> Signed-off-by: Christian Eggers <ceggers@arri.de>
> ---
>  .../pcapplusplus/pcapplusplus_21.11.bb        | 40 +++++++++++++++++++
>  1 file changed, 40 insertions(+)
>  create mode 100644 meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
>
> diff --git a/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
> new file mode 100644
> index 000000000000..0d2f83cf4af7
> --- /dev/null
> +++ b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
> @@ -0,0 +1,40 @@
> +SUMMARY = "A multiplatform C++ library for capturing, parsing and crafting of network packets"
> +HOMEPAGE = "https://pcapplusplus.github.io/"
> +BUGTRACKER = "https://github.com/seladb/PcapPlusPlus/issues"
> +SECTION = "libs/network"
> +LICENSE = "Unlicense"
> +LIC_FILES_CHKSUM = "file://LICENSE;md5=911690f51af322440237a253d695d19f"
> +
> +DEPENDS = "libpcap"
> +
> +SRC_URI = "git://github.com/seladb/PcapPlusPlus.git;protocol=https;branch=master"
> +SRCREV = "ddce58723a4ef7ab19bf1507e6323990b4d2d15e"
> +
> +S = "${WORKDIR}/git"
> +
> +EXTRA_CONF:libc-musl += "--musl"
> +# PcapPlusPlus uses a custom shell script for configuration
> +do_configure () {
> +    # must use the --default switch only if no other switches are set
> +    mkdir -p "${D}${prefix}"
> +    ./configure-linux.sh --install-dir "${D}${prefix}" ${EXTRA_CONF}
> +}
> +
> +do_compile () {
> +    # build only libs
> +    oe_runmake libs
> +}
> +
> +do_install () {
> +    # install script uses PKG_CONFIG_PATH as destination path for .pc files
> +    export PKG_CONFIG_PATH="${D}${libdir}/pkgconfig"
> +    oe_runmake install
> +    # remove example makefile
> +    rm -rf "${D}${prefix}/etc"
> +    # remove ${D} in .pc file
> +    sed -i "s@${D}@@g" ${D}${libdir}/pkgconfig/*.pc
> +    chown -R root:root ${D}${libdir}/pkgconfig/*.pc
> +}
> +
> +# main package is empty
> +RDEPENDS:${PN}-dev = ""
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#95358): https://lists.openembedded.org/g/openembedded-devel/message/95358
> Mute This Topic: https://lists.openembedded.org/mt/89210336/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Christian Eggers Feb. 21, 2022, 11:24 a.m. UTC | #4
On Saturday, 19 February 2022, 19:24:37 CET, Khem Raj wrote:
> On Sat, Feb 19, 2022 at 1:05 AM Clément Péron <peron.clem@gmail.com> wrote:
> >
> > Hi Christian,
> >
> > On Thu, 17 Feb 2022 at 15:45, Christian Eggers <ceggers@arri.de> wrote:
> > >
> > > "A multiplatform C++ library for capturing, parsing and crafting of
> > > network packets"
> > >
> > > PcapPlusPlus uses as custom build system (shell script + Makefile).
> > > There were attempts for using cmake but this work has never been
> > > finished.
> >
> > Work is still ongoing by me
> > (https://github.com/seladb/PcapPlusPlus/pull/652), Review and help is
> > welcome :)
> 
> this fails on riscv32 which has 64bit time_t on by default unlike
> older 32bit architectures
> see
> https://errors.yoctoproject.org/Errors/Details/629829/

I see the same problem locally on 32 bit ARM/musl, but only as a warning,
not as an error.

The C++ code converts from from struct timeval to struct timespec:
https://github.com/seladb/PcapPlusPlus/blob/master/Pcap%2B%2B/src/NetworkUtils.cpp#L172

struct timeval uses 'suseconds_t' for tv_usec which is _Int64 on musl, while
struct timespec uses 'long' for tv_nsec.

1. I think that conversion from useconds to nseconds requires multiplication with 1000.
2. Is there any problem casting from 'suseconds_t' to 'long'? I guess that nanoseconds
cannot exceed 32 bit.

> > > +
> > > +EXTRA_CONF:libc-musl += "--musl"
> > I think there is one fix required to build musl
> > https://github.com/seladb/PcapPlusPlus/commit/0607f5ccb7a26bc1567908507e46603e7c16b1ac
> >
> 
> additionally we should be using
> 
> EXTRA_CONF:append:libc-musl = " --musl"

From bitbake user manual:
> These operators differ from the ":=", ".=", "=.", "+=", and "=+" operators in that their effects are applied at variable expansion time rather than being immediately applied.

What is the reason for using override style here?

> > > +# main package is empty
> > > +RDEPENDS:${PN}-dev = ""
> >
> > Why not use ALLOW_EMPTY here ?
> 
> lesser of two evils.

RDEPENDS:${PN}-dev = "" is used several times in oe-core / meta-openembedded. Some
comments show that this is for the same reason (empty main package). Would it be
useful to covert some/all occurrences?

Patch

diff --git a/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
new file mode 100644
index 000000000000..0d2f83cf4af7
--- /dev/null
+++ b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
@@ -0,0 +1,40 @@ 
+SUMMARY = "A multiplatform C++ library for capturing, parsing and crafting of network packets"
+HOMEPAGE = "https://pcapplusplus.github.io/"
+BUGTRACKER = "https://github.com/seladb/PcapPlusPlus/issues"
+SECTION = "libs/network"
+LICENSE = "Unlicense"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=911690f51af322440237a253d695d19f"
+
+DEPENDS = "libpcap"
+
+SRC_URI = "git://github.com/seladb/PcapPlusPlus.git;protocol=https;branch=master"
+SRCREV = "ddce58723a4ef7ab19bf1507e6323990b4d2d15e"
+
+S = "${WORKDIR}/git"
+
+EXTRA_CONF:libc-musl += "--musl"
+# PcapPlusPlus uses a custom shell script for configuration
+do_configure () {
+    # must use the --default switch only if no other switches are set
+    mkdir -p "${D}${prefix}"
+    ./configure-linux.sh --install-dir "${D}${prefix}" ${EXTRA_CONF}
+}
+
+do_compile () {
+    # build only libs
+    oe_runmake libs
+}
+
+do_install () {
+    # install script uses PKG_CONFIG_PATH as destination path for .pc files
+    export PKG_CONFIG_PATH="${D}${libdir}/pkgconfig"
+    oe_runmake install
+    # remove example makefile
+    rm -rf "${D}${prefix}/etc"
+    # remove ${D} in .pc file
+    sed -i "s@${D}@@g" ${D}${libdir}/pkgconfig/*.pc
+    chown -R root:root ${D}${libdir}/pkgconfig/*.pc
+}
+
+# main package is empty
+RDEPENDS:${PN}-dev = ""