Gentoo Archives: gentoo-commits

From: "Robin H. Johnson" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/iproute2/files/, sys-apps/iproute2/
Date: Sun, 07 Jan 2018 22:39:50
Message-Id: 1515364775.041fdf910f7dda041d1f01f6538fc7550ad830b7.robbat2@gentoo
1 commit: 041fdf910f7dda041d1f01f6538fc7550ad830b7
2 Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jan 7 22:36:48 2018 +0000
4 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
5 CommitDate: Sun Jan 7 22:39:35 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=041fdf91
7
8 sys-apps/iproute2: fix libmnl/libelf/libselinux automagic.
9
10 libmnl, libelf, libselinux were being linked automagically.
11 Fix by improving Makefiles.
12
13 Tested on:
14 - USE='-minimal -iptables'
15 - USE='-minimal iptables'
16 - USE=' minimal -iptables'
17 - USE=' minimal iptables' (reported by broken per bug)
18
19 Closes: https://bugs.gentoo.org/643722
20 Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
21 Package-Manager: Portage-2.3.16, Repoman-2.3.6
22
23 .../files/iproute2-4.14.1-configure-nomagic.patch | 196 +++++++++++++++++++++
24 sys-apps/iproute2/iproute2-4.14.1-r3.ebuild | 152 ++++++++++++++++
25 2 files changed, 348 insertions(+)
26
27 diff --git a/sys-apps/iproute2/files/iproute2-4.14.1-configure-nomagic.patch b/sys-apps/iproute2/files/iproute2-4.14.1-configure-nomagic.patch
28 new file mode 100644
29 index 00000000000..919249b8392
30 --- /dev/null
31 +++ b/sys-apps/iproute2/files/iproute2-4.14.1-configure-nomagic.patch
32 @@ -0,0 +1,196 @@
33 +The hand-rolled configure script, for multiple options (selinux,mnl,elf), sets
34 +a variable as well as modifying CFLAGS & LDLIBS.
35 +
36 +If config.mk is later amended to disable a feature, the CFLAGS/LDLIBS tweaks
37 +are still in place.
38 +
39 +Push the CFLAGS/LDLIBS changes into new conditional Makefile code, so that they
40 +are only passed when correctly needed.
41 +
42 +Prior Gentoo testcase for reproduction:
43 +USE=minimal ebuild ... compile.
44 +- Linking with libelf & libmnl based only on presence.
45 +- Links based on libselinux based only on presence.
46 +
47 +Closes: https://bugs.gentoo.org/643722
48 +Signed-off-by: Robin H. Johnson <robbat2@g.o>
49 +
50 +diff -Nuar --exclude '*~' --exclude '.*.swp' --exclude '*.orig' iproute2-4.14.1.orig/bridge/Makefile iproute2-4.14.1/bridge/Makefile
51 +--- iproute2-4.14.1.orig/bridge/Makefile 2017-11-13 10:09:57.000000000 -0800
52 ++++ iproute2-4.14.1/bridge/Makefile 2018-01-07 14:24:23.350726423 -0800
53 +@@ -1,6 +1,7 @@
54 + BROBJ = bridge.o fdb.o monitor.o link.o mdb.o vlan.o
55 +
56 + include ../config.mk
57 ++include ../config.include
58 +
59 + all: bridge
60 +
61 +diff -Nuar --exclude '*~' --exclude '.*.swp' --exclude '*.orig' iproute2-4.14.1.orig/config.include iproute2-4.14.1/config.include
62 +--- iproute2-4.14.1.orig/config.include 1969-12-31 16:00:00.000000000 -0800
63 ++++ iproute2-4.14.1/config.include 2018-01-07 14:25:34.406126921 -0800
64 +@@ -0,0 +1,22 @@
65 ++# We can only modify CFLAGS/LDLIBS after all the config options are known.
66 ++ifeq ($(IP_CONFIG_SETNS),y)
67 ++ CFLAGS += $(IP_CONFIG_SETNS_CFLAGS)
68 ++endif
69 ++ifeq ($(HAVE_ELF),y)
70 ++ CFLAGS += $(HAVE_ELF_CFLAGS)
71 ++ LDLIBS += $(HAVE_ELF_LDLIBS)
72 ++endif
73 ++ifeq ($(HAVE_SELINUX),y)
74 ++ CFLAGS += $(HAVE_SELINUX_CFLAGS)
75 ++ LDLIBS += $(HAVE_SELINUX_LDLIBS)
76 ++endif
77 ++ifeq ($(HAVE_MNL),y)
78 ++ CFLAGS += $(HAVE_MNL_CFLAGS)
79 ++ LDLIBS += $(HAVE_MNL_LDLIBS)
80 ++endif
81 ++
82 ++# Rules can only be declared after all variables in them are known.
83 ++%.o: %.c
84 ++ $(QUIET_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
85 ++
86 ++# vim: ft=make:
87 +diff -Nuar --exclude '*~' --exclude '.*.swp' --exclude '*.orig' iproute2-4.14.1.orig/configure iproute2-4.14.1/configure
88 +--- iproute2-4.14.1.orig/configure 2017-11-13 10:09:57.000000000 -0800
89 ++++ iproute2-4.14.1/configure 2018-01-07 14:25:49.242419367 -0800
90 +@@ -223,7 +223,7 @@
91 + then
92 + echo "IP_CONFIG_SETNS:=y" >>$CONFIG
93 + echo "yes"
94 +- echo "CFLAGS += -DHAVE_SETNS" >>$CONFIG
95 ++ echo "IP_CONFIG_SETNS_CFLAGS += -DHAVE_SETNS" >>$CONFIG
96 + else
97 + echo "no"
98 + fi
99 +@@ -268,8 +268,8 @@
100 + echo "HAVE_ELF:=y" >>$CONFIG
101 + echo "yes"
102 +
103 +- echo 'CFLAGS += -DHAVE_ELF' `${PKG_CONFIG} libelf --cflags` >> $CONFIG
104 +- echo 'LDLIBS += ' `${PKG_CONFIG} libelf --libs` >>$CONFIG
105 ++ echo 'HAVE_ELF_CFLAGS += -DHAVE_ELF' `${PKG_CONFIG} libelf --cflags` >> $CONFIG
106 ++ echo 'HAVE_ELF_LDLIBS += ' `${PKG_CONFIG} libelf --libs` >>$CONFIG
107 + else
108 + echo "no"
109 + fi
110 +@@ -283,8 +283,8 @@
111 + echo "HAVE_SELINUX:=y" >>$CONFIG
112 + echo "yes"
113 +
114 +- echo 'LDLIBS +=' `${PKG_CONFIG} --libs libselinux` >>$CONFIG
115 +- echo 'CFLAGS += -DHAVE_SELINUX' `${PKG_CONFIG} --cflags libselinux` >>$CONFIG
116 ++ echo 'HAVE_SELINUX_CFLAGS += -DHAVE_SELINUX' `${PKG_CONFIG} --cflags libselinux` >>$CONFIG
117 ++ echo 'HAVE_SELINUX_LDLIBS +=' `${PKG_CONFIG} --libs libselinux` >>$CONFIG
118 + else
119 + echo "no"
120 + fi
121 +@@ -297,8 +297,8 @@
122 + echo "HAVE_MNL:=y" >>$CONFIG
123 + echo "yes"
124 +
125 +- echo 'CFLAGS += -DHAVE_LIBMNL' `${PKG_CONFIG} libmnl --cflags` >>$CONFIG
126 +- echo 'LDLIBS +=' `${PKG_CONFIG} libmnl --libs` >> $CONFIG
127 ++ echo 'HAVE_MNL_CFLAGS += -DHAVE_LIBMNL' `${PKG_CONFIG} libmnl --cflags` >>$CONFIG
128 ++ echo 'HAVE_MNL_LDLIBS +=' `${PKG_CONFIG} libmnl --libs` >> $CONFIG
129 + else
130 + echo "no"
131 + fi
132 +@@ -425,7 +425,3 @@
133 + echo -n "docs:"
134 + check_docs
135 + echo
136 +-
137 +-echo >> $CONFIG
138 +-echo "%.o: %.c" >> $CONFIG
139 +-echo ' $(QUIET_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<' >> $CONFIG
140 +diff -Nuar --exclude '*~' --exclude '.*.swp' --exclude '*.orig' iproute2-4.14.1.orig/devlink/Makefile iproute2-4.14.1/devlink/Makefile
141 +--- iproute2-4.14.1.orig/devlink/Makefile 2017-11-13 10:09:57.000000000 -0800
142 ++++ iproute2-4.14.1/devlink/Makefile 2018-01-07 14:24:23.351726442 -0800
143 +@@ -1,4 +1,5 @@
144 + include ../config.mk
145 ++include ../config.include
146 +
147 + ifeq ($(HAVE_MNL),y)
148 +
149 +diff -Nuar --exclude '*~' --exclude '.*.swp' --exclude '*.orig' iproute2-4.14.1.orig/genl/Makefile iproute2-4.14.1/genl/Makefile
150 +--- iproute2-4.14.1.orig/genl/Makefile 2017-11-13 10:09:57.000000000 -0800
151 ++++ iproute2-4.14.1/genl/Makefile 2018-01-07 14:24:23.351726442 -0800
152 +@@ -1,6 +1,7 @@
153 + GENLOBJ=genl.o
154 +
155 + include ../config.mk
156 ++include ../config.include
157 + SHARED_LIBS ?= y
158 +
159 + CFLAGS += -fno-strict-aliasing
160 +diff -Nuar --exclude '*~' --exclude '.*.swp' --exclude '*.orig' iproute2-4.14.1.orig/ip/Makefile iproute2-4.14.1/ip/Makefile
161 +--- iproute2-4.14.1.orig/ip/Makefile 2017-11-13 10:09:57.000000000 -0800
162 ++++ iproute2-4.14.1/ip/Makefile 2018-01-07 14:24:23.351726442 -0800
163 +@@ -14,6 +14,7 @@
164 + RTMONOBJ=rtmon.o
165 +
166 + include ../config.mk
167 ++include ../config.include
168 +
169 + ALLOBJ=$(IPOBJ) $(RTMONOBJ)
170 + SCRIPTS=ifcfg rtpr routel routef
171 +diff -Nuar --exclude '*~' --exclude '.*.swp' --exclude '*.orig' iproute2-4.14.1.orig/lib/Makefile iproute2-4.14.1/lib/Makefile
172 +--- iproute2-4.14.1.orig/lib/Makefile 2017-11-13 10:09:57.000000000 -0800
173 ++++ iproute2-4.14.1/lib/Makefile 2018-01-07 14:24:23.351726442 -0800
174 +@@ -1,4 +1,5 @@
175 + include ../config.mk
176 ++include ../config.include
177 +
178 + CFLAGS += -fPIC
179 +
180 +diff -Nuar --exclude '*~' --exclude '.*.swp' --exclude '*.orig' iproute2-4.14.1.orig/misc/Makefile iproute2-4.14.1/misc/Makefile
181 +--- iproute2-4.14.1.orig/misc/Makefile 2017-11-13 10:09:57.000000000 -0800
182 ++++ iproute2-4.14.1/misc/Makefile 2018-01-07 14:24:23.351726442 -0800
183 +@@ -4,6 +4,7 @@
184 + TARGETS=ss nstat ifstat rtacct lnstat
185 +
186 + include ../config.mk
187 ++include ../config.include
188 +
189 + ifeq ($(HAVE_BERKELEY_DB),y)
190 + TARGETS += arpd
191 +diff -Nuar --exclude '*~' --exclude '.*.swp' --exclude '*.orig' iproute2-4.14.1.orig/netem/Makefile iproute2-4.14.1/netem/Makefile
192 +--- iproute2-4.14.1.orig/netem/Makefile 2017-11-13 10:09:57.000000000 -0800
193 ++++ iproute2-4.14.1/netem/Makefile 2018-01-07 14:24:23.351726442 -0800
194 +@@ -1,4 +1,5 @@
195 + include ../config.mk
196 ++include ../config.include
197 +
198 + DISTGEN = maketable normal pareto paretonormal
199 + DISTDATA = normal.dist pareto.dist paretonormal.dist experimental.dist
200 +diff -Nuar --exclude '*~' --exclude '.*.swp' --exclude '*.orig' iproute2-4.14.1.orig/rdma/Makefile iproute2-4.14.1/rdma/Makefile
201 +--- iproute2-4.14.1.orig/rdma/Makefile 2017-11-13 10:09:57.000000000 -0800
202 ++++ iproute2-4.14.1/rdma/Makefile 2018-01-07 14:24:23.352726462 -0800
203 +@@ -1,4 +1,5 @@
204 + include ../config.mk
205 ++include ../config.include
206 +
207 + ifeq ($(HAVE_MNL),y)
208 +
209 +diff -Nuar --exclude '*~' --exclude '.*.swp' --exclude '*.orig' iproute2-4.14.1.orig/tc/Makefile iproute2-4.14.1/tc/Makefile
210 +--- iproute2-4.14.1.orig/tc/Makefile 2017-11-13 10:09:57.000000000 -0800
211 ++++ iproute2-4.14.1/tc/Makefile 2018-01-07 14:24:23.352726462 -0800
212 +@@ -3,6 +3,7 @@
213 + emp_ematch.yacc.o emp_ematch.lex.o
214 +
215 + include ../config.mk
216 ++include ../config.include
217 +
218 + SHARED_LIBS ?= y
219 +
220 +diff -Nuar --exclude '*~' --exclude '.*.swp' --exclude '*.orig' iproute2-4.14.1.orig/tipc/Makefile iproute2-4.14.1/tipc/Makefile
221 +--- iproute2-4.14.1.orig/tipc/Makefile 2017-11-13 10:09:57.000000000 -0800
222 ++++ iproute2-4.14.1/tipc/Makefile 2018-01-07 14:24:23.352726462 -0800
223 +@@ -1,4 +1,5 @@
224 + include ../config.mk
225 ++include ../config.include
226 +
227 + ifeq ($(HAVE_MNL),y)
228 +
229
230 diff --git a/sys-apps/iproute2/iproute2-4.14.1-r3.ebuild b/sys-apps/iproute2/iproute2-4.14.1-r3.ebuild
231 new file mode 100644
232 index 00000000000..d515a2cfe56
233 --- /dev/null
234 +++ b/sys-apps/iproute2/iproute2-4.14.1-r3.ebuild
235 @@ -0,0 +1,152 @@
236 +# Copyright 1999-2018 Gentoo Foundation
237 +# Distributed under the terms of the GNU General Public License v2
238 +
239 +EAPI=6
240 +
241 +inherit toolchain-funcs flag-o-matic multilib
242 +
243 +if [[ ${PV} == "9999" ]] ; then
244 + EGIT_REPO_URI="git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git"
245 + inherit git-r3
246 +else
247 + SRC_URI="mirror://kernel/linux/utils/net/${PN}/${P}.tar.xz"
248 + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
249 +fi
250 +
251 +DESCRIPTION="kernel routing and traffic control utilities"
252 +HOMEPAGE="https://wiki.linuxfoundation.org/networking/iproute2"
253 +
254 +LICENSE="GPL-2"
255 +SLOT="0"
256 +IUSE="atm berkdb +iptables ipv6 minimal selinux"
257 +
258 +# We could make libmnl optional, but it's tiny, so eh
259 +RDEPEND="
260 + !net-misc/arpd
261 + !minimal? ( net-libs/libmnl virtual/libelf )
262 + iptables? ( >=net-firewall/iptables-1.4.20:= )
263 + berkdb? ( sys-libs/db:= )
264 + atm? ( net-dialup/linux-atm )
265 + selinux? ( sys-libs/libselinux )
266 +"
267 +# We require newer linux-headers for ipset support #549948 and some defines #553876
268 +DEPEND="
269 + ${RDEPEND}
270 + app-arch/xz-utils
271 + iptables? ( virtual/pkgconfig )
272 + >=sys-devel/bison-2.4
273 + sys-devel/flex
274 + >=sys-kernel/linux-headers-3.16
275 + elibc_glibc? ( >=sys-libs/glibc-2.7 )
276 +"
277 +
278 +PATCHES=(
279 + "${FILESDIR}"/${PN}-3.1.0-mtu.patch #291907
280 + "${FILESDIR}"/${P}-fix-tc-actions.patch
281 + "${FILESDIR}"/${P}-configure-nomagic.patch # bug 643722
282 +)
283 +
284 +src_prepare() {
285 + if ! use ipv6 ; then
286 + PATCHES+=(
287 + "${FILESDIR}"/${PN}-4.11.0-no-ipv6.patch #326849
288 + )
289 + fi
290 +
291 + default
292 +
293 + sed -i \
294 + -e '/^CC :\?=/d' \
295 + -e "/^LIBDIR/s:=.*:=/$(get_libdir):" \
296 + -e "s:-O2:${CFLAGS} ${CPPFLAGS}:" \
297 + -e "/^HOSTCC/s:=.*:= $(tc-getBUILD_CC):" \
298 + -e "/^WFLAGS/s:-Werror::" \
299 + -e "/^DBM_INCLUDE/s:=.*:=${T}:" \
300 + Makefile || die
301 +
302 + # Use /run instead of /var/run.
303 + sed -i \
304 + -e 's:/var/run:/run:g' \
305 + include/namespace.h \
306 + man/man8/ip-netns.8 || die
307 +
308 + # build against system headers
309 + rm -r include/netinet #include/linux include/ip{,6}tables{,_common}.h include/libiptc
310 + sed -i 's:TCPI_OPT_ECN_SEEN:16:' misc/ss.c || die
311 +
312 + use minimal && sed -i -e '/^SUBDIRS=/s:=.*:=lib tc ip:' Makefile
313 +}
314 +
315 +src_configure() {
316 + tc-export AR CC PKG_CONFIG
317 +
318 + # This sure is ugly. Should probably move into toolchain-funcs at some point.
319 + local setns
320 + pushd "${T}" >/dev/null
321 + printf '#include <sched.h>\nint main(){return setns(0, 0);}\n' > test.c
322 + ${CC} ${CFLAGS} ${CPPFLAGS} -D_GNU_SOURCE ${LDFLAGS} test.c >&/dev/null && setns=y || setns=n
323 + echo 'int main(){return 0;}' > test.c
324 + ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} test.c -lresolv >&/dev/null || sed -i '/^LDLIBS/s:-lresolv::' "${S}"/Makefile
325 + popd >/dev/null
326 +
327 + # run "configure" script first which will create "config.mk"...
328 + econf
329 +
330 + # ...now switch on/off requested features via USE flags
331 + # this is only useful if the test did not set other things, per bug #643722
332 + cat <<-EOF >> config.mk
333 + TC_CONFIG_ATM := $(usex atm y n)
334 + TC_CONFIG_XT := $(usex iptables y n)
335 + TC_CONFIG_NO_XT := $(usex iptables n y)
336 + # We've locked in recent enough kernel headers #549948
337 + TC_CONFIG_IPSET := y
338 + HAVE_BERKELEY_DB := $(usex berkdb y n)
339 + HAVE_MNL := $(usex minimal n y)
340 + HAVE_ELF := $(usex minimal n y)
341 + HAVE_SELINUX := $(usex selinux y n)
342 + IP_CONFIG_SETNS := ${setns}
343 + # Use correct iptables dir, #144265 #293709
344 + IPT_LIB_DIR := $(use iptables && ${PKG_CONFIG} xtables --variable=xtlibdir)
345 + EOF
346 +}
347 +
348 +src_compile() {
349 + emake V=1
350 +}
351 +
352 +src_install() {
353 + if use minimal ; then
354 + into /
355 + dosbin tc/tc
356 + dobin ip/ip
357 + return 0
358 + fi
359 +
360 + emake \
361 + DESTDIR="${D}" \
362 + LIBDIR="${EPREFIX%/}"/$(get_libdir) \
363 + SBINDIR="${EPREFIX%/}"/sbin \
364 + CONFDIR="${EPREFIX%/}"/etc/iproute2 \
365 + DOCDIR="${EPREFIX%/}"/usr/share/doc/${PF} \
366 + MANDIR="${EPREFIX%/}"/usr/share/man \
367 + ARPDDIR="${EPREFIX%/}"/var/lib/arpd \
368 + install
369 +
370 + dodir /bin
371 + mv "${ED%/}"/{s,}bin/ip || die #330115
372 +
373 + dolib.a lib/libnetlink.a
374 + insinto /usr/include
375 + doins include/libnetlink.h
376 + # This local header pulls in a lot of linux headers it
377 + # doesn't directly need. Delete this header that requires
378 + # linux-headers-3.8 until that goes stable. #467716
379 + sed -i '/linux\/netconf.h/d' "${ED%/}"/usr/include/libnetlink.h || die
380 +
381 + if use berkdb ; then
382 + dodir /var/lib/arpd
383 + # bug 47482, arpd doesn't need to be in /sbin
384 + dodir /usr/bin
385 + mv "${ED%/}"/sbin/arpd "${ED%/}"/usr/bin/ || die
386 + fi
387 +}