summaryrefslogtreecommitdiffstats
path: root/meta/classes-global
diff options
context:
space:
mode:
authorPavel Zhukov <pavel@zhukoff.net>2024-10-10 19:45:45 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-10-11 12:17:03 +0100
commit0d564b3ad1e8f0db3909eeaa6afed636a57f31f6 (patch)
tree4fea217d1f1981a86e902ae0352ce464132ba9c7 /meta/classes-global
parenta475c8ab38bc56c0a5d68a44f99f0005058f6b75 (diff)
downloadpoky-0d564b3ad1e8f0db3909eeaa6afed636a57f31f6.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: 4ad9a0e0b11eb7bc5a3dd45fc8945e094ea949e9) Signed-off-by: Pavel Zhukov <pavel@zhukoff.net> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-global')
-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 474d2491eb..ddc4bf3a6a 100644
--- a/meta/classes-global/package_rpm.bbclass
+++ b/meta/classes-global/package_rpm.bbclass
@@ -201,14 +201,22 @@ python write_specfile () {
201 try: 201 try:
202 owner = pwd.getpwuid(stat_f.st_uid).pw_name 202 owner = pwd.getpwuid(stat_f.st_uid).pw_name
203 except Exception as e: 203 except Exception as e:
204 bb.error("Content of /etc/passwd in sysroot:\n{}".format( 204 filename = d.getVar('RECIPE_SYSROOT') + '/etc/passwd'
205 open(d.getVar("RECIPE_SYSROOT") +"/etc/passwd").read())) 205 if os.path.exists(filename):
206 bb.error("Content of /etc/passwd in sysroot:\n{}".format(
207 open(filename).read()))
208 else:
209 bb.error("File {} doesn't exist in sysroot!".format(filename))
206 raise e 210 raise e
207 try: 211 try:
208 group = grp.getgrgid(stat_f.st_gid).gr_name 212 group = grp.getgrgid(stat_f.st_gid).gr_name
209 except Exception as e: 213 except Exception as e:
210 bb.error("Content of /etc/group in sysroot:\n{}".format( 214 filename = d.getVar("RECIPE_SYSROOT") +"/etc/group"
211 open(d.getVar("RECIPE_SYSROOT") +"/etc/group").read())) 215 if os.path.exists(filename):
216 bb.error("Content of /etc/group in sysroot:\n{}".format(
217 open(filename).read()))
218 else:
219 bb.error("File {} doesn't exists in sysroot!".format(filename))
212 raise e 220 raise e
213 return "%attr({:o},{},{}) ".format(mode, owner, group) 221 return "%attr({:o},{},{}) ".format(mode, owner, group)
214 222