Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-libs/libpcap/files/, net-libs/libpcap/
Date: Sat, 27 Aug 2022 23:10:27
Message-Id: 1661580355.99e3374e9cb8d121c3d534111de8fbad950b51bd.sam@gentoo
1 commit: 99e3374e9cb8d121c3d534111de8fbad950b51bd
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Sat Aug 27 05:40:38 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Sat Aug 27 06:05:55 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=99e3374e
7
8 net-libs/libpcap: drop -L/usr/lib from pcap-config output
9
10 Signed-off-by: Sam James <sam <AT> gentoo.org>
11
12 ...bpcap-1.10.1-pcap-config-no-hardcoded-lib.patch | 100 ++++++++++++++++++++
13 .../libpcap/files/libpcap-1.10.1-pcap-config.patch | 43 +++++++++
14 net-libs/libpcap/libpcap-1.10.1-r2.ebuild | 103 +++++++++++++++++++++
15 3 files changed, 246 insertions(+)
16
17 diff --git a/net-libs/libpcap/files/libpcap-1.10.1-pcap-config-no-hardcoded-lib.patch b/net-libs/libpcap/files/libpcap-1.10.1-pcap-config-no-hardcoded-lib.patch
18 new file mode 100644
19 index 000000000000..2fc617dcda2f
20 --- /dev/null
21 +++ b/net-libs/libpcap/files/libpcap-1.10.1-pcap-config-no-hardcoded-lib.patch
22 @@ -0,0 +1,100 @@
23 +https://github.com/the-tcpdump-group/libpcap/commit/84cb8cfdbf99a5fbc8127e3f092dc4d36ab513e9
24 +
25 +From 84cb8cfdbf99a5fbc8127e3f092dc4d36ab513e9 Mon Sep 17 00:00:00 2001
26 +From: Guy Harris <gharris@×××××.net>
27 +Date: Mon, 2 Aug 2021 01:04:53 -0700
28 +Subject: [PATCH] pcap-config: don't provide -L/usr/lib for pkg-config --libs.
29 +
30 +It shouldn't be necessary, as C compilers generally look there by
31 +default and...
32 +
33 +...it can cause problems if the libpcap you want *isn't* in /usr/lib.
34 +For example, on some systems that support both 32-bit and 64-bit
35 +executables, this might cause the 32-bit library to be found, even on
36 +64-bit platforms, with hilarity ensuing afterwards.
37 +
38 +In particular, on Solaris 11, where /usr/lib has the 32-bit libraries
39 +and /usr/lib/{something} has the 64-bit libraries ({something} depends
40 +on whether it's SPARC or x86), that's what happens if you try to do a
41 +CMake build of tcpdump against the system libpcap:
42 +
43 +The CMake file for finding pcap converts the -lpcap provided by
44 +pcap-config into the absolute path of libpcap, and that's the path of
45 +the 32-bit library, as it looks in /usr/lib. (CMake really wants "find
46 +library" scripts to supply a list of libraries giving their absolute
47 +paths.)
48 +
49 +Thus, if you're using GCC, the tests done to find out what pcap APIs are
50 +available will fail, as the test programs get build 64-bit but are
51 +linked with the 32-bit libpcap; the link fails as you're mixing 32-bit
52 +and 64-bit code, and the CMake script treats that as meaning "the
53 +function isn't available".
54 +
55 +(Sun C apparently somehow manages either to build 32-bit code by
56 +default, so that linking with /usr/lib/libpcap.so succeeds, or realizes
57 +that linking 64-bit code with /usr/lib/{library}.so is bogus and links
58 +with /usr/lib/{something}/libpcap.so instead.)
59 +
60 +Debian removed the -L in pcap-config for similar reasons; to quote the
61 +comment at the beginning of the patch file:
62 +
63 + Remove -L<libdir> from default pcap-config --libs output, as
64 + libdir is already in the default toolchain search path on
65 + Debian, and we want the generated script to be arch-independent.
66 +
67 +(We don't remove it from the .pc file; we assume that 1) pkg-config and
68 +2) the packager of libpcap does what is necessary to make this work.)
69 +--- a/pcap-config.in
70 ++++ b/pcap-config.in
71 +@@ -41,6 +41,13 @@ do
72 + esac
73 + shift
74 + done
75 ++#
76 ++# If libdir isn't /usr/lib, add it to the link-time linker path.
77 ++#
78 ++if [ "$libdir" != "/usr/lib" ]
79 ++then
80 ++ LPATH=-L$libdir
81 ++fi
82 + if [ "$V_RPATH_OPT" != "" ]
83 + then
84 + #
85 +@@ -59,16 +66,16 @@ then
86 + #
87 + if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
88 + then
89 +- echo "-I$includedir -L$libdir -lpcap $LIBS"
90 ++ echo "-I$includedir $LPATH -lpcap $LIBS"
91 + elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
92 + then
93 +- echo "-I$includedir -L$libdir $LIBS"
94 ++ echo "-I$includedir $LPATH $LIBS"
95 + elif [ "$show_cflags" = 1 ]
96 + then
97 + echo "-I$includedir"
98 + elif [ "$show_libs" = 1 ]
99 + then
100 +- echo "-L$libdir -lpcap $LIBS"
101 ++ echo "$LPATH -lpcap $LIBS"
102 + elif [ "$show_additional_libs" = 1 ]
103 + then
104 + echo "$LIBS"
105 +@@ -80,7 +87,7 @@ else
106 + #
107 + if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
108 + then
109 +- echo "-I$includedir -L$libdir $RPATH -l$PACKAGE_NAME"
110 ++ echo "-I$includedir $LPATH $RPATH -l$PACKAGE_NAME"
111 + elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
112 + then
113 + echo "-I$includedir"
114 +@@ -89,6 +96,6 @@ else
115 + echo "-I$includedir"
116 + elif [ "$show_libs" = 1 ]
117 + then
118 +- echo "-L$libdir $RPATH -l$PACKAGE_NAME"
119 ++ echo "$LPATH $RPATH -l$PACKAGE_NAME"
120 + fi
121 + fi
122 +
123
124 diff --git a/net-libs/libpcap/files/libpcap-1.10.1-pcap-config.patch b/net-libs/libpcap/files/libpcap-1.10.1-pcap-config.patch
125 new file mode 100644
126 index 000000000000..1fa8d411ead6
127 --- /dev/null
128 +++ b/net-libs/libpcap/files/libpcap-1.10.1-pcap-config.patch
129 @@ -0,0 +1,43 @@
130 +--- a/pcap-config.in
131 ++++ b/pcap-config.in
132 +@@ -66,16 +66,16 @@ then
133 + #
134 + if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
135 + then
136 +- echo "-I$includedir $LPATH -lpcap $LIBS"
137 ++ echo "-lpcap $LIBS"
138 + elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
139 + then
140 +- echo "-I$includedir $LPATH $LIBS"
141 ++ echo "$LIBS"
142 + elif [ "$show_cflags" = 1 ]
143 + then
144 +- echo "-I$includedir"
145 ++ echo ""
146 + elif [ "$show_libs" = 1 ]
147 + then
148 +- echo "$LPATH -lpcap $LIBS"
149 ++ echo "-lpcap $LIBS"
150 + elif [ "$show_additional_libs" = 1 ]
151 + then
152 + echo "$LIBS"
153 +@@ -87,15 +87,15 @@ else
154 + #
155 + if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
156 + then
157 +- echo "-I$includedir $LPATH $RPATH -l$PACKAGE_NAME"
158 ++ echo " $RPATH -l$PACKAGE_NAME"
159 + elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
160 + then
161 +- echo "-I$includedir"
162 ++ echo ""
163 + elif [ "$show_cflags" = 1 ]
164 + then
165 +- echo "-I$includedir"
166 ++ echo ""
167 + elif [ "$show_libs" = 1 ]
168 + then
169 +- echo "$LPATH $RPATH -l$PACKAGE_NAME"
170 ++ echo "$RPATH -l$PACKAGE_NAME"
171 + fi
172 + fi
173
174 diff --git a/net-libs/libpcap/libpcap-1.10.1-r2.ebuild b/net-libs/libpcap/libpcap-1.10.1-r2.ebuild
175 new file mode 100644
176 index 000000000000..477ba7b57d29
177 --- /dev/null
178 +++ b/net-libs/libpcap/libpcap-1.10.1-r2.ebuild
179 @@ -0,0 +1,103 @@
180 +# Copyright 1999-2022 Gentoo Authors
181 +# Distributed under the terms of the GNU General Public License v2
182 +
183 +EAPI=7
184 +
185 +inherit autotools multilib-minimal
186 +
187 +DESCRIPTION="A system-independent library for user-level network packet capture"
188 +HOMEPAGE="https://www.tcpdump.org/ https://github.com/the-tcpdump-group/libpcap"
189 +
190 +if [[ ${PV} == *9999* ]] ; then
191 + EGIT_REPO_URI="https://github.com/the-tcpdump-group/libpcap"
192 + inherit git-r3
193 +else
194 + VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/tcpdump.asc
195 + inherit verify-sig
196 +
197 + # Note: drop -upstream on bump, this is just because we switched to the official
198 + # distfiles for verify-sig
199 + SRC_URI="https://www.tcpdump.org/release/${P}.tar.gz -> ${P}-upstream.tar.gz"
200 + SRC_URI+=" verify-sig? ( https://www.tcpdump.org/release/${P}.tar.gz.sig -> ${P}-upstream.tar.gz.sig )"
201 +
202 + KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~x86-solaris"
203 +fi
204 +
205 +LICENSE="BSD"
206 +SLOT="0"
207 +IUSE="bluetooth dbus netlink rdma remote static-libs usb yydebug"
208 +
209 +RDEPEND="
210 + bluetooth? ( net-wireless/bluez:=[${MULTILIB_USEDEP}] )
211 + dbus? ( sys-apps/dbus[${MULTILIB_USEDEP}] )
212 + netlink? ( dev-libs/libnl:3[${MULTILIB_USEDEP}] )
213 + remote? ( virtual/libcrypt:=[${MULTILIB_USEDEP}] )
214 + rdma? ( sys-cluster/rdma-core )
215 + usb? ( virtual/libusb:1[${MULTILIB_USEDEP}] )
216 +"
217 +DEPEND="${RDEPEND}"
218 +BDEPEND="
219 + sys-devel/flex
220 + virtual/yacc
221 + dbus? ( virtual/pkgconfig )
222 +"
223 +
224 +if [[ ${PV} != *9999* ]] ; then
225 + BDEPEND+=" verify-sig? ( sec-keys/openpgp-keys-tcpdump )"
226 +fi
227 +
228 +PATCHES=(
229 + "${FILESDIR}"/${PN}-1.10.0-usbmon.patch
230 +
231 + # Drop ${P}-pcap-config-no-hardcoded-lib.patch on next release
232 + "${FILESDIR}"/${P}-pcap-config-no-hardcoded-lib.patch
233 +
234 + # We need to keep this, it's just rebased on top of the above
235 + # ${P}-pcap-config-no-hardcoded-lib.patch. Drop this comment then too,
236 + # but keep this patch.
237 + "${FILESDIR}"/${PN}-1.10.1-pcap-config.patch
238 +)
239 +
240 +src_prepare() {
241 + default
242 +
243 + if ! [[ -f VERSION ]]; then
244 + echo ${PV} > VERSION || die
245 + fi
246 +
247 + eautoreconf
248 +}
249 +
250 +multilib_src_configure() {
251 + ECONF_SOURCE="${S}" \
252 + econf \
253 + $(use_enable bluetooth) \
254 + $(use_enable dbus) \
255 + $(use_enable rdma) \
256 + $(use_enable remote) \
257 + $(use_enable usb) \
258 + $(use_enable yydebug) \
259 + $(use_with netlink libnl) \
260 + --enable-ipv6
261 +}
262 +
263 +multilib_src_compile() {
264 + emake all shared
265 +}
266 +
267 +multilib_src_install_all() {
268 + dodoc CREDITS CHANGES VERSION TODO README.* doc/README.*
269 +
270 + # remove static libraries (--disable-static does not work)
271 + if ! use static-libs; then
272 + find "${ED}" -name '*.a' -exec rm {} + || die
273 + fi
274 +
275 + find "${ED}" -name '*.la' -delete || die
276 +
277 + # We need this to build pppd on G/FBSD systems
278 + if [[ "${USERLAND}" == "BSD" ]]; then
279 + insinto /usr/include
280 + doins pcap-int.h portability.h
281 + fi
282 +}