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

Martin Panter vadmium+patch at gmail.com
Tue Oct 30 22:28:48 EDT 2012


On 31/10/2012, Allan McRae <allan at archlinux.org> wrote:
> On 31/10/12 09:54, Martin Panter wrote:
>> 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...

I have a Pacman wrapper called “roopwn” that I am playing with, linked
in my ~/bin/ directory. This seems to me to be a nice way to use it as
I develop it.

>> ---
>>  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?

[vadmium at patig pacaur]$ makepkg --syncdeps  # Requires “expac” to be
installed first
==> Making package: pacaur 3.2.6-1 (Wed Oct 31 02:10:34 UTC 2012)
==> Checking runtime dependencies...
==> Installing missing dependencies...
resolving dependencies...

Packages (1): expac-1-1
. . .
(1/1) installing expac                             [######################] 100%
/home/bin/../proj/pacman/pacman/scripts/makepkg.sh.in: line 890:
roopwn: command not found
==> ERROR: 'roopwn' returned a fatal error (127):
[Exit 1]
[vadmium at patig pacaur]$

> 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)

Sounds like that could be better. Then “makepkg --syncdeps” should
actually be usable in the above case.


More information about the pacman-dev mailing list