问题
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