Skip to contentSkip to conversation

nativesdk: Handle chown/chgrp calls in nativesdk do_install tasks

PATCH In review Richard Purdie 2 participants 5 messages Nov 25, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 nativesdk: Handle chown/chgrp calls in nativesdk do_install tasks

We disable the useradd code for nativesdk targets since we don't support postinstalls or multiple users in those cases. This means any usage of chown/chgrp inside do_install tasks won't work and would have to be conditional. Rather than require all recipes to do that, add intercepts of the calls and map those to root/root user/groups. We can't just ignore them as some calls are used to remove host contamination from the host user ID so they need to be made, just as root.

---
 meta/classes/nativesdk.bbclass    |  2 ++
 scripts/nativesdk-intercept/chgrp | 27 +++++++++++++++++++++++++++
 scripts/nativesdk-intercept/chown | 27 +++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)
 create mode 100755 scripts/nativesdk-intercept/chgrp
 create mode 100755 scripts/nativesdk-intercept/chown
meta/classes/nativesdk.bbclass +2 -0
index 14e210562f1..f8e96075134 100644
@@ -113,3 +113,5 @@ do_packagedata[stamp-extra-info] = ""
 USE_NLS = "${SDKUSE_NLS}"
 
 OLDEST_KERNEL = "${SDK_OLDEST_KERNEL}"
+
+PATH:prepend = "${COREBASE}/scripts/nativesdk-intercept:"
scripts/nativesdk-intercept/chgrp new file +27 -0
new file mode 100755
index 00000000000..30cc417d3ac
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+#
+# Wrapper around 'chgrp' that redirects to root in all cases
+
+import os
+import shutil
+import sys
+
+# calculate path to the real 'chgrp'
+path = os.environ['PATH']
+path = path.replace(os.path.dirname(sys.argv[0]), '')
+real_chgrp = shutil.which('chgrp', path=path)
+
+args = list()
+
+found = False
+for i in sys.argv:
+    if i.startswith("-"):
+        args.append(i)
+        continue
+    if not found:
+        args.append("root")
+        found = True
+    else:
+        args.append(i)
+
+os.execv(real_chgrp, args)
scripts/nativesdk-intercept/chown new file +27 -0
new file mode 100755
index 00000000000..3914b3e3841
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+#
+# Wrapper around 'chown' that redirects to root in all cases
+
+import os
+import shutil
+import sys
+
+# calculate path to the real 'chown'
+path = os.environ['PATH']
+path = path.replace(os.path.dirname(sys.argv[0]), '')
+real_chown = shutil.which('chown', path=path)
+
+args = list()
+
+found = False
+for i in sys.argv:
+    if i.startswith("-"):
+        args.append(i)
+        continue
+    if not found:
+        args.append("root:root")
+        found = True
+    else:
+        args.append(i)
+
+os.execv(real_chown, args)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 2/3 gcc: Drop no longer needed patch

This patch was mentioned upstream a long time ago:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47256

Changes from gcc 10 onward mean it is no longer needed as mentioned in the above bug report. Drop the patch.

---
 meta/recipes-devtools/gcc/gcc-11.2.inc        |  1 -
 .../gcc/gcc/0006-COLLECT_GCC_OPTIONS.patch    | 35 -------------------
 2 files changed, 36 deletions(-)
 delete mode 100644 meta/recipes-devtools/gcc/gcc/0006-COLLECT_GCC_OPTIONS.patch
