4

Can install be used to install symlinks without dereferencing and installing the target file - it seems like such an unusual omission?

drwxrwxr-x 2 greg greg 4096 Aug 20 10:46 .
drwxrwxr-x 4 greg greg 4096 Aug 20 10:40 ..
lrwxrwxrwx 1 greg greg    4 Aug 20 10:46 stest -> test
-rw-rw-r-- 1 greg greg    0 Aug 20 10:40 test
$ mkdir target
$ install test  target/test
$ install stest  target/stest
$ ls -la target/
total 8
drwxrwxr-x 2 greg greg 4096 Aug 20 10:46 .
drwxrwxr-x 3 greg greg 4096 Aug 20 10:46 ..
-rwxr-xr-x 1 greg greg    0 Aug 20 10:46 stest
-rwxr-xr-x 1 greg greg    0 Aug 20 10:46 test

Is there an alternative tool that more provides the base install functionality as well as safe staging of symlinks?

  • PS - the obvious tag install for this question is deprecated as it has been used incorrectly for installation - perhaps it could be clarified to refer specifically to this 'standard' command-line tool. – Greg Aug 21 '15 at 6:25
  • 2
    Why not simply use ln? – michas Aug 21 '15 at 6:34
  • install allows custom setting of uid/gid and access mode, creation of directories in the path, safe handling of existing files, along with binary stripping - for my application all of these features were critical - it just chokes on symlinks. ln does none of those things. – Greg Aug 21 '15 at 12:14
1

The only workaround I have is something along the lines of:

# mess around extracting src/dest from install's $@ params
#  ...
if [ -h $src ]; then
    rm -f $dest
    [ -d $(dirname $dest) ] || install -d $(dirname $dest) ...install args... $(dirname $src)
    cp -d $src $dest
else
    install $@
fi

The mess around extracting args bit is a pain in the...

  • $dest isn't always the last argument of install with -t or -d. I'm unsure of interactions with -Tand symlinks. Do you have argument parsing code to share as well? – Tom Hale Feb 24 at 1:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.