Ticket #6146 (needs_work defect)

Opened 15 months ago

Last modified 5 months ago

the detection of SAGE_ROOT in $SAGE_ROOT/sage script should expand symlinks recursively (fix this on systems that do *NOT* support readlink -f)

Reported by: was Owned by: cwitty
Priority: major Milestone: sage-4.5.3
Component: misc Keywords:
Cc: Author(s):
Report Upstream: N/A Reviewer(s):
Merged in: Work issues:

Description

See #5852.

Attachments

sage-realpath-test.tar.gz Download (1.0 KB) - added by tornaria 14 months ago.
test implementation of realpath in bash for systems which don't support realpath/readlink -f

Change History

Changed 15 months ago by was

  • summary changed from [with patch, needs review] the detection of SAGE_ROOT in $SAGE_ROOT/sage script should expand symlinks recursively (fix this on systems that do *NOT* support readlink -f) to the detection of SAGE_ROOT in $SAGE_ROOT/sage script should expand symlinks recursively (fix this on systems that do *NOT* support readlink -f)

Changed 14 months ago by tornaria

test implementation of realpath in bash for systems which don't support realpath/readlink -f

Changed 14 months ago by tornaria

I've attached a proof-of-concept of a bash script which correctly computes the SAGE_ROOT as a fully canonicalized path. This is a tarball which includes the script itself, and a bunch of symlinks to the same script in different configurations, plus a test script which shows the result of the computation of SAGE_ROOT in the different cases.

To test, untar, cd sage-realpath-test and run ./test. Sample output:

==========================================================
The following lines of output should all be identical, and
point to the canonicalized path of directory sage_root
==========================================================

SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:
SAGE_ROOT:/home/tornaria/sage-realpath-test/sage_root:

This is a correct run, because all the runs gave the same canonical path (which is the correct canonical path).

The script uses realpath, then readlink -f, and fall back to a bash function; but for testing purposes, the fallback to bash function is always tried.

I've successfully tested this on:

  • linux with no realpath, but readlink -f works (my laptop)
  • linux with realpath (sage.math)
  • mac with fink (which supports readlink -f)
  • mac with fink disabled (remove it from path)
  • t2 (trying this found out some gnuisms or non-sunisms which I had to fix)

Maybe somebody can try this on the build farm to check that it is safe... Assuming what we really want is for SAGE_ROOT to be the fully canonicalized path (see the last comments in #5852).

BTW, this already gives an absolute path, so there would be no need to cd $SAGE_ROOT here and cd $CUR back in sage-sage (ugly hack).

Changed 11 months ago by mhansen

  • status changed from new to needs_review

Changed 5 months ago by malb

  • status changed from needs_review to needs_work
  • upstream set to N/A

This isn't a patch etc. so it cannot be reviewed yet. I'll change the status to needs work.

Note: See TracTickets for help on using tickets.