You are not logged in.

#1 2024-03-08 15:24:31

Ayu2805
Member
Registered: 2023-07-23
Posts: 52

[GUIDE]How to install all optional dependencies automatically?

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:

  1. 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')
  2. 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

#2 2024-07-02 17:12:45

bionade24
Member
Registered: 2020-12-26
Posts: 4

Re: [GUIDE]How to install all optional dependencies automatically?

You can use

expac

from the pacman-contrib pkg for this:

sudo pacman -S --needed --asdeps $(expac -Ss '%o' <pkg_name>)

Offline

#3 2024-07-02 18:14:26

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [GUIDE]How to install all optional dependencies automatically?

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

#4 2024-07-02 18:35:21

icar
Member
Registered: 2020-07-31
Posts: 560

Re: [GUIDE]How to install all optional dependencies automatically?

It should detect if the optdeps conflict and prompt to choose. It can get complicated if they conflict between packages, though.

Offline

#5 2024-07-02 21:02:27

cryptearth
Member
Registered: 2024-02-03
Posts: 2,009

Re: [GUIDE]How to install all optional dependencies automatically?

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

#6 2024-07-19 08:28:11

Ayu2805
Member
Registered: 2023-07-23
Posts: 52

Re: [GUIDE]How to install all optional dependencies automatically?

bionade24 wrote:

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

Board footer

Powered by FluxBB