update-alternatives question

Rod Whitby rod at whitby.id.au
Sun Sep 14 09:21:07 CEST 2008

Charles-Henri Gros wrote:
> Joel Newkirk wrote:
>> Quick question, hopefully someone can instantly see my error:
>> I've built the full iproute2 toolset, and am working on an ipk/opk for ip
>> and tc.  
>> The default om2008 at least, has /bin/ip linked to /bin/busybox.  So that
>> should be changed.  For inspiration, I looked at the postinst script for
>> grep, since it must perform the same changes.  (point at full bin instead
>> of busybox in postinst, restore in prerm)  So I took the
>> update-alternatives line from grep's postinst and simply replaced 'grep'
>> with 'ip' everywhere.
>> root at iota:~# update-alternatives --install /usr/bin/ip ip ip.ip 100
>> update-alternatives: Error: cannot register alternative ip to /usr/bin/ip
>> since it is already registered to /bin/ip
>> Isn't this the point of update-alternatives - to allow multiple possible
>> binaries, and 'register' the one with highest priority?  What have I done
>> wrong?  And why is the <path> component grep.grep (or in my case ip.ip)??
> grep.grep is the binary that contains what the "grep" package installs.
> You should probably install your "ip" as "ip.ip", or use /usr/bin/ip (if
> that's where you install it)
> So the command would look like (I think):
> update-alternatives --install /bin/ip ip /usr/bin/ip 100

I would not recommend that command.

For update-alternatives to work, all the packages which install that binary
have to agree on the final path of the binary.  You can't have one package
wanting to install it in /bin and the other wanting to install it in /usr/bin.

So first you need to modify all the packages so they install into the same

Then you go and put the update-alternatives stuff in, and you make each
package install the binary in /path/<binary-name>.<package-name> (e.g.
/bin/ip.ip and /bin/ip.busybox).  Then you get update-alternatives to
symlink one of those to the final binary filename in the postinst.

-- Rod

More information about the community mailing list