Bug 273899 - net/libdnet: fix build
Summary: net/libdnet: fix build
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Muhammad Moinur Rahman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-17 12:51 UTC by Kristof Provost
Modified: 2023-09-21 02:11 UTC (History)
5 users (show)

See Also:
bugzilla: maintainer-feedback? (onatan)


Attachments
patch (3.23 KB, patch)
2023-09-17 12:51 UTC, Kristof Provost
no flags Details | Diff
patch (3.89 KB, patch)
2023-09-17 22:42 UTC, Kristof Provost
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kristof Provost freebsd_committer freebsd_triage 2023-09-17 12:51:30 UTC
Created attachment 244968 [details]
patch

pf removed several outdated ioctls (see https://lists.freebsd.org/archives/freebsd-pf/2023-April/000345.html among others for details), one of which libdnet relies on.

The attached patch makes it use libpfctl instead.
Comment 1 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2023-09-17 14:31:52 UTC
Will look into it tomorrow.
Comment 2 Mark Millard 2023-09-17 17:11:09 UTC
Kristof did not note here why he provided the port fix
for this specific port. It might be good to note here
and not just on the lists:

The kyua test suite for FreeBSD uses net/scapy (when installed)
and net/scapy in turn depends on net/libnet . This leads to
net/libnet being special by its being needed for (full) kyua
test suite testing of FreeBSD.
Comment 3 Mark Millard 2023-09-17 17:20:16 UTC
(In reply to Mark Millard from comment #2)

Dumb typos of mine that happen to match another port's name,
2 examples of needing the correction:

net/libnet -> net/libdnet
Comment 4 Mark Millard 2023-09-17 19:48:42 UTC
(In reply to Kristof Provost from comment #0)

I tried the patch after also adding:

# git -C /usr/ports/ diff net/libdnet
diff --git a/net/libdnet/Makefile b/net/libdnet/Makefile
index 63134d9f8b40..8d18411e2729 100644
--- a/net/libdnet/Makefile
+++ b/net/libdnet/Makefile
@@ -13,6 +13,8 @@ LICENSE_FILE= ${WRKSRC}/LICENSE
 
 USES?=         autoreconf libtool
 
+BUILD_DEPENDS= libpfctl>=0:net/libpfctl
+
 USE_GITHUB=    yes
 GH_ACCOUNT=    5u623l20


The poudriere-devel based build got:

--- fw-pf.lo ---
fw-pf.c:18:10: fatal error: 'libpfctl.h' file not found
#include <libpfctl.h>
         ^~~~~~~~~~~~
Comment 5 Mark Millard 2023-09-17 20:05:58 UTC
(In reply to Mark Millard from comment #4)

Not that it makes the difference, but clearly not one of
my better days. Using LIB_DEPENDS for a library instead:

# git -C /usr/ports/ diff net/libdnet
diff --git a/net/libdnet/Makefile b/net/libdnet/Makefile
index 63134d9f8b40..7379b72cd7d7 100644
--- a/net/libdnet/Makefile
+++ b/net/libdnet/Makefile
@@ -13,6 +13,8 @@ LICENSE_FILE= ${WRKSRC}/LICENSE
 
 USES?=         autoreconf libtool
 
+LIB_DEPENDS=   libpfctl.so:net/libpfctl
+
 USE_GITHUB=    yes
 GH_ACCOUNT=    5u623l20
Comment 6 Kristof Provost freebsd_committer freebsd_triage 2023-09-17 20:16:48 UTC
I think I messed something up with the patch, because the makefile changes (setting libdepends among others) aren’t there. I’ll update it after dinner.
Comment 7 Kristof Provost freebsd_committer freebsd_triage 2023-09-17 22:42:10 UTC
Created attachment 244984 [details]
patch

Fixed patch.
Comment 8 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2023-09-18 06:32:49 UTC
Patched it locally with some minor changes. Will go into my tonight's build and hopefully I will commit tomorrow.
Comment 9 commit-hook freebsd_committer freebsd_triage 2023-09-19 06:56:53 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a36ac4ec4f06a1d6a14f63972aaa1399035f55a6

commit a36ac4ec4f06a1d6a14f63972aaa1399035f55a6
Author:     Kristof Provost <kp@freebsd.org>
AuthorDate: 2023-09-18 06:18:57 +0000
Commit:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
CommitDate: 2023-09-19 06:24:59 +0000

    net/libdnet: Use libpfctl

    Several old ioctl commands have been removed in 15/main, which broke
    compilation for this port. Rely on libpfctl instead.

    There are some breaking pf API changes in 14 which involves regarding
    the ioctl syscalls. This port is an old outdated port which explicitly
    used those older syscalls. This port also is dependency of net/scapy
    which is run in our CI for testing. So fix it with blanket approval.

    For more information see:
    https://lists.freebsd.org/archives/freebsd-pf/2023-April/000345.html

    PR:             273899
    Approved by:    portmgr (just-fix-it)
    Sponsored by:   Rubicon Communications, LLC ("Netgate")

 net/libdnet/Makefile                      |  8 ++-
 net/libdnet/files/patch-src_fw-pf.c (new) | 83 +++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+), 2 deletions(-)
Comment 10 Mark Millard 2023-09-19 14:37:56 UTC
(In reply to commit-hook from comment #9)

I've a poudriere build that is failing during configure
for c++ . The config.log shows:

configure:3978: checking whether the C++ compiler works
configure:4000: c++ -O2 -pipe -mcpu=cortex-a53 -Wno-error=incompatible-function-pointer-types -g -fstack-protector-strong -fno-strict-aliasing -mcpu=cortex-a53   -mcpu=cortex-a53  -lpfctl -fstack-protector-strong  conftest.cpp  >&5
ld: error: unable to find library -lpfctl
c++: error: linker command failed with exit code 1 (use -v to see invocation)

The -mcpu's are from:

# more /usr/local/etc/poudriere.d/main-CA53-make.conf 
CFLAGS+= -mcpu=cortex-a53
CXXFLAGS+= -mcpu=cortex-a53
CPPFLAGS+= -mcpu=cortex-a53


Note:

(A) it is using the system-clang
(B) the lack of anything indicating where to look for libpfctl.so
(C) so the lack of finding it

The build log does show:

=======================<phase: lib-depends    >============================
===== env: USE_PACKAGE_DEPENDS_ONLY=1 USER=root UID=0 GID=0
===>   py39-libdnet-1.13_4 depends on shared library: libpfctl.so - not found
===>   Installing existing package /packages/All/libpfctl-0.3.pkg
[CA72_ZFS] Installing libpfctl-0.3...
[CA72_ZFS] Extracting libpfctl-0.3: ...... done
===>   py39-libdnet-1.13_4 depends on shared library: libpfctl.so - found (/usr/local/lib/libpfctl.so)
===>   Returning to build of py39-libdnet-1.13_4

but also shows just:

LDFLAGS=" -lpfctl -fstack-protector-strong "
Comment 11 Mark Millard 2023-09-19 15:12:52 UTC
(In reply to Mark Millard from comment #10)

With:

# git -C /usr/ports diff net/libdnet/
diff --git a/net/libdnet/Makefile b/net/libdnet/Makefile
index 2004f32597ea..b979abe0a4a4 100644
--- a/net/libdnet/Makefile
+++ b/net/libdnet/Makefile
@@ -15,7 +15,8 @@ LIB_DEPENDS=  libpfctl.so:net/libpfctl
 
 USES?=         autoreconf libtool localbase
 
-LDFLAGS+=      -lpfctl
+CFLAGS+=       -I${LOCALBASE}/include/
+LDFLAGS+=      -L${LOCALBASE}/lib -lpfctl
 
 USE_GITHUB=    yes
 GH_ACCOUNT=    5u623l20

things are back to building net/libdnet and net/scapy .

The CFLAGS was also required or the include file was not found,
leading to a build failure.
Comment 12 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2023-09-19 15:35:18 UTC
(In reply to Mark Millard from comment #11)
Ah damn. I missed the :ldflags while typing localbase. I will fix it shortly.
Comment 13 Mark Millard 2023-09-20 14:37:09 UTC
Gad. I seem to have confused net/libdnet and net/py-libdnet
some yesterday and, so, been incomplete in my notes.

Being explicit about paths this time for the expanded tar
of the failed build in this new test of using the new update
to contribute to net/scapy building:

/wrkdirs/usr/ports/net/py-libdnet/work-py39/libdnet-1.13/config.log

shows (targeting cortex-a72's in this example, not 53's):

configure:3978: checking whether the C++ compiler works
configure:4000: c++ -O2 -pipe -mcpu=cortex-a72 -Wno-error=incompatible-function-pointer-types -g -fstack-protector-strong -fno-strict-aliasing -mcpu=cortex-a72   -mcpu=cortex-a72  -lpfctl -fstack-prot
ector-strong  conftest.cpp  >&5
ld: error: unable to find library -lpfctl
c++: error: linker command failed with exit code 1 (use -v to see invocation)
configure:4004: $? = 1
configure:4044: result: no

So it is now net/py-libnet that blocks building scapy, again
lack of indicating where to find libpfctl.so for the -lpfctl .


Trying:

# git -C /usr/ports/ diff net/py-libdnet/
diff --git a/net/py-libdnet/Makefile b/net/py-libdnet/Makefile
index 58b553c1e3de..b193ceb1a959 100644
--- a/net/py-libdnet/Makefile
+++ b/net/py-libdnet/Makefile
@@ -6,7 +6,7 @@ COMMENT=        Python module for libdnet
 
 LIB_DEPENDS=   libdnet.so:net/libdnet
 
-USES=          autoreconf libtool python
+USES=          autoreconf libtool python localbase:ldflags
 
 MASTERDIR=     ${.CURDIR}/../libdnet
 INSTALL_WRKSRC=        ${WRKSRC}/python

lead to net/py-libnet and net/scapy building when poudriere
was told to build via:

poudriere bulk -jmain-CA78C -w -C net/scapy

(yet a different example cortex-*) and the builds were
successful.
Comment 14 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2023-09-20 14:44:15 UTC
(In reply to Mark Millard from comment #13)
Yeap I saw it today morning. I will fix it soon.
Comment 15 Mark Millard 2023-09-21 02:11:27 UTC
(In reply to Muhammad Moinur Rahman from comment #14)

Thanks for the fixes: This time around the scapy related
builds all worked after updating /usr/ports/ .