PackagingDrafts/Symlinks

From FedoraProject

Jump to: navigation, search

Contents

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 will point to the same file inside or outside of a chroot.

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.

Discussion

See Talk:PackagingDrafts/Symlinks for discussion