From 4ca9d6b14ccd42deb2e288c62e9d581b69dfb010 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 15 Jan 2018 16:03:14 +0100 Subject: [PATCH] Add iproute2 package Signed-off-by: David Oberhollenzer --- cfg/alix/SQUASHFS | 1 + cfg/rpi3/SQUASHFS | 1 + pkg/iproute2/00001.patch | 31 ++++++ pkg/iproute2/0002.patch | 214 +++++++++++++++++++++++++++++++++++++++ pkg/iproute2/CREDITS | 6 ++ pkg/iproute2/build | 40 ++++++++ pkg/iproute2/depends | 2 + 7 files changed, 295 insertions(+) create mode 100644 pkg/iproute2/00001.patch create mode 100644 pkg/iproute2/0002.patch create mode 100644 pkg/iproute2/CREDITS create mode 100755 pkg/iproute2/build create mode 100644 pkg/iproute2/depends diff --git a/cfg/alix/SQUASHFS b/cfg/alix/SQUASHFS index e1b4fbc..8b02f3b 100644 --- a/cfg/alix/SQUASHFS +++ b/cfg/alix/SQUASHFS @@ -15,3 +15,4 @@ sed gawk inetutils ethtool +iproute2 diff --git a/cfg/rpi3/SQUASHFS b/cfg/rpi3/SQUASHFS index 11dee3f..ab1a6e3 100644 --- a/cfg/rpi3/SQUASHFS +++ b/cfg/rpi3/SQUASHFS @@ -18,3 +18,4 @@ sed gawk inetutils ethtool +iproute2 diff --git a/pkg/iproute2/00001.patch b/pkg/iproute2/00001.patch new file mode 100644 index 0000000..6af716f --- /dev/null +++ b/pkg/iproute2/00001.patch @@ -0,0 +1,31 @@ +--- a/Makefile ++++ b/Makefile +@@ -4,20 +4,20 @@ ifeq ($(VERBOSE),0) + MAKEFLAGS += --no-print-directory + endif + +-PREFIX?=/usr +-LIBDIR?=$(PREFIX)/lib +-SBINDIR?=/sbin +-CONFDIR?=/etc/iproute2 +-DATADIR?=$(PREFIX)/share +-HDRDIR?=$(PREFIX)/include/iproute2 ++PREFIX= ++LIBDIR=/lib ++SBINDIR=/bin ++CONFDIR=/etc/iproute2 ++DATADIR=/share ++HDRDIR=/include/iproute2 + DOCDIR?=$(DATADIR)/doc/iproute2 + MANDIR?=$(DATADIR)/man + ARPDDIR?=/var/lib/arpd +-KERNEL_INCLUDE?=/usr/include ++KERNEL_INCLUDE=$(SYSROOT)/include + BASH_COMPDIR?=$(DATADIR)/bash-completion/completions + + # Path to db_185.h include +-DBM_INCLUDE:=$(DESTDIR)/usr/include ++DBM_INCLUDE:=$(SYSROOT)/include + + SHARED_LIBS = y + diff --git a/pkg/iproute2/0002.patch b/pkg/iproute2/0002.patch new file mode 100644 index 0000000..f3ceade --- /dev/null +++ b/pkg/iproute2/0002.patch @@ -0,0 +1,214 @@ +--- a/include/uapi/linux/if_ether.h ++++ b/include/uapi/linux/if_ether.h +@@ -22,6 +22,7 @@ + #define _LINUX_IF_ETHER_H + + #include ++#include + + /* + * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble +@@ -142,11 +143,13 @@ + * This is an Ethernet frame header. + */ + ++#if __UAPI_DEF_ETHHDR + struct ethhdr { + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ + unsigned char h_source[ETH_ALEN]; /* source ether addr */ + __be16 h_proto; /* packet type ID field */ + } __attribute__((packed)); ++#endif + + + #endif /* _LINUX_IF_ETHER_H */ +--- a/include/uapi/linux/if_tunnel.h ++++ b/include/uapi/linux/if_tunnel.h +@@ -2,7 +2,6 @@ + #define _IF_TUNNEL_H_ + + #include +-#include + #include + #include + #include +--- a/include/uapi/linux/ip6_tunnel.h ++++ b/include/uapi/linux/ip6_tunnel.h +@@ -2,7 +2,6 @@ + #define _IP6_TUNNEL_H + + #include +-#include /* For IFNAMSIZ. */ + #include /* For struct in6_addr. */ + + #define IPV6_TLV_TNL_ENCAP_LIMIT 4 +--- a/include/uapi/linux/kernel.h ++++ b/include/uapi/linux/kernel.h +@@ -1,7 +1,9 @@ + #ifndef _LINUX_KERNEL_H + #define _LINUX_KERNEL_H + ++#ifdef __GLIBC__ + #include ++#endif + + /* + * 'kernel.h' contains some often-used function prototypes etc +--- a/include/uapi/linux/libc-compat.h ++++ b/include/uapi/linux/libc-compat.h +@@ -48,47 +48,57 @@ + #ifndef _LIBC_COMPAT_H + #define _LIBC_COMPAT_H + +-/* We have included glibc headers... */ +-#if defined(__GLIBC__) ++/* We're used from userspace... */ ++#if !defined(__KERNEL__) + +-/* Coordinate with glibc net/if.h header. */ ++/* Coordinate with libc net/if.h header. */ + #if defined(_NET_IF_H) && defined(__USE_MISC) + +-/* GLIBC headers included first so don't define anything ++/* libc headers included first so don't define anything + * that would already be defined. */ + + #define __UAPI_DEF_IF_IFCONF 0 + #define __UAPI_DEF_IF_IFMAP 0 + #define __UAPI_DEF_IF_IFNAMSIZ 0 + #define __UAPI_DEF_IF_IFREQ 0 +-/* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */ + #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0 +-/* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */ ++/* If libc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */ ++#if !defined(__GLIBC__) ++#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0 ++#else + #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO + #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1 + #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */ ++#endif /* !defined(__GLIBC__) */ + + #else /* _NET_IF_H */ + + /* Linux headers included first, and we must define everything +- * we need. The expectation is that glibc will check the ++ * we need. The expectation is that libc will check the + * __UAPI_DEF_* defines and adjust appropriately. */ + + #define __UAPI_DEF_IF_IFCONF 1 + #define __UAPI_DEF_IF_IFMAP 1 + #define __UAPI_DEF_IF_IFNAMSIZ 1 + #define __UAPI_DEF_IF_IFREQ 1 +-/* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */ + #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1 +-/* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */ ++/* If libc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */ + #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1 + + #endif /* _NET_IF_H */ + +-/* Coordinate with glibc netinet/in.h header. */ ++/* Coordinate with libc netinet/if_ether.h */ ++#ifdef _NETINET_IF_ETHER_H ++#define __UAPI_DEF_ETHHDR 0 ++#else ++/* glibc uses __NETINET_IF_ETHER_H and uses the uapi header */ ++#define __UAPI_DEF_ETHHDR 1 ++#endif /* _NETINET_IF_ETHER_H */ ++ ++/* Coordinate with libc netinet/in.h header. */ + #if defined(_NETINET_IN_H) + +-/* GLIBC headers included first so don't define anything ++/* libc headers included first so don't define anything + * that would already be defined. */ + #define __UAPI_DEF_IN_ADDR 0 + #define __UAPI_DEF_IN_IPPROTO 0 +@@ -98,15 +108,7 @@ + #define __UAPI_DEF_IN_CLASS 0 + + #define __UAPI_DEF_IN6_ADDR 0 +-/* The exception is the in6_addr macros which must be defined +- * if the glibc code didn't define them. This guard matches +- * the guard in glibc/inet/netinet/in.h which defines the +- * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */ +-#if defined(__USE_MISC) || defined (__USE_GNU) + #define __UAPI_DEF_IN6_ADDR_ALT 0 +-#else +-#define __UAPI_DEF_IN6_ADDR_ALT 1 +-#endif + #define __UAPI_DEF_SOCKADDR_IN6 0 + #define __UAPI_DEF_IPV6_MREQ 0 + #define __UAPI_DEF_IPPROTO_V6 0 +@@ -117,7 +119,7 @@ + #else + + /* Linux headers included first, and we must define everything +- * we need. The expectation is that glibc will check the ++ * we need. The expectation is that libc will check the + * __UAPI_DEF_* defines and adjust appropriately. */ + #define __UAPI_DEF_IN_ADDR 1 + #define __UAPI_DEF_IN_IPPROTO 1 +@@ -127,7 +129,7 @@ + #define __UAPI_DEF_IN_CLASS 1 + + #define __UAPI_DEF_IN6_ADDR 1 +-/* We unconditionally define the in6_addr macros and glibc must ++/* We unconditionally define the in6_addr macros and libc must + * coordinate. */ + #define __UAPI_DEF_IN6_ADDR_ALT 1 + #define __UAPI_DEF_SOCKADDR_IN6 1 +@@ -168,18 +170,20 @@ + /* If we did not see any headers from any supported C libraries, + * or we are being included in the kernel, then define everything + * that we need. */ +-#else /* !defined(__GLIBC__) */ ++#else /* defined(__KERNEL__) */ + + /* Definitions for if.h */ + #define __UAPI_DEF_IF_IFCONF 1 + #define __UAPI_DEF_IF_IFMAP 1 + #define __UAPI_DEF_IF_IFNAMSIZ 1 + #define __UAPI_DEF_IF_IFREQ 1 +-/* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */ + #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1 +-/* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */ ++/* If libc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */ + #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1 + ++/* Definitions for if/ether.h */ ++#define __UAPI_DEF_ETHHDR 1 ++ + /* Definitions for in.h */ + #define __UAPI_DEF_IN_ADDR 1 + #define __UAPI_DEF_IN_IPPROTO 1 +@@ -208,6 +212,6 @@ + /* Definitions for xattr.h */ + #define __UAPI_DEF_XATTR 1 + +-#endif /* __GLIBC__ */ ++#endif /* defined(__KERNEL__) */ + + #endif /* _LIBC_COMPAT_H */ +--- a/include/uapi/linux/netfilter_ipv4/ip_tables.h ++++ b/include/uapi/linux/netfilter_ipv4/ip_tables.h +@@ -17,7 +17,6 @@ + + #include + +-#include + #include + + #include +--- a/tc/f_flower.c ++++ b/tc/f_flower.c +@@ -15,7 +15,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include diff --git a/pkg/iproute2/CREDITS b/pkg/iproute2/CREDITS new file mode 100644 index 0000000..347f817 --- /dev/null +++ b/pkg/iproute2/CREDITS @@ -0,0 +1,6 @@ +Thanks a lot to Alpine Linux for the musl-fixes.patch on which 0002.patch +is based. + +Original version: + +https://git.alpinelinux.org/cgit/aports/tree/main/iproute2/musl-fixes.patch diff --git a/pkg/iproute2/build b/pkg/iproute2/build new file mode 100755 index 0000000..a9f5cf0 --- /dev/null +++ b/pkg/iproute2/build @@ -0,0 +1,40 @@ +VERSION="4.14.1" +SRCDIR="iproute2-${VERSION}" +TARBALL="${SRCDIR}.tar.xz" +URL="https://www.kernel.org/pub/linux/utils/net/iproute2/" +SHA256SUM="d43ac068afcc350a448f4581b6e292331ef7e4e7aa746e34981582d5fdb10067" + +prepare() { + local PKGSCRIPTDIR="$1" + + for PATCH in ${PKGSCRIPTDIR}/*.patch; do + patch -p1 < $PATCH + done +} + +build() { + local SOURCE="$1" + local BUILD="$2" + + cp -r ${SOURCE}/* ${BUILD} + + make HOSTCC="gcc" AR="${TARGET}-ar" LD="${TARGET}-ld" CC="${TARGET}-gcc" SYSROOT="$TCDIR/$TARGET" +} + +deploy() { + local SOURCE="$1" + local BUILD="$2" + local DEPLOY="$3" + local DEVDEPLOY="$4" + + mkdir -p "$DEPLOY/var/lib/arpd" + make DESTDIR="$DEPLOY" SYSROOT="$TCDIR/$TARGET" install + + rm -r "$DEPLOY/include" + rm -r "$DEPLOY/share/doc" + rm -r "$DEPLOY/share/man" + + for program in arpd bridge devlink genl ifstat ip lnstat nstat rdma rtacct rtmon ss tc tipc; do + ${TARGET}-strip --discard-all ${DEPLOY}/bin/$program + done +} diff --git a/pkg/iproute2/depends b/pkg/iproute2/depends new file mode 100644 index 0000000..8f05870 --- /dev/null +++ b/pkg/iproute2/depends @@ -0,0 +1,2 @@ +bdb +libmnl