Opened 6 years ago

Closed 6 years ago

#57039 closed defect (fixed)

glib2 @2.56.2: build fails due to Tiger "which" command

Reported by: xstnztk (Martin Jerabek) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.5.3
Keywords: tiger Cc:
Port: glib2, glib2-devel

Description

I tried to build git which has glib2 as a dependency on OSX Tiger 10.4.11. Building glib2 failed due to the fact that the autogen.sh script tried to determine with the which command whether or not the "gtkdocize" command was installed. It expected that the which command returned nothing on stdout if gtkdocize was missing. Unfortunately on OSX Tiger, which is a csh script /usr/bin/which which always outputs something to stdout:

$ which gtkdocize 2> /dev/null
no gtkdocize in /opt/local/bin /opt/local/sbin /bin /sbin /usr/bin /usr/sbin

autogen.sh stores this output in a shell variable which leads to the error output shown below:

--->  Configuring glib2
Executing:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_glib2/glib2/work/glib-2.56.2" && ./autogen.sh --prefix=/opt/local --enable-static --disable-libelf --disable-compile-warnings --disable-gtk-doc --with-pcre=system ac_cv_prog_AWK=/usr/bin/awk ac_cv_prog_GTKDOC_CHECK= ac_cv_path_GTKDOC_CHECK_PATH= ac_cv_path_GTKDOC_MKPDF= ac_cv_path_GTKDOC_REBASE= --disable-dtrace --with-appinfo-impl=generic
./autogen.sh: line 11: test: too many arguments
./autogen.sh: line 19: gtkdocize: command not found
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_glib2/glib2/work/glib-2.56.2" && ./autogen.sh --prefix=/opt/local --enable-static --disable-libelf --disable-compile-warnings --disable-gtk-doc --with-pcre=system ac_cv_prog_AWK=/usr/bin/awk ac_cv_prog_GTKDOC_CHECK= ac_cv_path_GTKDOC_CHECK_PATH= ac_cv_path_GTKDOC_MKPDF= ac_cv_path_GTKDOC_REBASE= --disable-dtrace --with-appinfo-impl=generic
Exit code: 127
Error: Failed to configure glib2: configure failure: command execution failed

https://stackoverflow.com/a/677212 advocates against using which and for command -v which works in all POSIX-compatible shells, even in the ancient BASH 2.05b.0(1) which is the default shell on Tiger.

Is this fix something which should go into a MacPorts patch file?

Attachments (2)

tiger-glib-2.56.2-configure.log (29.4 KB) - added by kencu (Ken) 6 years ago.
tiger glib2 successful configure log
patch-autogen.sh.diff (727 bytes) - added by xstnztk (Martin Jerabek) 6 years ago.
Patch fixing the autogen.sh script to use command -v instead of which to determine if a command is present.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign@… removed
Owner: set to ryandesign
Port: glib2-devel added
Status: newaccepted

Thanks for letting me know, I'll get that fixed.

comment:2 Changed 6 years ago by kencu (Ken)

for whatever reason, I have had no such issue when building glib2 on Tiger:

$ which gtkdocsize
no gtkdocsize in /opt/local/bin /opt/local/sbin /bin /sbin /usr/bin /usr/sbin
$ port -v installed | grep glib2
  glib2 @2.46.2_0 platform='darwin 8' archs='ppc' date='2016-03-01T11:22:02-0800'
  glib2 @2.48.1_0 platform='darwin 8' archs='ppc' date='2016-07-11T18:56:26-0700'
  glib2 @2.48.2_0 platform='darwin 8' archs='ppc' date='2016-08-22T23:45:45-0700'
  glib2 @2.50.0_0 platform='darwin 8' archs='ppc' date='2016-10-01T09:56:48-0700'
  glib2 @2.50.1_0 platform='darwin 8' archs='ppc' date='2016-10-27T08:26:04-0700'
  glib2 @2.50.2_0 platform='darwin 8' archs='ppc' date='2016-11-19T23:59:58-0800'
  glib2 @2.50.3_0 platform='darwin 8' archs='ppc' date='2017-02-24T17:49:43-0800'
  glib2 @2.52.3_0+x11 platform='darwin 8' archs='ppc' date='2017-08-12T10:16:06-0700'
  glib2 @2.54.1_0+x11 platform='darwin 8' archs='ppc' date='2017-10-07T13:44:27-0700'
  glib2 @2.54.2_0+x11 platform='darwin 8' archs='ppc' date='2017-11-04T11:57:29-0700'
  glib2 @2.54.2_1+x11 platform='darwin 8' archs='ppc' date='2017-12-25T17:54:12-0800'
  glib2 @2.54.3_0+x11 platform='darwin 8' archs='ppc' date='2018-01-24T18:25:46-0800'
  glib2 @2.54.3_1+x11 platform='darwin 8' archs='ppc' date='2018-02-15T20:58:00-0800'
  glib2 @2.56.1_0+x11 platform='darwin 8' archs='ppc' date='2018-04-14T09:56:44-0700'
  glib2 @2.56.2_0+x11 (active) platform='darwin 8' archs='ppc' date='2018-08-25T12:21:15-0700'
Last edited 6 years ago by kencu (Ken) (previous) (diff)

comment:3 Changed 6 years ago by kencu (Ken)

I am using a newer bash, if that makes any difference:

$ which bash
/opt/local/bin/bash

