scripts: fix file writing in convert-variable-renames

In my test environments (Fedora 35 and Debian 10.10 on AMD 2970WX),
running the convert-variable-renames.py rename script was resulting
in empty files instead of updated ones.  From inspection, the new
files are never flushed/closed before moving them into place, which
seems inherently racy.  Adding an explicit close to flush the modified
contents out before moving into place fixes the issue for me.

(From OE-Core rev: 187ac1ea0a701a5ba9ec92f6aa32f2a67600a584)

Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Scott Murray 2022-02-21 23:21:38 -05:00 committed by Richard Purdie
parent cc07ffe8f7
commit ccbc29bbc4

View File

@ -84,6 +84,7 @@ def processfile(fn):
if re.search(check_word, line, re.IGNORECASE):
print("%s needs further work at line %s since it contains %s"% (fn, lineno, check_word))
new_file.write(line)
new_file.close()
if modified:
print("*** Modified file '%s'" % (fn))
shutil.copymode(fn, abs_path)