osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-dev/+/37888?usp=email )
Change subject: gen_makefile: support symlinks for src + src_proj ......................................................................
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(-)
Approvals: fixeria: Looks good to me, but someone else must approve osmith: Looks good to me, approved; Verified pespin: Looks good to me, but someone else must approve
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 $@ '''