2

How do we update some certain packages by use pacman ?

E.g how do we update only packages (in regex syntax) py.+ as:

$ sudo pacman -S 'py.+' 
error: target not found: py.+

not work
Please help out, thanks in advance

2 Answers2

2

Note that, on Arch Linux, partial upgrades are not supported; you should always upgrade the whole system at once (pacman -Syu) and upgrade the whole system when installing new packages (pacman -Syu package).
pacman -S package would install the version of package that is currently in your sync database, likely reinstalling the already installed version.
pacman -Sy followed by pacman -S package would update the sync database and then install the latest version of package and its dependencies, possibly breaking other installed packages that depend on older versions of the latter.
As noted in the wiki page linked above, pacman -Syuw followed by pacman -S package is not a solution either.

That said, based on the Arch Wiki, a common way to give pacman a list of packages as arguments is to generate it using another pacman instance. For example, to get the details about a list of installed packages whose name or description1 starts with py (but is not just py), filtering out foreign ones:

pacman -Qsq '^py[^ ]+$' | xargs pacman -Qnq | xargs -o pacman -Si

Where xargs is used to avoid "argument list too long" errors.

When dealing with package names, the assumption that they will not contain whitespace, quoting, globbing or otherwise uncommon characters is safe. Leaving command substitions unquoted would otherwise be a likely bad idea2; just make sure the value of IFS does not include any characters that may appear in package names.

The non standard xargs's -o option (usually available on Arch Linux, which by default ships its GNU implementation), which tells xargs to reopen standard input as /dev/tty and make it available to the executed command, would be necessary when running pacman commands that require user interaction (though not actually needed in the above example).

Alternatively, if you feel confident the number of packages returned by your search will be small, you may use nested command substitutions:

pacman -Si $(pacman -Qnq $(pacman -Qsq '^py[^ ]+$'))

1 Other utilities may be needed to perform a regexp search on names only, e.g. pacsift (from pacutils) or expac. Note that pacman's search options also check the "provides" field of packages.

2 See When is double-quoting necessary?, Why does my shell script choke on whitespace or other special characters? and Security implications of forgetting to quote a variable in bash/POSIX shells.

fra-san
  • 10,205
  • 2
  • 22
  • 43
0

it is sort of supported, you can just use --ignore package1,package2 and ignore everything

so sudo or doas pacman -Syu --ignore vim,firefox,linux

Jory S
  • 1