Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make port-tclsh a relative symlink, not absolute #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ryandesign
Copy link
Contributor

This is a step toward allowing the MacPorts installer package to install to any prefix.

Using Perl is the most straightforward and most compatible way I found to compute a relative path from two absolute paths.

I wrote the Perl command inline because this is the only place where it's needed right now. But it could be broken out into a custom Makefile function to make it reusable.

Is it ok to just use perl, since it is so widely available, or do we need to do autoconf stuff to find it and set a variable with its path? We already use sed in the same Makefile without checking for it.

This is a step toward allowing the MacPorts installer package to install
to any prefix.
@raimue
Copy link
Member

raimue commented Jun 2, 2018

Given that we know that ${TCLSH} is inside ${INSTALLDIR}, how about using the ${foo#bar} prefix pattern expansion syntax to get the relative path? Needs a shell variable first, though.

Something like this, but it is untested:

tclshpath=${TCLSH}; $(LN_S) -f "../$${tclshpath#${INSTALLDIR}}" "${DESTDIR}${INSTALLDIR}/bin/port-tclsh"

@ryandesign
Copy link
Contributor Author

That should work and would be simpler.

@neverpanic
Copy link
Member

Are you going to update the PR with the shell-based solution?

@ryandesign
Copy link
Contributor Author

Yes I should do that.

@ryandesign
Copy link
Contributor Author

how about using the ${foo#bar} prefix pattern expansion syntax to get the relative path?

The problem with this is that we are perpetuating the mistake of making assumptions about the "bin" and "libexec" directory names/paths and their locations relative to one another. If we fix that mistake, then we need to compute the relative path from the one to the other, e.g. using the Perl solution I proposed.

@ryandesign
Copy link
Contributor Author

If avoiding Perl is strongly desired, the following should work:

bindir="${INSTALLDIR}/bin" && shopt -s extglob && rel="$${bindir//+([^\/])/..}" && $(LN_S) -f "$${rel:1}${TCLSH}" "${DESTDIR}${INSTALLDIR}/bin/port-tclsh"

The relative path this constructs is not minimal/optimal, but it should be correct regardless of how different bindir and libexecdir are from one another.

(Obviously this still incorrectly hardcodes the bin directory, but at least it makes it obvious where ${INSTALLDIR}/bin could be replaced by the right thing.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants