summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Zhukov <pavel@zhukoff.net>2024-10-10 19:45:45 +0200
committerSteve Sakoman <steve@sakoman.com>2024-11-26 06:11:30 -0800
commit1a526844db586a84978f23393b981da76c55ae41 (patch)
treedf26a9160c5bb5e0749a329b8d107a6ba47840a4
parentc81f1bb300e5b686f5595e194f6fc0986dd15391 (diff)
downloadpoky-1a526844db586a84978f23393b981da76c55ae41.tar.gz
package_rpm: Check if file exists before open()
Exception handler tries to read() /etc/passwd file in sysroot and if file doesn't exist for any reason then it raises FileNotFoundError exception which mask the original source of the problem and makes debugging of the issue more difficult. Fixes: Exception: FileNotFoundError: [Errno 2] No such file or directory: '/codebuild/output/src1899304708/src/build/tmp-container/work/core2-64-oe-linux/emqx-bin/4.3.12/recipe-sysroot/etc/passwd' (From OE-Core rev: 1adfa8b78991764ed1f9951c5bee5412553f3b9d) Signed-off-by: Pavel Zhukov <pavel@zhukoff.net> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 4ad9a0e0b11eb7bc5a3dd45fc8945e094ea949e9) Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/classes-global/package_rpm.bbclass16
1 files changed, 12 insertions, 4 deletions
diff --git a/meta/classes-global/package_rpm.bbclass b/meta/classes-global/package_rpm.bbclass
index 6d1519a272..4a700ec124 100644
--- a/meta/classes-global/package_rpm.bbclass
+++ b/meta/classes-global/package_rpm.bbclass
@@ -205,14 +205,22 @@ python write_specfile () {
205 try: 205 try:
206 owner = pwd.getpwuid(stat_f.st_uid).pw_name 206 owner = pwd.getpwuid(stat_f.st_uid).pw_name
207 except Exception as e: 207 except Exception as e:
208 bb.error("Content of /etc/passwd in sysroot:\n{}".format( 208 filename = d.getVar('RECIPE_SYSROOT') + '/etc/passwd'
209 open(d.getVar("RECIPE_SYSROOT") +"/etc/passwd").read())) 209 if os.path.exists(filename):
210 bb.error("Content of /etc/passwd in sysroot:\n{}".format(
211 open(filename).read()))
212 else:
213 bb.error("File {} doesn't exist in sysroot!".format(filename))
210 raise e 214 raise e
211 try: 215 try:
212 group = grp.getgrgid(stat_f.st_gid).gr_name 216 group = grp.getgrgid(stat_f.st_gid).gr_name
213 except Exception as e: 217 except Exception as e:
214 bb.error("Content of /etc/group in sysroot:\n{}".format( 218 filename = d.getVar("RECIPE_SYSROOT") +"/etc/group"
215 open(d.getVar("RECIPE_SYSROOT") +"/etc/group").read())) 219 if os.path.exists(filename):
220 bb.error("Content of /etc/group in sysroot:\n{}".format(
221 open(filename).read()))
222 else:
223 bb.error("File {} doesn't exists in sysroot!".format(filename))
216 raise e 224 raise e
217 return "%attr({:o},{},{}) ".format(mode, owner, group) 225 return "%attr({:o},{},{}) ".format(mode, owner, group)
218 226