[meta-selinux][PATCH 05/17] libselinux: upgrade to 3.1 (20200710)


Yi Zhao
 

Drop backported and obsolete patches:
0001-Fix-building-against-musl-and-uClibc-libc-libraries.patch
libselinux-drop-Wno-unused-but-set-variable.patch

Add patch to fix build on musl:
0001-libselinux-do-not-define-gettid-for-musl.patch

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
...ainst-musl-and-uClibc-libc-libraries.patch | 38 ---------------
...elinux-do-not-define-gettid-for-musl.patch | 47 +++++++++++++++++++
...nux-drop-Wno-unused-but-set-variable.patch | 26 ----------
recipes-security/selinux/libselinux_3.0.bb | 15 ------
recipes-security/selinux/libselinux_3.1.bb | 17 +++++++
5 files changed, 64 insertions(+), 79 deletions(-)
delete mode 100644 recipes-security/selinux/libselinux/0001-Fix-building-against-musl-and-uClibc-libc-libraries.patch
create mode 100644 recipes-security/selinux/libselinux/0001-libselinux-do-not-define-gettid-for-musl.patch
delete mode 100644 recipes-security/selinux/libselinux/libselinux-drop-Wno-unused-but-set-variable.patch
delete mode 100644 recipes-security/selinux/libselinux_3.0.bb
create mode 100644 recipes-security/selinux/libselinux_3.1.bb

