osmith submitted this change.
gen_makefile: support symlinks for src + src_proj
Support the src and src_proj directories to be symlinks by checking if
these paths exist only (-e), instead of checking if these are
directories (-d).
Add a second check to detect broken symlinks and inform the user about
those, so it does not fail later on with a more confusing error. This
may happen if the user runs testenv inside podman, and has a symlink
pointing to a directory that is not mounted inside podman.
Related: OS#6494
Change-Id: Ic5ffa132b29e0a2ca78b02e4c8c05492471b3966
---
M gen_makefile.py
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/gen_makefile.py b/gen_makefile.py
index 0476a3f..22882bd 100755
--- a/gen_makefile.py
+++ b/gen_makefile.py
@@ -221,8 +221,25 @@
return f'''
.make.{proj}.clone:
@echo "\\n\\n\\n===== $@\\n"
- test -d {src} || mkdir -p {src}
- test -d {src_proj} || ( {cmd_clone} && {cmd_set_push_url} )
+
+ @if ! [ -e {src}/ ]; then \\
+ if [ -L {src} ]; then \\
+ echo "ERROR: broken symlink: {src}"; \\
+ exit 1; \\
+ fi; \\
+ set -x; \\
+ mkdir -p {src}; \\
+ fi
+
+ @if ! [ -e {src_proj}/ ]; then \\
+ if [ -L {src_proj} ]; then \\
+ echo "ERROR: broken symlink: {src_proj}"; \\
+ exit 1; \\
+ fi; \\
+ set -x; \\
+ ( {cmd_clone} && {cmd_set_push_url} ); \\
+ fi
+
sync
touch $@
'''
To view, visit change 37888. To unsubscribe, or for help writing mail filters, visit settings.