In cases where we don't have permission to write to the existing
*.gen.go, we should be able to remove them and recreate them.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
For 4.17:
Without this, it is possible that the Gitlab CI got in a state
where writing to the file would fail, but removing it and creating
a new one should work.
This issue have been observed only on `fedora-gcc*` jobs as fedora
is our only container that have `golang` installed. And it runs
the build as a `user` instead of `root.
---
tools/golang/xenlight/gengotypes.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py
index 9fec60602d..ed0122874f 100644
--- a/tools/golang/xenlight/gengotypes.py
+++ b/tools/golang/xenlight/gengotypes.py
@@ -45,6 +45,7 @@ def xenlight_golang_generate_types(path = None, types = None, comment = None):
if path is None:
path = 'types.gen.go'
+ os.unlink(path)
with open(path, 'w') as f:
if comment is not None:
f.write(comment)
@@ -209,6 +210,7 @@ def xenlight_golang_generate_helpers(path = None, types = None, comment = None):
if path is None:
path = 'helpers.gen.go'
+ os.unlink(path)
with open(path, 'w') as f:
if comment is not None:
f.write(comment)
--
Anthony PERARD