install symbolic links with coreutils install

流过昼夜 提交于 2020-08-27 04:26:34

问题


I built a library and I want to install the library to /usr/local/lib using coreutils install. The result of the build looks as follows:

libfoo.so -> libfoo.so.1
libfoo.so.1 -> libfoo.so.1.1
libfoo.so.1.1

I want to retain the symbolic links and install the files as is to /usr/local/lib. However, if I run

install libfoo* /usr/local/lib

the symbolic links are resolved and /usr/local/lib looks as follows:

libfoo.so
libfoo.so.1
libfoo.so.1.1

In other words, these are all real files and no symbolic links.

The manpage of install does not contain any information about resolving symbolic links. How can I install symbolic links?


回答1:


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.



来源:https://stackoverflow.com/questions/35560730/install-symbolic-links-with-coreutils-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!