summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro del Castillo <alejandro.delcastillo@ni.com>2018-01-23 12:00:22 -0600
committerAlejandro del Castillo <alejandro.delcastillo@ni.com>2018-01-23 12:00:22 -0600
commitfcb26339000021eb9bb711aa264247aebcfdd4ae (patch)
tree922ede298241b89a8810b63c68b4f8e5193a448d
parentf2e63deda2eab4dbb7c4cef962e72202b747364a (diff)
downloadopkg-utils-fcb26339000021eb9bb711aa264247aebcfdd4ae.tar.gz
opkg-utils-fcb26339000021eb9bb711aa264247aebcfdd4ae.tar.bz2
opkg-utils-fcb26339000021eb9bb711aa264247aebcfdd4ae.zip
update-alternatives: add support for link renames
During package upgrades, the link location might change. For example: Package A: 'update-alternatives --install /bin/app app /some/real/path 100' Package B: 'update-alternatives --install /sbin/app app /some/other/path 100' Opkg disallows a link change and throws an error. Debian does allow the operation, changing the link to the new location. Add support to follow the debian update-alternatives behavior. bugzilla #8344 Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
-rw-r--r--update-alternatives7
1 files changed, 5 insertions, 2 deletions
diff --git a/update-alternatives b/update-alternatives
index ce7d66c..89a440b 100644
--- a/update-alternatives
+++ b/update-alternatives
@@ -54,8 +54,11 @@ register_alt() {
if [ -e "$ad/$name" ]; then
local olink=`head -n 1 $ad/$name`
if [ "$link" != "$olink" ]; then
- echo "update-alternatives: Error: cannot register alternative $name to $link since it is already registered to $olink" >&2
- return 1
+ echo "update-alternatives: renaming $name link from $olink to $link"
+ local link_str=`echo $link | protect_slashes`
+ sed -e "1s/.*/$link_str/" $ad/$name > $ad/$name.new
+ mv $ad/$name.new $ad/$name
+ mv $olink $link
fi
else
echo "$link" > "$ad/$name"