Skip to contentSkip to conversation

Check if version is actually a file

PATCH In review Frede Braendstrup 2 participants 4 messages Mar 14, 2025 – Mar 18, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Check if version is actually a file

Recipetool incorrectly made the assumption that version is always a file, but when it's a directory, the call to open fails

---
 scripts/lib/recipetool/create_buildsys.py | 2 ++
 1 file changed, 2 insertions(+)
scripts/lib/recipetool/create_buildsys.py +2 -0
index ec9d510e23..0a08fc64ca 100644
@@ -808,6 +808,8 @@ class VersionFileRecipeHandler(RecipeHandler):
             version = None
             for fileitem in filelist:
                 linecount = 0
+                if not os.path.isfile(fileitem):
+                    continue
                 with open(fileitem, 'r', errors='surrogateescape') as f:
                     for line in f:
                         line = line.rstrip().strip('"\'')
Signature · 1 line
2.47.2
#1 lore raw

Thanks for the patch, but it should be sent to openembedded-core list, as poky is an aggregate repository of various pieces.

Alex

Quoted 34 lines · Frederik Brændstrup via lists.yoctoproject.org

Recipetool incorrectly made the assumption that version is always a file, but when it's a directory, the call to open fails

---
 scripts/lib/recipetool/create_buildsys.py | 2 ++
 1 file changed, 2 insertions(+)
scripts/lib/recipetool/create_buildsys.py +2 -1
index ec9d510e23..0a08fc64ca 100644
@@ -808,6 +808,8 @@ class VersionFileRecipeHandler(RecipeHandler):
             version = None
             for fileitem in filelist:
                 linecount = 0
+                if not os.path.isfile(fileitem):
+                    continue
                 with open(fileitem, 'r', errors='surrogateescape') as f:
                     for line in f:
                         line = line.rstrip().strip('"\'')
--

2.47.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#13567): https://lists.yoctoproject.org/g/poky/message/13567
Mute This Topic: https://lists.yoctoproject.org/mt/111700337/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/poky/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

PATCH 1/1 Check if version is actually a file

In reply to Frede Braendstrup

Recipetool incorrectly made the assumption that version is always a file, but when it's a directory, the call to open fails

---
 scripts/lib/recipetool/create_buildsys.py | 2 ++
 1 file changed, 2 insertions(+)
(quoted diff) +0 -0

b/scripts/lib/recipetool/create_buildsys.py
index ec9d510e23..0a08fc64ca 100644

scripts/lib/recipetool/create_buildsys.py +2 -0
@@ -808,6 +808,8 @@ class VersionFileRecipeHandler(RecipeHandler):
             version = None
             for fileitem in filelist:
                 linecount = 0
+                if not os.path.isfile(fileitem):
+                    continue
                 with open(fileitem, 'r', errors='surrogateescape') as f:
                     for line in f:
                         line = line.rstrip().strip('"\'')

--
2.47.2

#3 lore raw
Quoted 3 lines · Frederik Brændstrup via lists.openembedded.org

Recipetool incorrectly made the assumption that version is always a file, but when it's a directory, the call to open fails

Thanks for the patch. There is some missing context in it, specifically, filelist is formed like this:

filelist = RecipeHandler.checkfiles(srctree, ['VERSION', 'version'])

Shouldn't rather this function/method be fixed to only return files? There are multiple other places in the same file where the same call is used to form filelists, and they all potentially have the same issue.

Alex