pkg_alternatives: pass if the desired symlink already exists
authorYousong Zhou <yszhou4tech@gmail.com>
Tue, 11 Jul 2017 03:07:23 +0000 (11:07 +0800)
committerYousong Zhou <yszhou4tech@gmail.com>
Tue, 11 Jul 2017 10:44:28 +0000 (18:44 +0800)
commit52fc0069b50b9be89ae3b525b98741123461dd0a
tree734005d69a4820069b98b6cc3200438984430be3
parentc668fcec731bed7acc21b3f88f9a94cb55b9b498
pkg_alternatives: pass if the desired symlink already exists

This can happen when opkg installs, then configures multiple
alternatives in a batch.  Symlink to the highest prio alternative will
be created in the initial configuring stage causing later symlink call
fail with EEXIST

    Configuring busybox.
    ...
    symlink("/sbin/ip-full", "/home/yousong/j/t/lede-imagebuilder-mvebu.Linux-x86_64/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/root-mvebu/sbin/ip") = 0
    ...
    Configuring ip-full.
    ...
    symlink("/sbin/ip-full", "/home/yousong/j/t/lede-imagebuilder-mvebu.Linux-x86_64/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/root-mvebu/sbin/ip") = -1 EEXIST (File exists)
    ...

While at it, "mkdir -p" dirname(path_in_dest) before symlink in case the
following symlink call may fail with ENOENT

Ref: https://github.com/openwrt/packages/issues/4567
Reported-by: Aner Andros <aa@anerandros.info>
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
libopkg/pkg_alternatives.c