symlinks

Ryan Schmidt ryandesign at macports.org
Fri Dec 30 13:08:16 PST 2011


On Dec 30, 2011, at 13:55, Mark Brethen wrote:

> When should sym-links be created? post-destroot? post-activate? If post-destroot, will the links break after activation?

It depends on what you're trying to do. Without more context, the answer is probably post-destroot, assuming you want to create symlinks that get installed by the port. Creating symlinks or anything else in post-activate would not register them to the port (they would not be removed at port uninstall time) so that's not usually what you want.

The links won't break if you create them correctly. For example, either create a relative symlink, or create an absolute symlink pointing to its final location (i.e. not pointing to its location in the destroot). For example:


post-destroot {
	ln -s bar ${destroot}${prefix}/bin/foo
}

(creates the symlink ${destroot}${prefix}/bin/foo (which will, after activation, be located at ${prefix}/bin/foo) which points to bar in the same directory, using a relative path; this is usually preferred)


post-destroot {
	ln -s ${prefix}/bin/bar ${destroot}${prefix}/bin/foo
}

(same as above, except the symlink refers to ${prefix}/bin/bar by the absolute path it will have after activation; use this if you cannot reliably construct a relative path, for example if you're linking from something in ${prefix} to something in ${applications_dir} or vice versa, since you don't know if the user has customized those locations)


post-destroot {
	ln -s ../libexec/${name}/foo ${destroot}${prefix}/bin/foo
}

(creates the symlink ${destroot}${prefix}/bin/foo which points to the relative path ../libexec/${name}/foo)





More information about the macports-dev mailing list