Subject: Re: bug#24657: Autoconf macro GUILE_PROGS only looks for guile without version suffix even if given version - patch included

From: Freja Nordsiek <[email-masked]>
Date: Tue, 14 Mar 2017 15:25:42 +0100

Found a bug in the modifications you made. Sorry for not catching this
before it got included into the Guile 2.1.8 release.

When constructing the candidates for the guile executable
(_guile_candidates), the version numbers essentially get reverse. This
is not noticeable for 2.2 since 2.2 reversed is still 2.2. But it is a
major issue for Guile 2.0.x and 1.8.x where 0.2 and 8.1 get generated
meaning the right executables could be missed. For the current version
of GUILE_PROGS, looking for 2.0 results in the following candidates

    guile-0.2 guile0.2 guile-2 guile2 guile

and for 1.8

    guile-8.1 guile8.1 guile-1 guile1 guile

The fix is luckily pretty trivial. A patch is attached.

For convenience of anyone trying to reproduce this bug, here are two
shell scripts that will take the version as the first input argument
and return the generated guile executable candidates.

The version with the bug is

    #!/bin/sh
    _guile_required_version=$1
    _guile_candidates=guile
    _tmp=
    for v in `echo "$_guile_required_version" | tr . ' '`; do
      if test -n "$_tmp"; then _tmp=.$_tmp; fi
      _tmp=$v$_tmp
      _guile_candidates="guile-$_tmp guile$_tmp $_guile_candidates"
    done
    echo $_guile_candidates

And the version with the fix is

    #!/bin/sh
    _guile_required_version=$1
    _guile_candidates=guile
    _tmp=
    for v in `echo "$_guile_required_version" | tr . ' '`; do
      if test -n "$_tmp"; then _tmp=$_tmp.; fi
      _tmp=$_tmp$v
      _guile_candidates="guile-$_tmp guile$_tmp $_guile_candidates"
    done
    echo $_guile_candidates

On Thu, Feb 23, 2017 at 10:43 AM, Andy Wingo <[email-masked]> wrote:
> Hi Freja,
>
> Thanks for this bug report and the patch, and sorry for the delay :)
>
> On Mon 10 Oct 2016 11:45, Freja Nordsiek <[email-masked]> writes:
>
>> While trying to build a package that uses guile with autotools, I
>> found a problem in the provided GUILE_PROGS macro.
>>
>> The macro searches for the executables guile, guild, guile-config, and
>> guile-tools. The problem is that even if the macro is given the
>> version, it only looks for guile, guild, etc. with no version suffix.
>
> Applied your patch with some small modifications; attached.  Let me know
> if it works for you!
>
> Andy
>
From 205f41d41b94f12670394ec526dddeaf1416d740 Mon Sep 17 00:00:00 2001
From: Freja Nordsiek <[email-masked]>
Date: Tue, 14 Mar 2017 15:14:47 +0100
Subject: [PATCH] Fixed reversed version order bug in GUILE_PROGS Autoconf
 macro.

---
 meta/guile.m4 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/guile.m4 b/meta/guile.m4
index 4a2e285..501a21c 100644
--- a/meta/guile.m4
+++ b/meta/guile.m4
@@ -234,8 +234,8 @@ AC_DEFUN([GUILE_PROGS],
   _guile_candidates=guile
   _tmp=
   for v in `echo "$_guile_required_version" | tr . ' '`; do
-    if test -n "$_tmp"; then _tmp=.$_tmp; fi
-    _tmp=$v$_tmp
+    if test -n "$_tmp"; then _tmp=$_tmp.; fi
+    _tmp=$_tmp$v
     _guile_candidates="guile-$_tmp guile$_tmp $_guile_candidates"
   done
 
-- 
2.9.3