Skip to contentSkip to conversation

check-package: support symlinks to the script

PATCH New Arnout Vandecappelle (Essensium/Mind) 3 participants 3 messages Apr 1, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 check-package: support symlinks to the script

The check-package script finds base_dir (= the Buildroot directory) and cd's into it. To be able to support relative paths as arguments, it first recalculates the arguments relative to base_dir.

However, if there is a symlink anywhere on the path to the check-package script, the relative paths will be wrong. To solve this, use realpath() instead of abspath(), so symlinks are resolved before calculating the relative path.

---
 utils/check-package | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/check-package +1 -1
index d9b719783d..3dbc28b0a2 100755
@@ -143,7 +143,7 @@ def __main__():
 
     if flags.intree_only:
         # change all paths received to be relative to the base dir
-        base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+        base_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
         files_to_check = [os.path.relpath(os.path.abspath(f), base_dir) for f in flags.files]
         # move current dir so the script find the files
         os.chdir(base_dir)
Signature · 1 line
2.16.3
#1 lore raw

PATCH 1/1 check-package: support symlinks to the script

Hello,

Quoted 11 lines · Arnout Vandecappelle (Essensium/Mind)

The check-package script finds base_dir (= the Buildroot directory) and cd's into it. To be able to support relative paths as arguments, it first recalculates the arguments relative to base_dir.

However, if there is a symlink anywhere on the path to the check-package script, the relative paths will be wrong. To solve this, use realpath() instead of abspath(), so symlinks are resolved before calculating the relative path.

Sorry. I forgot about this use case.
Thank you for fixing it.

Regards,
Ricardo

#2 lore raw

PATCH 1/1 check-package: support symlinks to the script

In reply to Arnout Vandecappelle (Essensium/Mind)
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle (Essensium/Mind) <[email protected]> writes:

The check-package script finds base_dir (= the Buildroot directory) and cd's into it. To be able to support relative paths as arguments, it first recalculates the arguments relative to base_dir.

Quoted 7 lines

However, if there is a symlink anywhere on the path to the check-package script, the relative paths will be wrong. To solve this, use realpath() instead of abspath(), so symlinks are resolved before calculating the relative path.

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard