template (3356B)
1 # Template file for 'iproute2' 2 pkgname=iproute2 3 version=6.19.0 4 revision=3 5 short_desc="IP routing and network device configuration tools" 6 maintainer="finwo <finwo@pm.me>" 7 license="GPL-2.0-only" 8 homepage="https://www.kernel.org/pub/linux/utils/net/iproute2/" 9 distfiles="https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-6.19.0.tar.xz" 10 checksum=9332213d35480b647086a70c302de8568de83455a98774d35de216c4ce191006 11 depends="libmnl libcap" 12 makedepends="libmnl libcap" 13 hostmakedepends="bison flex" 14 15 # Notes: 16 # - `ip` + `rtmon` + `ss` ONLY (PLAN section 10): the top-level 17 # `install: all` would build every subdir (tc needs flex/bison/xtables/elf), 18 # so the template builds SUBDIRS="lib ip misc" and cherry-picks the three 19 # binaries plus the iproute2 config files (rt_tables symbolic names live 20 # there). tc/bridge/nstat/ifstat/rtacct/lnstat land as separate design 21 # decisions, not silent extras. misc needs host bison/flex (build-only 22 # code generators, same category as perl for openssl); its libbpf/rpc 23 # includes are already gated off by the scrub below. 24 # - libmnl comes from the sysroot (extended-error-ack decoding) and libcap 25 # (drop_cap ambient-capability hygiene); configure finds both via the 26 # driver-exported PKG_CONFIG_PATH. 27 # - Host-independence scrub: configure appends every detected optional to 28 # GLOBAL LDLIBS, so any host dev library would silently link into `ip`. 29 # BPF/XDP program loading (elf, libbpf), selinux and tirpc go - none of 30 # them has consumers in lib/ or ip/. Patterns are anchored; absent lines 31 # are no-ops; do_build asserts the final linkage so a rotted scrub fails 32 # the build, never the boot. 33 # - CONF_USR_DIR bakes to /usr/share/iproute2; the config files are 34 # installed to match. 35 36 do_configure() { 37 cd "${WRKSRC}" 38 ./configure 39 sed -i \ 40 -e '/^HAVE_ELF:=/d' \ 41 -e '/^HAVE_LIBBPF.*:=/d' \ 42 -e '/^HAVE_SELINUX:=/d' \ 43 -e '/^HAVE_RPC:=/d' \ 44 -e '/^CFLAGS += -DHAVE_ELF/d' \ 45 -e '/^CFLAGS += -DHAVE_LIBBPF/d' \ 46 -e '/^CFLAGS += -DHAVE_SELINUX/d' \ 47 -e '/^CFLAGS += -DHAVE_RPC/d' \ 48 -e '/^LDLIBS +=.*-lelf/d' \ 49 -e '/^LDLIBS +=.*selinux/d' \ 50 -e '/^LDLIBS +=.*tirpc/d' \ 51 config.mk 52 } 53 54 do_build() { 55 cd "${WRKSRC}" 56 # iproute2 has no kbuild-style flag tracking: objects from a previous 57 # configure do not rebuild when config.mk flags change. Clean 58 # unconditionally (cheap for lib+ip+misc; full-tree cost is why SUBDIRS 59 # is limited here too). 60 make SUBDIRS="lib ip misc" clean >/dev/null 61 make -j"$(nproc)" SUBDIRS="lib ip misc" 62 for bin in ip/ip ip/rtmon misc/ss; do 63 [ -x "${bin}" ] || die "iproute2: ${bin} missing after build" 64 needed=$(readelf -d "${bin}" | sed -n 's/^.*NEEDED.*\[\(.*\)\].*$/\1/p' | sort) 65 for lib in ${needed}; do 66 case "${lib}" in 67 libmnl.so.*|libcap.so.*|libc.so.*) : ;; 68 *) die "iproute2: ${bin}: unexpected NEEDED entry: ${lib}" ;; 69 esac 70 done 71 done 72 } 73 74 do_install() { 75 cd "${WRKSRC}" 76 install -D -m 755 ip/ip "${DESTDIR}/sbin/ip" 77 install -D -m 755 ip/rtmon "${DESTDIR}/sbin/rtmon" 78 install -D -m 755 misc/ss "${DESTDIR}/sbin/ss" 79 for f in etc/iproute2/*; do 80 [ -f "${f}" ] || continue 81 install -D -m 644 "${f}" "${DESTDIR}/usr/share/iproute2/$(basename "${f}")" 82 done 83 [ -f "${DESTDIR}/usr/share/iproute2/rt_tables" ] || die "iproute2: rt_tables missing" 84 }