[pacman-dev] Alternatives system
Hi all, I plan to finish implementing an alternatives system for pacman post 5.2 release: https://wiki.archlinux.org/index.php/User:Allan/Alternatives Any comments or suggestions? Thanks, Allan
On 04/01/19 at 09:56am, Allan McRae wrote:
Hi all,
I plan to finish implementing an alternatives system for pacman post 5.2 release: https://wiki.archlinux.org/index.php/User:Allan/Alternatives
Any comments or suggestions?
"All alternatives are symlinked in /usr/bin so no need to specify the full path." Why? Arch puts all executables in /usr/bin but other users may not. "TODO bikeshed the separator" We're in the rather unfortunate position that neither of our database formats can handle multiple arbitrary filenames on a single line without escaping. We can use -> in PKGBUILDs if you like, but for .PKGINFO and desc files I would pick a single character to make escaping easier. You don't mention anywhere on the wiki what happens when a package is removed. I'm guessing alpm would remove the alternative if the link target is owned by the package and call a callback to prompt the user to select a new provider? That means the upgrade logic will need to track whether the new version still provides the alternative. How would packages that provide a file as an alternative interact with those that provide it directly? What happens if an alternative is installed and then a user attempts to install a package that provides that file directly? Does that just fail as a file conflict? What if the package that provides the file directly is uninstalled? We'd have to scan the local database for every single file we remove (or at least those in usr/bin, if that stands) in case any packages provide that file as an alternative. Overall, I'm torn between "this seems really neat" and "this seems like a lot of complexity for something we don't /really/ need". So, I'm going to play devil's advocate here: what's the advantage of this over the existing solutions? The example you give is bin/sh. On Arch, that could be solved by the user with NoExtract. For a more general solution, the bin/sh link could be distributed by itself in sh-bash and sh-dash packages. It's not very aesthetically pleasing, but it gets the job done with just what we already have.
On 1/4/19 2:12 pm, Andrew Gregory wrote:
On 04/01/19 at 09:56am, Allan McRae wrote:
Hi all,
I plan to finish implementing an alternatives system for pacman post 5.2 release: https://wiki.archlinux.org/index.php/User:Allan/Alternatives
Any comments or suggestions?
"All alternatives are symlinked in /usr/bin so no need to specify the full path."
Why? Arch puts all executables in /usr/bin but other users may not.
Make the path configurable, if anyone ever asks for that. Or if they want a range of locations, extend it to allow optional full paths. And this will have some configurability with the --prefix or --bindir configuration options (at least in autotools).
"TODO bikeshed the separator"
We're in the rather unfortunate position that neither of our database formats can handle multiple arbitrary filenames on a single line without escaping. We can use -> in PKGBUILDs if you like, but for .PKGINFO and desc files I would pick a single character to make escaping easier.
I went for two character, in a combination that is unlikely to be used in the name of the alternative symlink itself. That way it is a split on first occurrence. I realize that someone will try an alternative with that pair of characters in their name... so yes, that needs addressed. My other thought was "::" like we use to split other things in makepkg. Would that be a compromise - two characters, but one?
You don't mention anywhere on the wiki what happens when a package is removed. I'm guessing alpm would remove the alternative if the link target is owned by the package and call a callback to prompt the user to select a new provider?
Remove the symlink to the package being removed, set it to the first other provider found (if any). Print a notification if new symlink made.
That means the upgrade logic will need to track whether the new version still provides the alternative.
Yes.
How would packages that provide a file as an alternative interact with those that provide it directly? What happens if an alternative is installed and then a user attempts to install a package that provides that file directly? Does that just fail as a file conflict?
Yes. It will already be detected as a conflict with a file on the system. We would just need to check to give a more informative error message.
What if the package that provides the file directly is uninstalled? We'd have to scan the local database for every single file we remove (or at least those in usr/bin, if that stands) in case any packages provide that file as an alternative.
My idea was to not create the alternative symlink in this instance, and put it down to bad packaging. Not an ideal solution, but I think there is none in this instance.
Overall, I'm torn between "this seems really neat" and "this seems like a lot of complexity for something we don't /really/ need". So, I'm going to play devil's advocate here: what's the advantage of this over the existing solutions? The example you give is bin/sh. On Arch, that could be solved by the user with NoExtract.
NoExtract could work, but having an alternative means a distribution has decided to actually support varying the (e.g.) /bin/sh provider. That means bashisms have been removed or appropriate shebangs added. I know people currently do this with python->python2. The alternative system also avoids dangling symlinks, and unowned files.
For a more general solution, the bin/sh link could be distributed by itself in sh-bash and sh-dash packages. It's not very aesthetically pleasing, but it gets the job done with just what we already have.
sh-bash could not be a dependency of bash, or else this would not work. But just installing bash does not give me the bin/sh symlink I need. So then we make sh-bash and sh-dash provide "sh", and have everything needing sh depend on it. So I agree, it can be done. It just becomes messy. Thanks for the feedback! Allan
On Mon, Apr 01, 2019 at 02:57:31PM +1000, Allan McRae <allan@archlinux.org> wrote:
"TODO bikeshed the separator"
We're in the rather unfortunate position that neither of our database formats can handle multiple arbitrary filenames on a single line without escaping. We can use -> in PKGBUILDs if you like, but for .PKGINFO and desc files I would pick a single character to make escaping easier.
I went for two character, in a combination that is unlikely to be used in the name of the alternative symlink itself. That way it is a split on first occurrence. I realize that someone will try an alternative with that pair of characters in their name... so yes, that needs addressed. My other thought was "::" like we use to split other things in makepkg. Would that be a compromise - two characters, but one?
How about /./? I've seen this being used by jailkit. A value could look like "foo/./usr/bin/foo-v1". This should be easy to escape/handle and it doesn't make a whole lot of sense to ever use this syntax in a real path. Florian
Am 01.04.19 um 06:57 schrieb Allan McRae:
On 1/4/19 2:12 pm, Andrew Gregory wrote:
On 04/01/19 at 09:56am, Allan McRae wrote:
Hi all,
I plan to finish implementing an alternatives system for pacman post 5.2 release: https://wiki.archlinux.org/index.php/User:Allan/Alternatives
Any comments or suggestions?
"All alternatives are symlinked in /usr/bin so no need to specify the full path."
Why? Arch puts all executables in /usr/bin but other users may not.
Make the path configurable, if anyone ever asks for that. Or if they want a range of locations, extend it to allow optional full paths. And this will have some configurability with the --prefix or --bindir configuration options (at least in autotools).
I do think there could be use cases for alternatives outside /usr/bin: What if someone wanted to use an alternative for something else than a executable? For example something like /usr/lib/jvm/default comes to mind. So using alternatives couldn't selecting a default java be handled by pacman alone, instead of needing a helper like archlinux-java? (Or does that helper do anything, alternatives couldn't handle?) -- regards, brainpower
allan at archlinux.org (Allan McRae) wrote:
On 04/01/19 at 09:56am, Allan McRae wrote:
Hi all,
I plan to finish implementing an alternatives system for pacman post 5.2 release: https://wiki.archlinux.org/index.php/User:Allan/Alternatives
Any comments or suggestions? "All alternatives are symlinked in /usr/bin so no need to specify the full path." Why? Arch puts all executables in /usr/bin but other users may not. Make the path configurable, if anyone ever asks for that. Or if they want a range of locations, extend it to allow optional full paths. And
On 1/4/19 2:12 pm, Andrew Gregory wrote: this will have some configurability with the --prefix or --bindir configuration options (at least in autotools).
xbps has alternatives which are very similar, but not limited to binaries, alternatives can be used for any path and even directories. The most common use case is binaries and their man pages. The alternatives are structured in groups, `sh` is a group and each package providing the alternative group can have one or more symlinks for a given group. $ xbps-alternatives -l -g sh sh - dash (current) - sh:/usr/bin/dash - sh.1:/usr/share/man/man1/dash.1 - mksh - sh:/usr/bin/mksh - sh.1:/usr/share/man/man1/mksh.1 - bash - sh:/usr/bin/bash - sh.1:/usr/share/man/man1/bash.1 - busybox - sh:/usr/bin/busybox - yash - sh:/usr/bin/yash - sh.1:/usr/share/man/man1/yash.1 - loksh - sh:/usr/bin/loksh - sh.1:/usr/share/man/man1/loksh-sh.1 If the target is relative or a filename they are created inside the targets directory. $ xbps-alternatives -l -g lua lua - lua (current) - lua:/usr/bin/lua5.3 - luac:/usr/bin/luac5.3 - lua.1:/usr/share/man/man1/lua5.3.1 - luac.1:/usr/share/man/man1/luac5.3.1 - lua:/usr/include/lua5.3 - /usr/include/lua.h:/usr/include/lua5.3/lua.h - /usr/include/luaconf.h:/usr/include/lua5.3/luaconf.h - /usr/include/lua.hpp:/usr/include/lua5.3/lua.hpp - /usr/include/lualib.h:/usr/include/lua5.3/lualib.h - /usr/include/lauxlib.h:/usr/include/lua5.3/lauxlib.h - lua.pc:/usr/lib/pkgconfig/lua5.3.pc - liblua.a:/usr/lib/liblua5.3.a - liblua.so:/usr/lib/liblua5.3.so - lua:/usr/share/doc/lua5.3 - lua52 - lua:/usr/bin/lua5.2 - luac:/usr/bin/luac5.2 - lua.1:/usr/share/man/man1/lua5.2.1 - luac.1:/usr/share/man/man1/luac5.2.1 - lua:/usr/include/lua5.2 - /usr/include/lua.h:/usr/include/lua5.2/lua.h - /usr/include/luaconf.h:/usr/include/lua5.2/luaconf.h - /usr/include/lua.hpp:/usr/include/lua5.2/lua.hpp - /usr/include/lualib.h:/usr/include/lua5.2/lualib.h - /usr/include/lauxlib.h:/usr/include/lua5.2/lauxlib.h - lua.pc:/usr/lib/pkgconfig/lua5.2.pc - liblua.a:/usr/lib/liblua5.2.a - liblua.so:/usr/lib/liblua5.2.so - lua:/usr/share/doc/lua5.2 - lua51 - lua:/usr/bin/lua5.1 - luac:/usr/bin/luac5.1 - lua.1:/usr/share/man/man1/lua5.1.1 - luac.1:/usr/share/man/man1/luac5.1.1 - lua:/usr/include/lua5.1 - /usr/include/lua.h:/usr/include/lua5.1/lua.h - /usr/include/luaconf.h:/usr/include/lua5.1/luaconf.h - /usr/include/lua.hpp:/usr/include/lua5.1/lua.hpp - /usr/include/lualib.h:/usr/include/lua5.1/lualib.h - /usr/include/lauxlib.h:/usr/include/lua5.1/lauxlib.h - lua.pc:/usr/lib/pkgconfig/lua5.1.pc - liblua.a:/usr/lib/liblua5.1.a - liblua.so:/usr/lib/liblua5.1.so - lua:/usr/share/doc/lua5.1 Greetings, Duncan Overbruck
On 01-04-2019 01:56, Allan McRae wrote:
Hi all,
I plan to finish implementing an alternatives system for pacman post 5.2 release: https://wiki.archlinux.org/index.php/User:Allan/Alternatives
Any comments or suggestions?
Thanks, Allan
pacman 6 .0 alpha has been released, but there's no sign of an alternatives system I can find. The descriptions suggest the alternatives system could improve at least one of my aur packages by a lot. Is an alternatives system still on the roadmap ? Lone_Wolf
On 7/12/20 3:03 am, Lone_Wolf wrote:
On 01-04-2019 01:56, Allan McRae wrote:
Hi all,
I plan to finish implementing an alternatives system for pacman post 5.2 release: https://wiki.archlinux.org/index.php/User:Allan/Alternatives
Any comments or suggestions?
Thanks, Allan
pacman 6 .0 alpha has been released, but there's no sign of an alternatives system I can find.
The descriptions suggest the alternatives system could improve at least one of my aur packages by a lot.
Is an alternatives system still on the roadmap ?
It is on the roadmap. Unlikely for 6.0, unless I feel motivated over the upcoming holiday season. Allan
participants (6)
-
Allan McRae
-
Andrew Gregory
-
brainpower
-
Duncan Overbruck
-
Florian Pritz
-
Lone_Wolf