diff --git a/recipes-security/selinux/libselinux/0001-Fix-building-against-musl-and-uClibc-libc-libraries.patch b/recipes-security/selinux/libselinux/0001-Fix-building-against-musl-and-uClibc-libc-libraries.patch
deleted file mode 100644
index 8308553..0000000
--- a/recipes-security/selinux/libselinux/0001-Fix-building-against-musl-and-uClibc-libc-libraries.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From 61bfcbffce32be51d712040c3f84293b78428184 Mon Sep 17 00:00:00 2001
-From: Adam Duskett <Aduskett@gmail.com>
-Date: Tue, 7 Apr 2020 13:53:05 -0700
-Subject: [PATCH] Fix building against musl and uClibc libc libraries.
-
-Currently, the src/Makefile provides the FTS_LDLIBS when building against musl
-or uClibc. However, this is missing from utils/Makefile, which causes linking
-to fail.
-
-Add the FTS_LDLIBS variable to the LDLIBS variable in utils/Makefile to fix
-compiling against uClibc and musl.
-
-Signed-off-by: Adam Duskett <Aduskett@gmail.com>
-
-Upstream-Status: Backport
-[https://github.com/SELinuxProject/selinux/commit/aa40067b7b86d5e4c951fccae1aa98baff148613]
-
-Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
----
- utils/Makefile | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/utils/Makefile b/utils/Makefile
-index 3615063..a5632b7 100644
---- a/utils/Makefile
-+++ b/utils/Makefile
-@@ -45,7 +45,7 @@ endif
-
- override CFLAGS += -I../include -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
- override LDFLAGS += -L../src
--override LDLIBS += -lselinux
-+override LDLIBS += -lselinux $(FTS_LDLIBS)
- PCRE_LDLIBS ?= -lpcre
-
- ifeq ($(ANDROID_HOST),y)
---
-2.7.4
-
diff --git a/recipes-security/selinux/libselinux/0001-libselinux-do-not-define-gettid-for-musl.patch b/recipes-security/selinux/libselinux/0001-libselinux-do-not-define-gettid-for-musl.patch
new file mode 100644
index 0000000..5d6e409
--- /dev/null
+++ b/recipes-security/selinux/libselinux/0001-libselinux-do-not-define-gettid-for-musl.patch
@@ -0,0 +1,47 @@
+From 5f6f4a095bc82b29c3871d4d8a15d9c16cef39ef Mon Sep 17 00:00:00 2001
+From: Yi Zhao <yi.zhao@windriver.com>
+Date: Wed, 6 Jan 2021 10:42:11 +0800
+Subject: [PATCH] libselinux: do not define gettid() for musl
+
+The musl has implemented gettid() function:
+http://git.musl-libc.org/cgit/musl/commit/?id=d49cf07541bb54a5ac7aec1feec8514db33db8ea
+
+Fixes:
+procattr.c:38:14: error: static declaration of 'gettid' follows non-static declaration
+ 38 | static pid_t gettid(void)
+ | ^~~~~~
+In file included from procattr.c:2:
+/build/tmp/work/core2-32-poky-linux-musl/libselinux/3.1-r0/recipe-sysroot/usr/include/unistd.h:194:7:
+note: previous declaration of 'gettid' was here
+ 194 | pid_t gettid(void);
+ | ^~~~~~
+
+Upstream-Status: Pending
+
+Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
+---
+ src/procattr.c | 8 +-------
+ 1 file changed, 1 insertion(+), 7 deletions(-)
+
+diff --git a/src/procattr.c b/src/procattr.c
+index 926ee54..519e515 100644
+--- a/src/procattr.c
++++ b/src/procattr.c
+@@ -24,13 +24,7 @@ static __thread char destructor_initialized;
+
+ /* Bionic and glibc >= 2.30 declare gettid() system call wrapper in unistd.h and
+ * has a definition for it */
+-#ifdef __BIONIC__
+- #define OVERRIDE_GETTID 0
+-#elif !defined(__GLIBC_PREREQ)
+- #define OVERRIDE_GETTID 1
+-#elif !__GLIBC_PREREQ(2,30)
+- #define OVERRIDE_GETTID 1
+-#else
++#if !defined(__GLIBC_)
+ #define OVERRIDE_GETTID 0
+ #endif
+
+--
+2.17.1
+
diff --git a/recipes-security/selinux/libselinux/libselinux-drop-Wno-unused-but-set-variable.patch b/recipes-security/selinux/libselinux/libselinux-drop-Wno-unused-but-set-variable.patch
deleted file mode 100644
index 688b4e3..0000000
--- a/recipes-security/selinux/libselinux/libselinux-drop-Wno-unused-but-set-variable.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 865b8c40b331235ce2c9df1fcbbb3876c9b79338 Mon Sep 17 00:00:00 2001
-From: Randy MacLeod <Randy.MacLeod@windriver.com>
-Date: Tue, 30 Apr 2013 17:28:34 -0400
-Subject: [PATCH] libselinux: drop flag: -Wno-unused-but-set-variable
-
-Upstream status: Inappropriate [older compilers only]
-
-Signed-off-by: Randy MacLeod <Randy.MacLeod@windriver.com>
-
----
- src/Makefile | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/Makefile b/src/Makefile
-index 2408fae..a89c0f7 100644
---- a/src/Makefile
-+++ b/src/Makefile
-@@ -96,7 +96,7 @@ PCRE_LDLIBS ?= -lpcre
-
- override CFLAGS += -I../include -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
-
--SWIG_CFLAGS += -Wno-error -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter \
-+SWIG_CFLAGS += -Wno-error -Wno-unused-variable -Wno-unused-parameter \
- -Wno-shadow -Wno-uninitialized -Wno-missing-prototypes -Wno-missing-declarations
-
- RANLIB ?= ranlib
diff --git a/recipes-security/selinux/libselinux_3.0.bb b/recipes-security/selinux/libselinux_3.0.bb
deleted file mode 100644
index 05d2346..0000000
--- a/recipes-security/selinux/libselinux_3.0.bb
+++ /dev/null
@@ -1,15 +0,0 @@
-require selinux_20191204.inc
-require ${BPN}.inc
-
-LIC_FILES_CHKSUM = "file://LICENSE;md5=84b4d2c6ef954a2d4081e775a270d0d0"
-
-SRC_URI[md5sum] = "b387a66f087b6d97713570e85ec89d89"
-SRC_URI[sha256sum] = "2ea2b30f671dae9d6b1391cbe8fb2ce5d36a3ee4fb1cd3c32f0d933c31b82433"
-
-SRC_URI += "\
- file://libselinux-drop-Wno-unused-but-set-variable.patch \
- file://libselinux-make-O_CLOEXEC-optional.patch \
- file://libselinux-make-SOCK_CLOEXEC-optional.patch \
- file://libselinux-define-FD_CLOEXEC-as-necessary.patch \
- file://0001-Fix-building-against-musl-and-uClibc-libc-libraries.patch \
- "
diff --git a/recipes-security/selinux/libselinux_3.1.bb b/recipes-security/selinux/libselinux_3.1.bb
new file mode 100644
index 0000000..9d1cda5
--- /dev/null
+++ b/recipes-security/selinux/libselinux_3.1.bb
@@ -0,0 +1,17 @@
+require selinux_20200710.inc
+require ${BPN}.inc
+
+LIC_FILES_CHKSUM = "file://LICENSE;md5=84b4d2c6ef954a2d4081e775a270d0d0"
+
+SRC_URI[md5sum] = "693680c021feb69a4b258b0370021461"
+SRC_URI[sha256sum] = "ea5dcbb4d859e3f999c26a13c630da2f16dff9462e3cc8cb7b458ac157d112e7"
+
+SRC_URI += "\
+ file://libselinux-make-O_CLOEXEC-optional.patch \
+ file://libselinux-make-SOCK_CLOEXEC-optional.patch \
+ file://libselinux-define-FD_CLOEXEC-as-necessary.patch \
+ "
+
+SRC_URI_append_libc-musl = " \
+ file://0001-libselinux-do-not-define-gettid-for-musl.patch \
+ "
--
2.25.1