meta/recipes-devtools/gcc/gcc-11.2.inc +0 -1
index baced2a4007..b4e4300c66b 100644
@@ -34,7 +34,6 @@ SRC_URI = "\
            file://0002-gcc-poison-system-directories.patch \
            file://0004-64-bit-multilib-hack.patch \
            file://0005-optional-libstdc.patch \
-           file://0006-COLLECT_GCC_OPTIONS.patch \
            file://0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \
            file://0009-cpp-honor-sysroot.patch \
            file://0010-MIPS64-Default-to-N64-ABI.patch \
meta/recipes-devtools/gcc/gcc/0006-COLLECT_GCC_OPTIONS.patch deleted +0 -35
deleted file mode 100644
index 265ca0e2187..00000000000
@@ -1,35 +0,0 @@
-From 127716a32a11ca2a6b3aac068054bfc69c4dcfd8 Mon Sep 17 00:00:00 2001
-From: Khem Raj <[email protected]>
-Date: Fri, 29 Mar 2013 09:16:28 +0400
-Subject: [PATCH] COLLECT_GCC_OPTIONS
-
-This patch adds --sysroot into COLLECT_GCC_OPTIONS which is used to
-invoke collect2.
-
-Signed-off-by: Khem Raj <[email protected]>
-
-Upstream-Status: Pending
----
- gcc/gcc.c | 9 +++++++++
- 1 file changed, 9 insertions(+)
-
-diff --git a/gcc/gcc.c b/gcc/gcc.c
-index be7630ffd8c..1bc45285384 100644
---- a/gcc/gcc.c
-+++ b/gcc/gcc.c
-@@ -5383,6 +5383,15 @@ set_collect_gcc_options (void)
- 		sizeof ("COLLECT_GCC_OPTIONS=") - 1);
- 
-   first_time = TRUE;
-+#ifdef HAVE_LD_SYSROOT
-+  if (target_system_root_changed && target_system_root)
-+    {
-+      obstack_grow (&collect_obstack, "'--sysroot=", sizeof("'--sysroot=")-1);
-+      obstack_grow (&collect_obstack, target_system_root,strlen(target_system_root));
-+      obstack_grow (&collect_obstack, "'", 1);
-+      first_time = FALSE;
-+    }
-+#endif
-   for (i = 0; (int) i < n_switches; i++)
-     {
-       const char *const *args;
Signature · 1 line
2.32.0
#2 lore raw

Re: [OE-core] [PATCH 2/3] gcc: Drop no longer needed patch

Quoted 7 lines · Richard Purdie

This patch was mentioned upstream a long time ago:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47256

Changes from gcc 10 onward mean it is no longer needed as mentioned in the above bug report. Drop the patch.

this looks ok.

Quoted 71 lines
---
  meta/recipes-devtools/gcc/gcc-11.2.inc        |  1 -
  .../gcc/gcc/0006-COLLECT_GCC_OPTIONS.patch    | 35 -------------------
  2 files changed, 36 deletions(-)

delete mode 100644 meta/recipes-devtools/gcc/gcc/0006-COLLECT_GCC_OPTIONS.patch

meta/recipes-devtools/gcc/gcc-11.2.inc +0 -1
index baced2a4007..b4e4300c66b 100644
@@ -34,7 +34,6 @@ SRC_URI = "\
             file://0002-gcc-poison-system-directories.patch \
             file://0004-64-bit-multilib-hack.patch \
             file://0005-optional-libstdc.patch \
-           file://0006-COLLECT_GCC_OPTIONS.patch \
             file://0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \
             file://0009-cpp-honor-sysroot.patch \
             file://0010-MIPS64-Default-to-N64-ABI.patch \
meta/recipes-devtools/gcc/gcc/0006-COLLECT_GCC_OPTIONS.patch deleted +0 -36
deleted file mode 100644
index 265ca0e2187..00000000000
@@ -1,35 +0,0 @@
-From 127716a32a11ca2a6b3aac068054bfc69c4dcfd8 Mon Sep 17 00:00:00 2001
-From: Khem Raj <[email protected]>
-Date: Fri, 29 Mar 2013 09:16:28 +0400
-Subject: [PATCH] COLLECT_GCC_OPTIONS
-
-This patch adds --sysroot into COLLECT_GCC_OPTIONS which is used to
-invoke collect2.
-
-Signed-off-by: Khem Raj <[email protected]>
-
-Upstream-Status: Pending
----
- gcc/gcc.c | 9 +++++++++
- 1 file changed, 9 insertions(+)
-
-diff --git a/gcc/gcc.c b/gcc/gcc.c
-index be7630ffd8c..1bc45285384 100644
---- a/gcc/gcc.c
-+++ b/gcc/gcc.c
-@@ -5383,6 +5383,15 @@ set_collect_gcc_options (void)
- 		sizeof ("COLLECT_GCC_OPTIONS=") - 1);
-
-   first_time = TRUE;
-+#ifdef HAVE_LD_SYSROOT
-+  if (target_system_root_changed && target_system_root)
-+    {
-+      obstack_grow (&collect_obstack, "'--sysroot=", sizeof("'--sysroot=")-1);
-+      obstack_grow (&collect_obstack, target_system_root,strlen(target_system_root));
-+      obstack_grow (&collect_obstack, "'", 1);
-+      first_time = FALSE;
-+    }
-+#endif
-   for (i = 0; (int) i < n_switches; i++)
-     {
-       const char *const *args;
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#158781): https://lists.openembedded.org/g/openembedded-core/message/158781
Mute This Topic: https://lists.openembedded.org/mt/87304168/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw

PATCH 3/3 gcc: Drop mips default ABI patch

In reply to Richard Purdie

gcc-configure-common.inc already sets --with-abi=64 for our mips64 targets so this patch is no longer needed.

[YOCTO #14639]

---
 meta/recipes-devtools/gcc/gcc-11.2.inc        |  1 -
 .../gcc/0010-MIPS64-Default-to-N64-ABI.patch  | 54 -------------------
 2 files changed, 55 deletions(-)
 delete mode 100644 meta/recipes-devtools/gcc/gcc/0010-MIPS64-Default-to-N64-ABI.patch
meta/recipes-devtools/gcc/gcc-11.2.inc +0 -1
index b4e4300c66b..afb8f2df5c2 100644
@@ -36,7 +36,6 @@ SRC_URI = "\
            file://0005-optional-libstdc.patch \
            file://0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \
            file://0009-cpp-honor-sysroot.patch \
-           file://0010-MIPS64-Default-to-N64-ABI.patch \
            file://0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \
            file://0012-gcc-Fix-argument-list-too-long-error.patch \
            file://0014-libtool.patch \
meta/recipes-devtools/gcc/gcc/0010-MIPS64-Default-to-N64-ABI.patch deleted +0 -54

54 lines not on this page · raw message

Signature · 1 line
2.32.0
#4 lore raw

Re: [OE-core] [PATCH 3/3] gcc: Drop mips default ABI patch

Quoted 2 lines · Richard Purdie

gcc-configure-common.inc already sets --with-abi=64 for our mips64 targets so this patch is no longer needed.

sounds good. Long time ago, IIRC it did not work for compiling the target gcc so it has to be enforced but I agree one less patch is better now.

Quoted 93 lines

[YOCTO #14639]

---
  meta/recipes-devtools/gcc/gcc-11.2.inc        |  1 -
  .../gcc/0010-MIPS64-Default-to-N64-ABI.patch  | 54 -------------------
  2 files changed, 55 deletions(-)

delete mode 100644 meta/recipes-devtools/gcc/gcc/0010-MIPS64-Default-to-N64-ABI.patch

meta/recipes-devtools/gcc/gcc-11.2.inc +0 -1
index b4e4300c66b..afb8f2df5c2 100644
@@ -36,7 +36,6 @@ SRC_URI = "\
             file://0005-optional-libstdc.patch \
             file://0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \
             file://0009-cpp-honor-sysroot.patch \
-           file://0010-MIPS64-Default-to-N64-ABI.patch \
             file://0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \
             file://0012-gcc-Fix-argument-list-too-long-error.patch \
             file://0014-libtool.patch \
meta/recipes-devtools/gcc/gcc/0010-MIPS64-Default-to-N64-ABI.patch deleted +0 -55
deleted file mode 100644
index f385f8c5a20..00000000000
@@ -1,54 +0,0 @@
-From a2dc2fa4cc7e5d54544d4a7b6601eef79bc26cad Mon Sep 17 00:00:00 2001
-From: Khem Raj <[email protected]>
-Date: Fri, 29 Mar 2013 09:23:08 +0400
-Subject: [PATCH] MIPS64: Default to N64 ABI
-
-MIPS64 defaults to n32 ABI, this patch makes it
-so that it defaults to N64 ABI
-
-Signed-off-by: Khem Raj <[email protected]>
-
-Upstream-Status: Inappropriate [OE config specific]
----
- gcc/config.gcc | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/gcc/config.gcc b/gcc/config.gcc
-index 3ec7582f5dd..a046fa6945c 100644
---- a/gcc/config.gcc
-+++ b/gcc/config.gcc
-@@ -2543,29 +2543,29 @@ mips*-*-linux*)				# Linux MIPS, either endian.
- 			default_mips_arch=mips32
- 			;;
- 		mips64el-st-linux-gnu)
--			default_mips_abi=n32
-+			default_mips_abi=64
- 			tm_file="${tm_file} mips/st.h"
- 			tmake_file="${tmake_file} mips/t-st"
- 			enable_mips_multilibs="yes"
- 			;;
- 		mips64octeon*-*-linux*)
--			default_mips_abi=n32
-+			default_mips_abi=64
- 			tm_defines="${tm_defines} MIPS_CPU_STRING_DEFAULT=\\\"octeon\\\""
- 			target_cpu_default=MASK_SOFT_FLOAT_ABI
- 			enable_mips_multilibs="yes"
- 			;;
- 		mipsisa64r6*-*-linux*)
--			default_mips_abi=n32
-+			default_mips_abi=64
- 			default_mips_arch=mips64r6
- 			enable_mips_multilibs="yes"
- 			;;
- 		mipsisa64r2*-*-linux*)
--			default_mips_abi=n32
-+			default_mips_abi=64
- 			default_mips_arch=mips64r2
- 			enable_mips_multilibs="yes"
- 			;;
- 		mips64*-*-linux* | mipsisa64*-*-linux*)
--			default_mips_abi=n32
-+			default_mips_abi=64
- 			enable_mips_multilibs="yes"
- 			;;
- 	esac
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#158783): https://lists.openembedded.org/g/openembedded-core/message/158783
Mute This Topic: https://lists.openembedded.org/mt/87304170/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-