You are not logged in.

#1 2013-09-08 13:34:41

kaari
Member
Registered: 2011-08-12
Posts: 22

How to ignore "target not found" errors?

I'm running pacman from a script and it would be preferable if it didn't abort because of  missing packages.
Is there a way of configuring pacman so that it installs everything it can first, and notifies the user about missing targets only at the very end? (assuming of course that the missing targets are not dependencies of other packages)

Offline

#2 2013-09-08 14:02:30

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: How to ignore "target not found" errors?

Maybe you can run a 'for' loop instead of 'pacman -Syu foo bar baz'.

Please post the exact command you're using.

Offline

#3 2013-09-08 15:19:51

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

Re: How to ignore "target not found" errors?

Or, perhaps, for a simpler output, first run a `pacman -Ss pkgname` for each one in a for loop, and append only those that are found to a variable (ie $pkglist).  Then `pacman -Syu $pkglist`.

This wouldn't be any quicker, but it would avoid errors, and it would allow the final installation to run in one shot.


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

Offline

#4 2013-09-08 16:34:42

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: How to ignore "target not found" errors?

*If* your list of packages are all _actual_ package names, (e.g. python-setuptools, NOT python-distribute which python-setuptools now provides), something like this will do:

pkgs=(foo bar baz)
pkgs_200=($(comm -12 <(pacman -Slq|sort -u) <(printf '%s\n' "${pkgs[@]}"|sort -u)))
pkgs_404=($(comm -23 <(printf '%s\n' "${pkgs[@]}"|sort -u) <(printf '%s\n' "${pkgs_200[@]}")))
pacman -S "${pkgs_200[@]}"
printf "404 Not Found:\n" >&2
printf "%s\n" "${pkgs_404[@]}" >&2

This silver ladybug at line 28...

Offline

#5 2013-09-08 16:38:46

cookies
Member
Registered: 2013-01-17
Posts: 253

Re: How to ignore "target not found" errors?

Trilby wrote:

Or, perhaps, for a simpler output, first run a `pacman -Ss pkgname` for each one in a for loop

pacman -Sp pkgname might be easier to work with.

Offline

#6 2013-09-08 20:13:50

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: How to ignore "target not found" errors?

FWIW, I actually tried posting a feature request for this before:

https://bugs.archlinux.org/task/18306

Offline

#7 2013-09-09 02:25:06

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: How to ignore "target not found" errors?

Incorporating cookies' idea (-Sp), here is a proper version that should work with any package list; even more HTTP code abuse:

#!/bin/bash

declare -a pkgs pkgs_200 pkgs_202 pkgs_404
declare -A pkgs_301

pkgs=(foo bar baz)
pkgs=($(printf '%s\n' "${pkgs[@]}"|sort -u))
pkgs_200=($(comm -12 <(pacman -Slq|sort -u) <(printf '%s\n' "${pkgs[@]}")))
pkgs_202=($(comm -23 <(printf '%s\n' "${pkgs[@]}") <(printf '%s\n' "${pkgs_200[@]}")))
for pkg in "${pkgs_202[@]}"; do
  pkgname=$(pacman -Spdd --print-format %n "$pkg" 2> /dev/null)
  if [[ -n $pkgname ]]; then
    pkgs_301[$pkg]=$pkgname
  else
    pkgs_404+=("$pkg")
  fi
done

pacman -S "${pkgs_200[@]}" "${pkgs_301[@]}"
printf "\n301 Moved Permanently:\n" >&2
paste -d : <(printf "%s\n" "${!pkgs_301[@]}") <(printf "%s\n" "${pkgs_301[@]}") >&2
printf "\n404 Not Found:\n" >&2
printf "%s\n" "${pkgs_404[@]}" >&2

Edit: use `pacman -Spdd` to prevent listing of dependencies.

Last edited by lolilolicon (2013-09-10 23:34:13)


This silver ladybug at line 28...

Offline

#8 2016-05-18 15:21:19

rakotomandimby
Member
From: Madagascar
Registered: 2014-05-07
Posts: 20
Website

Re: How to ignore "target not found" errors?

This is what I did:

for P in $( </tmp/package-list-one-per-line )
do
    if ! (pacman -Q | grep ${P} > /dev/null)
    then
        pacman -S ${P} --noconfirm
    fi
done

Offline

#9 2016-05-18 22:34:16

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,543

Re: How to ignore "target not found" errors?

rakotomandimby wrote:

This is what I did:

I doubt the OP is still looking for an answer two and a half years later. Please pay attention to the dates and follow the forum rules.
https://wiki.archlinux.org/index.php/Fo … bumping.22

Offline

#10 2016-05-18 22:52:43

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,772

Re: How to ignore "target not found" errors?

Using this opportunity to close this old thread.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB