You are not logged in.

#1 2021-01-01 10:51:52

brighton64
Member
Registered: 2020-11-24
Posts: 4

Pacman install optional dependencies

Guys is there a way of installing packages using pacman in such a way that it prompts you about all the optional dependencies before installing just like pamac does?

Offline

#2 2021-01-01 11:24:15

VoDo
Member
From: Europe
Registered: 2020-06-04
Posts: 122

Re: Pacman install optional dependencies

I think it writes it during the installation process.


Archi3

Offline

#3 2021-01-01 15:08:45

respiranto
Member
Registered: 2015-05-15
Posts: 479
Website

Re: Pacman install optional dependencies

You could probably write a wrapper using ``expac -S '%O\n' $pkg''.  You might want to take care of cases where there is more than one package of a single name.

Offline

#4 2021-01-01 16:13:40

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

Re: Pacman install optional dependencies

That should be a small %o in the expac format.  And there'd be no need to deduplicate the output as pacman will handle this itself:

# install all optional dependencies (as explicit) for pkgs 1-3 that are already installed:
expac -Q %o $pkg1 $pkg2 $pkg3 | pacman -S -
# install package and all of it's optional dependencies:
expac -S "%n %o" $pkg | pacman -S -

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2021-01-01 17:00:53

respiranto
Member
Registered: 2015-05-15
Posts: 479
Website

Re: Pacman install optional dependencies

If prompts for individual optional dependencies are desired, some more complexity is required, i believe.

Such as

typeset -a os
for o in `expac -S '%o\n' $pkgs`
do
  read -p "Install ${o}? " r
  [[ ${r,,} =~ ^y(|e|es)$ ]] && os+=( $o )
done

pacman -S $pkgs ${os[@]}

This assumes that no package name exists twice in the configured repositories.

A capital %O could be used to additionally list the respective reason on each prompt.


Edit: Fixed usage of whole array.  Alternatively, a normal variable with spaces would suffice.

Last edited by respiranto (2021-01-01 17:13:42)

Offline

#6 2021-01-01 17:05:43

brighton64
Member
Registered: 2020-11-24
Posts: 4

Re: Pacman install optional dependencies

Thanks i will try this

Offline

Board footer

Powered by FluxBB