glib-2 and gio-fam-backend install stuck or stalls on FreeBSD

You are going about your normal business, updating your ports on FreeBSD using portmaster or portupgrade. You come back an hour later to find that your update has stalled on the following:

--->  Installing the new version via the port
===>  Installing for gio-fam-backend-2.24.2
===>   gio-fam-backend-2.24.2 depends on executable: pkg-config - found
===>   gio-fam-backend-2.24.2 depends on shared library: fam.0 - found
===>   gio-fam-backend-2.24.2 depends on shared library: intl - found
===>   gio-fam-backend-2.24.2 depends on shared library: glib-2.0.0 - found
===>   Generating temporary packing list
===>  Checking if devel/gio-fam-backend already installed
gmake[1]: Entering directory `/usr/ports/devel/gio-fam-backend/work/glib-2.24.2/gio/fam'
gmake[1]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/lib/gio/modules" || ../.././install-sh -c -d "/usr/local/lib/gio/modules"
/bin/sh ../../libtool   --mode=install /usr/bin/install -c -o root -g wheel   libgiofam.la '/usr/local/lib/gio/modules'
libtool: install: /usr/bin/install -c -o root -g wheel .libs/libgiofam.so /usr/local/lib/gio/modules/libgiofam.so
libtool: install: /usr/bin/install -c -o root -g wheel .libs/libgiofam.lai /usr/local/lib/gio/modules/libgiofam.la
libtool: install: /usr/bin/install -c -o root -g wheel .libs/libgiofam.a /usr/local/lib/gio/modules/libgiofam.a
libtool: install: chmod 644 /usr/local/lib/gio/modules/libgiofam.a
libtool: install: ranlib /usr/local/lib/gio/modules/libgiofam.a
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib/gio/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
gmake  install-data-hook
gmake[2]: Entering directory `/usr/ports/devel/gio-fam-backend/work/glib-2.24.2/gio/fam'
if true && test -z "" ; then                                    \
                gio-querymodules /usr/local/lib/gio/modules ;   \
        fi

The Problem

The installation is hanging on "/usr/local/bin/gio-querymodules /usr/local/lib/gio/modules/". When you run it manually, you get the same issue, it just hangs or stalls. Running "/usr/local/bin/gio-querymodules" alone says the following:

/usr/local/bin/gio-querymodules
Usage: gio-querymodules <directory1> [<directory2> ...]
Will update giomodule.cache in the listed directories

This issue occurs when you are installing or updating the "glib-2" (/usr/ports/devel/glib20) and "gio-fam-backend" (/usr/ports/devel/gio-fam-backend) ports. So, just for fun I I did an HUP on the hung process and the install of glib20 completed. However, when upgrading gio-fam-backend the same happens, but the HUP "trick" does not work here.

How to Fix (aka: Workaround)

To resolve this problem, uninstall the "gio-fam-backend" if it isn't already.

cd usr/ports/devel/gio-fam-backend
make deinstall

Most likely if you are having this issue, the port will already be uninstalled and you'll get an error saying so. That is okay and expected. It means we have some manual clean-up to do.

Go ahead and rename the "/usr/local/lib/gio" directory to "/usr/local/lib/gio.BAD", or If you prefer, just move or delete the files in the "modules" directory within that directory witch contain the word "fam" in them. On my system, their were only 3:

libgiofam.a
libgiofam.la
libgiofam.so

If you decide to, don't rename them and leave them in their, you must move or delete those file out of that directory. Since my setup only had those 3 files, I decided to just remove or move the whole "/usr/local/lib/gio" directory.

mv /usr/local/lib/gio /usr/local/lib/gio.BAD

Now, go ahead and update the glib-2 port

cd /usr/ports/devel/glib20
make clean
make deinstall
make install

This should complete successfully.

Next, build the gio-fam-backend port, but do not install it. The following command will take care of that:

cd /usr/ports/devel/gio-fam-backend
make clean
make build

When the port is done building, you will need to edit the Makefile located in "/usr/ports/devel/gio-fam-backend/work/glib-2.24.2/gio/fam/Makefile". Note, your path may differ slightly. Adjust accordingly.

edit /usr/ports/devel/gio-fam-backend/work/glib-2.24.2/gio/fam/Makefile

Locate the line that has "RUN_QUERY_MODULES = true", on my system it was at line 379. Directly below that line you'll see a commented line that reads "RUN_QUERY_MODULES = false". Modify the "/usr/ports/devel/gio-fam-backend/work/glib-2.24.2/gio/fam/Makefile" so that it reads like what is shown below:

#RUN_QUERY_MODULES = true
RUN_QUERY_MODULES = false

Save the file and install the gio-fam-backend port.

make install

This should complete successfully.

About the Problem

I am not sure what is going on, but apparently their is some kind of bug with the gio-fam-backend port that causes it to hang when running the "/usr/local/bin/gio-querymodules" executable. The fix above is more of a workaround since we are skipping the step that runs gio-querymodules. Obviously the maintainer of this port saw it as a potential problem sine he/she built in the logic to skip the offending step.

I am also not sure what side effects will occur by using the work around, so:
USE AT YOUR OWN RISK!!