diff options
author | Alexander Kanavin <alex.kanavin@gmail.com> | 2023-04-04 17:15:18 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-04-11 11:31:52 +0100 |
commit | 312dfcc29b009ba8ac14da9fadcf9e5f68ea43d3 (patch) | |
tree | f0c4e06bee179e8f16497e122cc02e5312ff0b4c | |
parent | 34d843dada61f91ddce07bb900f71a145ebe886f (diff) | |
download | poky-312dfcc29b009ba8ac14da9fadcf9e5f68ea43d3.tar.gz |
patchelf: replace a rejected patch with an equivalent uninative.bbclass tweak
This was the original reason to add the patch:
https://git.openembedded.org/openembedded-core/commit/?id=18efcbcb896239c64fedd009ce57f3f0c668cbc0
and this is the upstream discussion which suggests handling
read-only files explicitly outside of patchelf:
https://github.com/NixOS/patchelf/pull/89
(From OE-Core rev: 163e2d5defebab262a5ec6fa9885deedace538f2)
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/uninative.bbclass | 2 | ||||
-rw-r--r-- | meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch | 65 | ||||
-rw-r--r-- | meta/recipes-devtools/patchelf/patchelf_0.14.5.bb | 1 |
3 files changed, 2 insertions, 66 deletions
diff --git a/meta/classes/uninative.bbclass b/meta/classes/uninative.bbclass index 6a9e862bcd..7f0591d49a 100644 --- a/meta/classes/uninative.bbclass +++ b/meta/classes/uninative.bbclass | |||
@@ -167,5 +167,7 @@ python uninative_changeinterp () { | |||
167 | if not elf.isDynamic(): | 167 | if not elf.isDynamic(): |
168 | continue | 168 | continue |
169 | 169 | ||
170 | os.chmod(f, s[stat.ST_MODE] | stat.S_IWUSR) | ||
170 | subprocess.check_output(("patchelf-uninative", "--set-interpreter", d.getVar("UNINATIVE_LOADER"), f), stderr=subprocess.STDOUT) | 171 | subprocess.check_output(("patchelf-uninative", "--set-interpreter", d.getVar("UNINATIVE_LOADER"), f), stderr=subprocess.STDOUT) |
172 | os.chmod(f, s[stat.ST_MODE]) | ||
171 | } | 173 | } |
diff --git a/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch b/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch deleted file mode 100644 index b755a263a4..0000000000 --- a/meta/recipes-devtools/patchelf/patchelf/handle-read-only-files.patch +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | From 682fb48c137b687477008b68863c2a0b73ed47d1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Fabio Berton <fabio.berton@ossystems.com.br> | ||
3 | Date: Fri, 9 Sep 2016 16:00:42 -0300 | ||
4 | Subject: [PATCH] handle read-only files | ||
5 | |||
6 | Patch from: | ||
7 | https://github.com/darealshinji/patchelf/commit/40e66392bc4b96e9b4eda496827d26348a503509 | ||
8 | |||
9 | Upstream-Status: Denied [https://github.com/NixOS/patchelf/pull/89] | ||
10 | |||
11 | Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br> | ||
12 | |||
13 | --- | ||
14 | src/patchelf.cc | 16 +++++++++++++++- | ||
15 | 1 file changed, 15 insertions(+), 1 deletion(-) | ||
16 | |||
17 | Index: git/src/patchelf.cc | ||
18 | =================================================================== | ||
19 | --- git.orig/src/patchelf.cc | ||
20 | +++ git/src/patchelf.cc | ||
21 | @@ -534,9 +534,19 @@ void ElfFile<ElfFileParamNames>::sortShd | ||
22 | |||
23 | static void writeFile(const std::string & fileName, const FileContents & contents) | ||
24 | { | ||
25 | + struct stat st; | ||
26 | + int fd; | ||
27 | + | ||
28 | debug("writing %s\n", fileName.c_str()); | ||
29 | |||
30 | - int fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0777); | ||
31 | + if (stat(fileName.c_str(), &st) != 0) | ||
32 | + error("stat"); | ||
33 | + | ||
34 | + if (chmod(fileName.c_str(), 0600) != 0) | ||
35 | + error("chmod"); | ||
36 | + | ||
37 | + fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0777); | ||
38 | + | ||
39 | if (fd == -1) | ||
40 | error("open"); | ||
41 | |||
42 | @@ -551,8 +561,6 @@ static void writeFile(const std::string | ||
43 | bytesWritten += portion; | ||
44 | } | ||
45 | |||
46 | - if (close(fd) >= 0) | ||
47 | - return; | ||
48 | /* | ||
49 | * Just ignore EINTR; a retry loop is the wrong thing to do. | ||
50 | * | ||
51 | @@ -561,9 +569,11 @@ static void writeFile(const std::string | ||
52 | * http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR | ||
53 | * https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain | ||
54 | */ | ||
55 | - if (errno == EINTR) | ||
56 | - return; | ||
57 | - error("close"); | ||
58 | + if ((close(fd) < 0) && errno != EINTR) | ||
59 | + error("close"); | ||
60 | + | ||
61 | + if (chmod(fileName.c_str(), st.st_mode) != 0) | ||
62 | + error("chmod"); | ||
63 | } | ||
64 | |||
65 | |||
diff --git a/meta/recipes-devtools/patchelf/patchelf_0.14.5.bb b/meta/recipes-devtools/patchelf/patchelf_0.14.5.bb index 0fa2c00f1d..82c7e807ac 100644 --- a/meta/recipes-devtools/patchelf/patchelf_0.14.5.bb +++ b/meta/recipes-devtools/patchelf/patchelf_0.14.5.bb | |||
@@ -5,7 +5,6 @@ HOMEPAGE = "https://github.com/NixOS/patchelf" | |||
5 | LICENSE = "GPL-3.0-only" | 5 | LICENSE = "GPL-3.0-only" |
6 | 6 | ||
7 | SRC_URI = "git://github.com/NixOS/patchelf;protocol=https;branch=master \ | 7 | SRC_URI = "git://github.com/NixOS/patchelf;protocol=https;branch=master \ |
8 | file://handle-read-only-files.patch \ | ||
9 | " | 8 | " |
10 | SRCREV = "a35054504293f9ff64539850d1ed0bfd2f5399f2" | 9 | SRCREV = "a35054504293f9ff64539850d1ed0bfd2f5399f2" |
11 | 10 | ||