install symbolic links with coreutils install

Please be note that the install utility always dereferences symlinks.

Please see my question here.

To copy files while preserving everything (symlinks, hard links, mode, etc) you can use cp -a

You can also use tar:

tar c -C source_dir file1 ... fileN | tar xv -C dest_dir

Be aware that both cp -a and tar will preserve user and group and that those files must probably be owned by root:root at the destination. You may have to add a chown afterwards.


I wondered about this too. After looking at the source code it would appear that install is pretty aggressive about resolving links at install time. Here are some of the defaults it passes to cp; the relevant ones don't get overridden later.

cp_option_init (struct cp_options *x)
{
  cp_options_default (x);
  x->copy_as_regular = true;
  x->reflink_mode = REFLINK_NEVER;
  x->dereference = DEREF_ALWAYS;
  x->hard_link = false;
  x->preserve_links = false;
  x->preserve_mode = false;
  x->symbolic_link = false;
(...)

The workaround would be to use cp + chmod.