GetCompnents does not handle symbolic links correctly when checking repository inter-dependencies

Issue #2719 open
Roland Haas created an issue

GIven two stanzas:

# FUKA initial data thorns
# the crazy path works around a bug in GetComponents that does not handly
# symbolic links and ".." correctly
!TARGET = $ARR/Fuka/KadathThorn/src/fuka
!TYPE   = git
!URL    = https://bitbucket.org/fukaws/fuka
!CHECKOUT = Cmake build_debug build_release codes eos include install_par.sh install_seq.sh src src_par src_seq

!TARGET   = $ARR
!TYPE     = git
!URL      = https://bitbucket.org/fukaws/$2
!REPO_PATH=../$2
!CHECKOUT = Fuka/KadathImporter Fuka/KadathThorn
#DISABLED Fuka/KadathImporter
#DISABLED Fuka/KadathThorn

GetComponents detects that the Cmake, build_debug etc files checked out of fuka depend on KadathThorn having been checked out by running $TARGET/$CHECKOUT for both through canonpath then doing a string comparison to check if the path obtained for fuka starts with that of KadathThorn.

However when creating symbolic links it uses abs2rel which walks the directory tree and produces possibly incorrect symbolic links. Namely I get:

$ ls repos/KadathThorn/src/fuka/ -l                                         total 44
lrwxrwxrwx 1 rhaas rhaas 31 Apr 25 13:28 Cmake -> ../../../../../repos/fuka/Cmake
lrwxrwxrwx 1 rhaas rhaas 37 Apr 25 13:28 build_debug -> ../../../../../repos/fuka/build_debug
lrwxrwxrwx 1 rhaas rhaas 39 Apr 25 13:28 build_release -> ../../../../../repos/fuka/build_release
lrwxrwxrwx 1 rhaas rhaas 31 Apr 25 13:28 codes -> ../../../../../repos/fuka/codes
lrwxrwxrwx 1 rhaas rhaas 29 Apr 25 13:28 eos -> ../../../../../repos/fuka/eos
lrwxrwxrwx 1 rhaas rhaas 33 Apr 25 13:28 include -> ../../../../../repos/fuka/include
lrwxrwxrwx 1 rhaas rhaas 40 Apr 25 13:28 install_par.sh -> ../../../../../repos/fuka/install_par.sh
lrwxrwxrwx 1 rhaas rhaas 40 Apr 25 13:28 install_seq.sh -> ../../../../../repos/fuka/install_seq.sh
lrwxrwxrwx 1 rhaas rhaas 29 Apr 25 13:28 src -> ../../../../../repos/fuka/src
lrwxrwxrwx 1 rhaas rhaas 33 Apr 25 13:28 src_par -> ../../../../../repos/fuka/src_par
lrwxrwxrwx 1 rhaas rhaas 33 Apr 25 13:28 src_seq -> ../../../../../repos/fuka/src_seq

which have an extra ../

Instead one must use:

# FUKA initial data thorns
# the crazy path works around a bug in GetComponents that does not handly
# symbolic links and ".." correctly
!TARGET = $ARR/Fuka/KadathThorn/src/fuka/../../../../../repos/KadathThorn/src/fuka
!TYPE   = git
!URL    = https://bitbucket.org/fukaws/fuka
!CHECKOUT = Cmake build_debug build_release codes eos include install_par.sh install_seq.sh src src_par src_seq

for the first stanza to make sure it does not end up in a symbolic link. Which produces the correct:

$ ls repos/KadathThorn/src/fuka/ -l
total 44
lrwxrwxrwx 1 rhaas rhaas 28 Apr 25 13:29 Cmake -> ../../../../repos/fuka/Cmake
lrwxrwxrwx 1 rhaas rhaas 34 Apr 25 13:29 build_debug -> ../../../../repos/fuka/build_debug
lrwxrwxrwx 1 rhaas rhaas 36 Apr 25 13:29 build_release -> ../../../../repos/fuka/build_release
lrwxrwxrwx 1 rhaas rhaas 28 Apr 25 13:29 codes -> ../../../../repos/fuka/codes
lrwxrwxrwx 1 rhaas rhaas 26 Apr 25 13:29 eos -> ../../../../repos/fuka/eos
lrwxrwxrwx 1 rhaas rhaas 30 Apr 25 13:29 include -> ../../../../repos/fuka/include
lrwxrwxrwx 1 rhaas rhaas 37 Apr 25 13:29 install_par.sh -> ../../../../repos/fuka/install_par.sh
lrwxrwxrwx 1 rhaas rhaas 37 Apr 25 13:29 install_seq.sh -> ../../../../repos/fuka/install_seq.sh
lrwxrwxrwx 1 rhaas rhaas 26 Apr 25 13:29 src -> ../../../../repos/fuka/src
lrwxrwxrwx 1 rhaas rhaas 30 Apr 25 13:29 src_par -> ../../../../repos/fuka/src_par
lrwxrwxrwx 1 rhaas rhaas 30 Apr 25 13:29 src_seq -> ../../../../repos/fuka/src_seq

The “obvious” solution would be to use realpath instead of canonpath however that requires that the path actually exists which is not yet the case when dependencies are checked for.

This was triggered by Fuka in #2711

Comments (2)

  1. Log in to comment