[pacman-dev] Fwd: [PATCH] Hack to detect Pacman-command-no-found error

Allan McRae allan at archlinux.org
Tue Oct 30 21:44:32 EDT 2012


On 31/10/12 09:54, Martin Panter wrote:
> [Resending after subscribing my address. If this works perhaps a note
> should be added saying you have to subscribe to be able to send to the
> list?]
> Original [patch] in case it gets garbled:
> https://github.com/vadmium/pacman-arch/commit/0a71ece.patch
> 
> If the spirit of the change is appropriate but you’re not happy about
> using the ”test” command, I’m happy to learn how to use the
> Bash-specific way with double square brackets. Or someone who already
> knows can translate it :)

Done below.

> From 0a71ece90951894953ffd7bae741d69af927bf3f Mon Sep 17 00:00:00 2001
> From: Martin Panter <vadmium à gmail·com>
> Date: Thu, 18 Oct 2012 06:31:07 +0000
> Subject: [PATCH] Hack to detect Pacman-command-no-found error
> 
> Bash also uses exit code 127 for command-not-found errors, which can occur if
> we lose access to the command given by $PACMAN. For instance after invoking
> /etc/profile, $PATH may be reset.

I'd be concerned if the software used for package management was not in
a system path...

> ---
>  scripts/makepkg.sh.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index d387b7d..307ceeb 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -895,7 +895,7 @@ check_deps() {
>         pmout=$(run_pacman -T "$@")
>         ret=$?
> 
> -       if (( ret == 127 )); then #unresolved deps
> +       if test "$ret" -eq 127 -a -n "$pmout"; then #unresolved deps

(( ret == 127 )) && [[ -n "$pmout" ]]

>                 printf "%s\n" "$pmout"
>         elif (( ret )); then
>                 error "$(gettext "'%s' returned a fatal error (%i):
> %s")" "$PACMAN"
> "$ret" "$pmout"

Now, if we hit a return of 127 due to missing command, and "$pmout" is
empty, what does this fall though message look like?


Perhaps a better approach to this would be to check the program
specified in $PACMAN is available in the check_software function and
then assign it to its full path.  i.e. PACMAN=$(which $PACMAN)

Allan



More information about the pacman-dev mailing list