System-wide GAR

If you’re building Solaris packages using GAR from OpenCSW, you’re familiar with the GAR code inclusion practice. Each package build recipe can be checked out individually, and pulls GAR code using the svn:externals parameter. Try the following command if you don’t know what I mean:

svn co https://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/pkg/mysql5

This sort of works, but since SourceForge Subversion repository works somewhat slow, it can be irritating if there’s a GAR update you want to roll out to all your checked out packages.

As an alternative to svn:externals, you can use a system wide GAR installation, and use a symlink:

ln -s /opt/csw/src/gar/v2 gar

There’s currently no official GAR package, but you can build it yourself from its Subversion build recipe.

There’s one problem. If you don’t have the symlink and your Makefile tries to include the gar/category.mk file, your command will fail with:

Makefile:29: gar/category.mk: No such file or directory
gmake: *** No rule to make target `gar/category.mk'.  Stop.

It would be nice to make the symlink if it didn’t exist, right? I’ve found a way to do it:

ifeq ($(shell test -h gar && echo yes || echo no), yes)
include gar/category.mk
else
%:
        @echo "Making the symlink to GAR"
        ln -s /opt/csw/src/gar/v2 gar
        @echo "Please re-run your command."                     
endif

The idea is that it only includes the file if the symlink exists. Otherwise, it makes the symlink and asks us to re-run the gmake command.

I haven’t so far found a way to make it work in one go.

Author: automatthias

You won't believe what a skeptic I am.