$ port -v installed bash
The following ports are currently installed:
  bash @4.3.46_0 platform='darwin 8' archs='ppc' date='2016-08-26T13:45:43-0700'
  bash @4.4.0_0 platform='darwin 8' archs='ppc' date='2016-10-01T13:15:24-0700'
  bash @4.4.5_0 platform='darwin 8' archs='ppc' date='2016-12-23T17:11:08-0800'
  bash @4.4.12_0 platform='darwin 8' archs='ppc' date='2017-02-08T15:51:12-0800'
  bash @4.4.18_0 platform='darwin 8' archs='ppc' date='2018-02-15T12:47:01-0800'
  bash @4.4.19_0 platform='darwin 8' archs='ppc' date='2018-04-14T10:48:51-0700'
  bash @4.4.23_0 (active) platform='darwin 8' archs='ppc' date='2018-06-06T17:19:42-0700'

Changed 6 years ago by kencu (Ken)

tiger glib2 successful configure log

comment:4 Changed 6 years ago by kencu (Ken)

here's the configure log (successful) to see if you can see where it goes wrong.

comment:5 Changed 6 years ago by kencu (Ken)

but printenv still says:

$ printenv
TERM=xterm-color
SHELL=/bin/bash
...

and glib2 still configures correctly, even if I deactivate bash.

Last edited 6 years ago by kencu (Ken) (previous) (diff)

comment:6 Changed 6 years ago by kencu (Ken)

hold on -- I do have gtkdocize:

$ which gtkdocize
/opt/local/bin/gtkdocize

$ port provides /opt/local/bin/gtkdocize
/opt/local/bin/gtkdocize is provided by: gtk-doc

so I suppose that is why glib2 builds for me without any troubles.

comment:7 Changed 6 years ago by xstnztk (Martin Jerabek)

Yes, the build only fails if gtkdocize is not present but the bash version should not matter because which is not a shell built-in in any bash version as far as I can tell from the documentation, so the Tiger script with its unexpected behavior will always be used. (BTW, it is a built-in in zsh.)

On Linux (at least on Ubuntu), which is a shell script which does not output anything to stdout if the command is not found, so it seems that the glib2 script expects this behavior. which is not defined by POSIX so its behavior (and even its presence) is not guaranteed, whereas the exact behavior of command -v is defined by POSIX and so has a much bigger chance of working on most platforms:

"Otherwise, no output shall be written and the exit status shall reflect that the name was not found."

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html

I would prefer not having to install gtk-doc with all its dependencies just to get glib2 (which I anyway only need for git). It would of course be trivial to hack around this problem on my system (define my own which, or create a dummy gtkdocize) but IMHO this should be fixed for everybody.

I see that there are already several patch files for glib2, so I can try to create another one for this problem. Anyway, thanks for keeping the old systems alive!

comment:8 Changed 6 years ago by xstnztk (Martin Jerabek)

Find attached a patch which allowed me to successfully build glib2 on Tiger. I not only replaced the which command but also cleaned up the code a bit because the two checks for the presence of gtkdocize and for autoreconf were different for no good reason. The latter also served as a test that command -v worked as expected for commands which are present.

This is the first patch I ever made for MacPorts, so please let me know if there are any problems with it. If you accept it, I will try to get it included upstream.

Changed 6 years ago by xstnztk (Martin Jerabek)

Attachment: patch-autogen.sh.diff added

Patch fixing the autogen.sh script to use command -v instead of which to determine if a command is present.

comment:9 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

Thanks. It can be fixed a bit more simply than that. I've submitted a PR for the simpler fix upstream:

https://gitlab.gnome.org/GNOME/glib/merge_requests/277

Unfortunately this usage of which permeates gnome projects. I've sent a PR to pango too:

https://gitlab.gnome.org/GNOME/pango/merge_requests/16

But I suspect dozens or hundreds of other gnome projects should get the same fix.

comment:10 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

We should probably wait to see what upstream says about those two PRs before making lots more for other projects.

The issue may become moot soon anyway, since gnome projects are switching to meson, so the autotools-specific autogen.sh scripts will be going away. For glib, the meson build system is already done, and the autotools build system that we're using for it in MacPorts now will be deprecated with the next major version and removed the next major version after that.

But I don't know if meson works on Tiger. I'd like it to, so if you want to see if you can build some port that uses meson on Tiger that would be helpful, and if you find any problems you can file tickets and we can look into those.

comment:11 in reply to:  10 Changed 6 years ago by kencu (Ken)

Replying to ryandesign:

But I don't know if meson works on Tiger.

Not as currently installed it doesn't, due to rpath usage, but it does appear to function with some minor modifications. See 56932.

Similarly, gobject-introspection also needs some tweaking. See 56729

comment:12 in reply to:  9 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to ryandesign:

Thanks. It can be fixed a bit more simply than that. I've submitted a PR for the simpler fix upstream:

https://gitlab.gnome.org/GNOME/glib/merge_requests/277

A glib developer says that PR looks ok but hasn't merged it yet because their automated build system found an error, though I don't think the error is related to this change.

Unfortunately this usage of which permeates gnome projects. I've sent a PR to pango too:

https://gitlab.gnome.org/GNOME/pango/merge_requests/16

A pango developer merged that PR.

comment:13 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: acceptedclosed

In 336e245212850ab0a5010ea8bee468088e103d06/macports-ports (master):

glib2, glib2-devel: Fix build on Tiger w/o gtk-doc

Fix build on Tiger when gtk-doc is not installed by using "command -v"
instead of "which" in autogen.sh.

Closes: #57039

Note: See TracTickets for help on using tickets.