Task #5322

Build contrib modules

Added by Ivan Lezhnjov 10/28/2016 (about 5 years) ago. Updated 12/09/2016 (almost 5 years) ago.

Status:ResolvedStart date:10/28/2016
Priority:HighDue date:
Assignee:Eugene Dubinin% Done:


Category:-Spent time:-
Target version:-


Building contrib modules fails with the following error message:

Building contrib 
make -f Makefile -j1
Makefile:5: ../src/Makefile.global: No such file or directory
make: *** No rule to make target '../src/Makefile.global'.  Stop.
Command '['/bin/sh', '/tmp/tmpxgmn5skk', 'make', '-f', 'Makefile', '-j1']' returned non-zero exit status 2

The problem here seems to be that src/contrib/Makefile includes ../src/Makefile.global via a relative path and the snapcraft make plugin wasn't designed for this use case.

Our options are:

  • either patch the source code or
  • write a custom make plugin or
  • report this as a bug to snapcraft developers

and then hope they fix it. The latter is ideal, though, because PostgreSQL may not be the only program that includes a Makefile in a Makefile.


#1 Updated by Eugene Dubinin 12/01/2016 (almost 5 years) ago

  • Assignee set to Eugene Dubinin

After some research, I have discovered that the root cause of the issue is not in the Snapcraft plugin limitations, but in the source tree being used.
Lets take a look at the contrib part of snapcraft.yaml:

  plugin: make
  source: parts/postgresql/src/contrib/
    - postgresql

It acquires its source code from the Postgresql part's src/contrib subdir. It is a part of the pristine source tree without any makefiles generated by Autotools.

The contrib source tree relies on the parent directory Makefile.global, which is not there since the contrib is being used as a root and does not have the correct parent directory structure.
But even if the path is adjusted to be one dir higher in the hierarchy (e.g. source: parts/postgresql/src/contrib/) this will not help either because the parent dir does not have Autotools-generated Makefile.global, but only the Makefile.global.in

Here is the adjusted contrib part:

    plugin: make
    source: ./parts/postgresql/build
    source-subdir: contrib
      - postgresql

The idea is to steal the Autotools-processed/configured source tree from the postgres part, that's why the parts/postgresql/build subtree is being used
The source-subdir directive will tell the make plugin change the CWD to the contrib subdir before the build process starts

Hope this helps to solve the issue.

#2 Updated by Ivan Lezhnjov 12/01/2016 (almost 5 years) ago

  • Priority changed from Normal to High
  • % Done changed from 0 to 90

This appears to work. I was able to compile all current major versions with proposed fix. I also tested a couple contrib modules with 9.3.15 and they seem to work.


#3 Updated by Ivan Lezhnjov 12/09/2016 (almost 5 years) ago

  • Status changed from New to Resolved
  • % Done changed from 90 to 100

Also available in: Atom PDF