From 1faf424b35f1c87994ef27638d2deb04793619de Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 1 Jul 2015 23:11:51 +0200 Subject: [PATCH] batman-adv-legacy: fix applying batctl patches and fix musl build --- net/batman-adv-legacy/Makefile | 9 +-- ...l-Add-required-includes-to-all-files.patch | 57 +++++++++++++++ ...-Fix-inconsistent-use-of-_GNU_SOURCE.patch | 71 +++++++++++++++++++ ...e-sys-types.h-for-caddr_t-definition.patch | 27 +++++++ 4 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 net/batman-adv-legacy/patches/0002-batctl-Add-required-includes-to-all-files.patch create mode 100644 net/batman-adv-legacy/patches/0003-batctl-Fix-inconsistent-use-of-_GNU_SOURCE.patch create mode 100644 net/batman-adv-legacy/patches/0004-batctl-Include-sys-types.h-for-caddr_t-definition.patch diff --git a/net/batman-adv-legacy/Makefile b/net/batman-adv-legacy/Makefile index f059bb5..0f420e8 100644 --- a/net/batman-adv-legacy/Makefile +++ b/net/batman-adv-legacy/Makefile @@ -11,6 +11,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batman-adv-legacy PKG_VERSION:=2015-01-11 +PKG_RELEASE:=2 BATCTL_VERSION:=2013.4.0 BATCTL_MD5SUM:=42e269cc710bbc9a8fd17628201d4258 @@ -95,7 +96,7 @@ endef $(eval $(call Download,batctl-legacy)) BATCTL_EXTRACT = tar xzf "$(DL_DIR)/batctl-$(BATCTL_VERSION).tar.gz" -C "$(BUILD_DIR)/$(PKG_NAME)" -BATCTL_PATCH = $(call Build/DoPatch,"$(PKG_BATCTL_BUILD_DIR)","$(PATCH_DIR)",".*batctl.*") +BATCTL_PATCH = $(call Build/DoPatch,"$(PKG_BATCTL_BUILD_DIR)","$(PATCH_DIR)",batctl) BATCTL_BUILD = $(MAKE_BATCTL_ENV) $(MAKE) -C $(PKG_BATCTL_BUILD_DIR) $(MAKE_BATCTL_ARGS) BATCTL_INSTALL = $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/local/sbin/batctl $(1)/usr/sbin/ endif @@ -103,14 +104,14 @@ endif KPATCH ?= $(PATCH) define Build/DoPatch @if [ -d "$(2)" ]; then \ - if [ "$$$$(ls $(2) | grep -Ec $(3))" -gt 0 ]; then \ - $(KPATCH) "$(1)" "$(2)" "$(3)"; \ + if [ "$$$$(ls $(2) | grep -Ec ',*$(3).*')" -gt 0 ]; then \ + $(KPATCH) "$(1)" "$(2)" "*$(3)*"; \ fi; \ fi endef define Build/Patch - $(call Build/DoPatch,"$(PKG_BUILD_DIR)","$(PATCH_DIR)",".*batman.*") + $(call Build/DoPatch,"$(PKG_BUILD_DIR)","$(PATCH_DIR)",batman) $(BATCTL_EXTRACT) $(BATCTL_PATCH) endef diff --git a/net/batman-adv-legacy/patches/0002-batctl-Add-required-includes-to-all-files.patch b/net/batman-adv-legacy/patches/0002-batctl-Add-required-includes-to-all-files.patch new file mode 100644 index 0000000..02319b0 --- /dev/null +++ b/net/batman-adv-legacy/patches/0002-batctl-Add-required-includes-to-all-files.patch @@ -0,0 +1,57 @@ +From f9b50cd48c8cca1b9c7e8b8f6611265cc62674e1 Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: <704e64165f8d37c42fd13652cf8b1c0f56f37cd6.1435782705.git.mschiffer@universe-factory.net> +References: <704e64165f8d37c42fd13652cf8b1c0f56f37cd6.1435782705.git.mschiffer@universe-factory.net> +From: Sven Eckelmann +Date: Fri, 17 Apr 2015 19:40:28 +0200 +Subject: [PATCH 2/2] batctl: Add required includes to all files + +The header files could not be build indepdent from each other. This is happened +because headers didn't include the files for things they've used. This was +problematic because the success of a build depended on the knowledge about the +right order of local includes. + +Also source files were not including everything they've used explicitly. +Instead they required that transitive includes are always stable. This is +problematic because some transitive includes are not obvious, depend on config +settings and may not be stable in the future. + +The order for include blocks are: + + * primary headers (main.h and the *.h file of a *.c file) + * global linux headers + * required local headers + * extra forward declarations for pointers in function/struct declarations + +The only exceptions are linux/bitops.h and linux/if_ether.h in packet.h. This +header file is shared with userspace applications like batctl and must +therefore build together with userspace applications. The header linux/bitops.h +is not part of the uapi headers and linux/if_ether.h conflicts with the musl +implementation of netinet/if_ether.h. The maintainers rejected the use of +__KERNEL__ preprocessor checks and thus these two headers are only in main.h. +All files using packet.h first have to include main.h to work correctly. + +Reported-by: Markus Pargmann +Signed-off-by: Sven Eckelmann +Signed-off-by: Marek Lindner +--- + packet.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/packet.h b/packet.h +index a51ccfc..3767a86 100644 +--- a/packet.h ++++ b/packet.h +@@ -20,6 +20,9 @@ + #ifndef _NET_BATMAN_ADV_PACKET_H_ + #define _NET_BATMAN_ADV_PACKET_H_ + ++#include ++#include ++ + enum batadv_packettype { + BATADV_IV_OGM = 0x01, + BATADV_ICMP = 0x02, +-- +2.4.5 + diff --git a/net/batman-adv-legacy/patches/0003-batctl-Fix-inconsistent-use-of-_GNU_SOURCE.patch b/net/batman-adv-legacy/patches/0003-batctl-Fix-inconsistent-use-of-_GNU_SOURCE.patch new file mode 100644 index 0000000..fb436f1 --- /dev/null +++ b/net/batman-adv-legacy/patches/0003-batctl-Fix-inconsistent-use-of-_GNU_SOURCE.patch @@ -0,0 +1,71 @@ +From e718de23e6cf05c75d3cd352de3ae50ff40adbef Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: <704e64165f8d37c42fd13652cf8b1c0f56f37cd6.1435784617.git.mschiffer@universe-factory.net> +References: <704e64165f8d37c42fd13652cf8b1c0f56f37cd6.1435784617.git.mschiffer@universe-factory.net> +From: Sven Eckelmann +Date: Tue, 10 Sep 2013 23:11:53 +0200 +Subject: [PATCH 3/3] batctl: Fix inconsistent use of _GNU_SOURCE + +Either all or no source file should define _GNU_SOURCE to avoid incompatible +types or function declarations. + +Signed-off-by: Sven Eckelmann +Signed-off-by: Marek Lindner +--- + Makefile | 1 + + bat-hosts.c | 1 - + functions.c | 1 - + vis.c | 1 - + 4 files changed, 1 insertion(+), 3 deletions(-) + +diff --git a/Makefile b/Makefile +index 233f453..9e7c5be 100755 +--- a/Makefile ++++ b/Makefile +@@ -30,6 +30,7 @@ MANPAGE = man/batctl.8 + + # batctl flags and options + CFLAGS += -pedantic -Wall -W -std=gnu99 -fno-strict-aliasing -MD ++CPPFLAGS += -D_GNU_SOURCE + LDLIBS += -lm + + # disable verbose output +diff --git a/bat-hosts.c b/bat-hosts.c +index 04e7a9b..053c26f 100644 +--- a/bat-hosts.c ++++ b/bat-hosts.c +@@ -21,7 +21,6 @@ + + + +-#define _GNU_SOURCE + #include + #include + #include +diff --git a/functions.c b/functions.c +index cc05a48..66f9a7d 100644 +--- a/functions.c ++++ b/functions.c +@@ -20,7 +20,6 @@ + */ + + +-#define _GNU_SOURCE + #include + #include + #include +diff --git a/vis.c b/vis.c +index 33c7a7f..add93fd 100644 +--- a/vis.c ++++ b/vis.c +@@ -19,7 +19,6 @@ + * + */ + +-#define _GNU_SOURCE + #include + #include + #include +-- +2.4.5 + diff --git a/net/batman-adv-legacy/patches/0004-batctl-Include-sys-types.h-for-caddr_t-definition.patch b/net/batman-adv-legacy/patches/0004-batctl-Include-sys-types.h-for-caddr_t-definition.patch new file mode 100644 index 0000000..9849439 --- /dev/null +++ b/net/batman-adv-legacy/patches/0004-batctl-Include-sys-types.h-for-caddr_t-definition.patch @@ -0,0 +1,27 @@ +From b6d87da52915aec1f012e9f048dfedb3fc61a824 Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: <704e64165f8d37c42fd13652cf8b1c0f56f37cd6.1435784837.git.mschiffer@universe-factory.net> +References: <704e64165f8d37c42fd13652cf8b1c0f56f37cd6.1435784837.git.mschiffer@universe-factory.net> +From: Matthias Schiffer +Date: Wed, 1 Jul 2015 23:06:48 +0200 +Subject: [PATCH 4/4] batctl: Include for caddr_t definition + +--- + ioctl.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/ioctl.c b/ioctl.c +index 26bb482..393521c 100644 +--- a/ioctl.c ++++ b/ioctl.c +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + #include + #include + #include +-- +2.4.5 +