You are not logged in.
I am not talking about listing all the optional dependencies manually and install them with "--asdeps" flag.
Instead I am talking about install all optional dependencies automatically with a simple(kind of) command.
I found two solution:
Quite complicated but works:
sudo pacman -S <package name> --asdeps $(pacman -Si <package name> | sed -n '/^Optional Deps/,/^Conflicts With/p' | sed '$d' | sed 's/^Optional Deps ://g' | sed 's/^\s*//g')Very simple and works flawlessly:
sudo pacman -S <package name> --asdeps --needed $(pactree -su <package name>)
This needs pacman-contrib to be installed.
Both commands works with any AUR helper.
Only the first one works as of now, I was misguided earlier.
Last edited by Ayu2805 (2024-07-19 08:30:24)
Offline
You can use
expacfrom the pacman-contrib pkg for this:
sudo pacman -S --needed --asdeps $(expac -Ss '%o' <pkg_name>)Offline
At very least, you could clean up that sed pipeline - there's really no need for piping sed to sed:
pacman -S <pkg> $(pacman -Si <pkg> | sed -n '/^Optional/{ s/[^:]*: //;:a;s/:.*//p;n;/^[^ \t]/q;ba;}')But that would be a bad idea - in many cases optional dependencies will conflict with each other as you are to chose one of several options.
EDIT: commented sed script:
/^Optional/ {
# Remove "Optional ..." on first line only
s/[^:]*: //
# Line label for looping; Remove description and print package name
:a
s/:.*//p
# Get next line; Quit if it doesn't start with a blank
n
/^[^ \t]/q
# Branch to loop start
ba
}Last edited by Trilby (2024-07-02 18:23:46)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
It should detect if the optdeps conflict and prompt to choose. It can get complicated if they conflict between packages, though.
Offline
sorry for hijacking: more basic question: why would someone do such thing?
it highly depends on proper and active maintenance and can explode rather quickly with big multi-gb packages
isn't all that dependency management meant the other way around: I want to do something specific and have pacman figure out all the requirements?
Offline
sudo pacman -S --needed --asdeps $(expac -Ss '%o' <pkg_name>)
I think this is better if one is using repos that may contain duplicate/similar entries(e.g. Chaotic AUR):
sudo pacman -S --needed --asdeps $(expac -1S "%n\n%o" <pkg_name>)Offline