From Fedora Project Wiki
(New page: == Symlinks == There are two ways of making a symlink, either as a relative link or an absolute link. In Fedora, neither method is required. Packagers should use their best judgement when ...)
 
No edit summary
Line 5: Line 5:
A relative symlink is a symlink which points to a file or directory relative to the position of the symlink. For example, this command would create a relative symlink:
A relative symlink is a symlink which points to a file or directory relative to the position of the symlink. For example, this command would create a relative symlink:
<pre>
<pre>
ln -s ../../usr/bin/foo %{buildroot}/bin/foo
ln -s ../../%{_bindir}/foo %{buildroot}/bin/foo
</pre>
</pre>


Line 15: Line 15:
* Relative symlinks may break or behave unexpectedly when a part of a filesystem is mounted to a custom location.
* Relative symlinks may break or behave unexpectedly when a part of a filesystem is mounted to a custom location.
* Relative symlinks may break when bind mounting or symlinking directories.
* Relative symlinks may break when bind mounting or symlinking directories.
* Relative symlinks make it more difficult to use rpm system macros.
* Relative symlinks may make it more difficult to use rpm system macros.


=== Absolute Symlinks ===
=== Absolute Symlinks ===
An absolute symlink is a symlink which points to an absolute file or directory path. For example, this command would create an absolute symlink:
An absolute symlink is a symlink which points to an absolute file or directory path. For example, this command would create an absolute symlink:
<pre>
<pre>
ln -s /usr/bin/foo %{buildroot}/bin/foo
ln -s %{_bindir}/foo %{buildroot}/bin/foo
</pre>
</pre>



Revision as of 18:21, 20 January 2009

Symlinks

There are two ways of making a symlink, either as a relative link or an absolute link. In Fedora, neither method is required. Packagers should use their best judgement when deciding which method of symlink creation is appropriate.

Relative Symlinks

A relative symlink is a symlink which points to a file or directory relative to the position of the symlink. For example, this command would create a relative symlink:

ln -s ../../%{_bindir}/foo %{buildroot}/bin/foo

Pros:

  • Relative symlinks are better when working with chroots.

Cons:

  • Much more complicated to create than absolute symlinks
  • Relative symlinks may break or behave unexpectedly when a part of a filesystem is mounted to a custom location.
  • Relative symlinks may break when bind mounting or symlinking directories.
  • Relative symlinks may make it more difficult to use rpm system macros.

Absolute Symlinks

An absolute symlink is a symlink which points to an absolute file or directory path. For example, this command would create an absolute symlink:

ln -s %{_bindir}/foo %{buildroot}/bin/foo

Pros:

  • Much easier to create than relative symlinks.
  • Absolute symlinks work properly when bind mounting or symlinking directories.
  • Absolute symlinks work well with rpm system macros.

Cons:

  • Absolute symlinks may break when used with chroots.