Обсуждение: Add subdirectory support for DATA/DOCS with PGXS
Hi all, Since moving PostGIS over to PGXS for the 1.4 release, we've been looking at how we can support multiple versions of PostGIS being installed in different databases within the same cluster. We are able to version the .so file produced by PGXS without too much difficulty, however PGXS in its current form does not have the ability to install different versions of the DATA or DOCS files within the same installation. The attached patch is a prototype which allows the user to specify a new MODULEDIR variable in a module makefile which, if specified, will install DATA and DOCS items in contrib/$(MODULEDIR) rather than just contrib. If MODULEDIR is left unspecified, the files will simply be stored directly in contrib/ as before. In my current development setup here, the head of the new PostGIS PGXS Makefile now looks like this: MODULE_big=postgis-1.5 MODULEDIR=$(MODULE_big) ... ... With this patch in place, "make install" on the PGXS will correctly install the DATA and DOCS files in versioned directories and therefore allow multiple installations within the same database cluster. The coding within the Makefile isn't too difficult in its current form, but I'd be interested to get some initial feedback as to whether the introduction of a new MODULEDIR variable is the best way to add this new piece of functionality. Many thanks, Mark. -- Mark Cave-Ayland - Senior Technical Architect PostgreSQL - PostGIS Sirius Corporation plc - control through freedom http://www.siriusit.co.uk t: +44 870 608 0063 Sirius Labs: http://www.siriusit.co.uk/labs diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index a83dad3..4e17e8a 100644 --- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -19,8 +19,11 @@ # # MODULES -- list of shared objects to be build from source file with # same stem (do not include suffix in this list) -# DATA -- random files to install into $PREFIX/share/contrib -# DATA_built -- random files to install into $PREFIX/share/contrib, +# MODULEDIR -- subdirectory under contrib into which DATA and DOCS are +# installed (if not set, DATA and DOCS files are installed directly +# under the contrib/ directory) +# DATA -- random files to install into $PREFIX/share/contrib/$MODULEDIR +# DATA_built -- random files to install into $PREFIX/share/contrib/$MODULEDIR, # which need to be built first # DATA_TSEARCH -- random files to install into $PREFIX/share/tsearch_data # DOCS -- random files to install under $PREFIX/doc/contrib @@ -86,12 +89,16 @@ include $(top_srcdir)/src/Makefile.shlib all: all-lib endif # MODULE_big +ifdef MODULEDIR +moduledir = /$(MODULEDIR) +endif + install: all installdirs ifneq (,$(DATA)$(DATA_built)) @for file in $(addprefix $(srcdir)/, $(DATA)) $(DATA_built); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/contrib'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/contrib'; \ + echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/contrib$(moduledir)'"; \ + $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/contrib$(moduledir)'; \ done endif # DATA ifneq (,$(DATA_TSEARCH)) @@ -109,8 +116,8 @@ endif # MODULES ifdef DOCS ifdef docdir @for file in $(addprefix $(srcdir)/, $(DOCS)); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/contrib'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/contrib'; \ + echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/contrib$(moduledir)'"; \ + $(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/contrib$(moduledir)'; \ done endif # docdir endif # DOCS @@ -137,7 +144,7 @@ endif # MODULE_big installdirs: ifneq (,$(DATA)$(DATA_built)) - $(MKDIR_P) '$(DESTDIR)$(datadir)/contrib' + $(MKDIR_P) '$(DESTDIR)$(datadir)/contrib$(moduledir)' endif ifneq (,$(DATA_TSEARCH)) $(MKDIR_P) '$(DESTDIR)$(datadir)/tsearch_data' @@ -147,7 +154,7 @@ ifneq (,$(MODULES)) endif ifdef DOCS ifdef docdir - $(MKDIR_P) '$(DESTDIR)$(docdir)/contrib' + $(MKDIR_P) '$(DESTDIR)$(docdir)/contrib$(moduledir)' endif # docdir endif # DOCS ifneq (,$(PROGRAM)$(SCRIPTS)$(SCRIPTS_built)) @@ -161,7 +168,7 @@ endif # MODULE_big uninstall: ifneq (,$(DATA)$(DATA_built)) - rm -f $(addprefix '$(DESTDIR)$(datadir)'/contrib/, $(notdir $(DATA) $(DATA_built))) + rm -f $(addprefix '$(DESTDIR)$(datadir)'/contrib$(moduledir)/, $(notdir $(DATA) $(DATA_built))) endif ifneq (,$(DATA_TSEARCH)) rm -f $(addprefix '$(DESTDIR)$(datadir)'/tsearch_data/, $(notdir $(DATA_TSEARCH))) @@ -170,7 +177,7 @@ ifdef MODULES rm -f $(addprefix '$(DESTDIR)$(pkglibdir)'/, $(addsuffix $(DLSUFFIX), $(MODULES))) endif ifdef DOCS - rm -f $(addprefix '$(DESTDIR)$(docdir)'/contrib/, $(DOCS)) + rm -f $(addprefix '$(DESTDIR)$(docdir)'/contrib$(moduledir)/, $(DOCS)) endif ifdef PROGRAM rm -f '$(DESTDIR)$(bindir)/$(PROGRAM)$(X)'
Mark Cave-Ayland wrote: > The attached patch is a prototype which allows the user to specify a > new MODULEDIR variable in a module makefile which, if specified, > will install DATA and DOCS items in contrib/$(MODULEDIR) rather than > just contrib. If MODULEDIR is left unspecified, the files will > simply be stored directly in contrib/ as before. As a proof of its usefulness, you could remove DATA_TSEARCH and replace it with usage of MODULEDIR, right? -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Alvaro Herrera wrote: >> The attached patch is a prototype which allows the user to specify a >> new MODULEDIR variable in a module makefile which, if specified, >> will install DATA and DOCS items in contrib/$(MODULEDIR) rather than >> just contrib. If MODULEDIR is left unspecified, the files will >> simply be stored directly in contrib/ as before. > > As a proof of its usefulness, you could remove DATA_TSEARCH and replace > it with usage of MODULEDIR, right? Not in its current form because PGXS always places files underneath a contrib/ subdirectory within datadir. However, if people are happier with this approach then it shouldn't be too hard to alter things so that my PGXS Makefile would look like this: MODULE_big=postgis-1.5 MODULEDIR=contrib/$(MODULE_big) Once in this form it should then be possible to use this code to replace the DATA_TSEARCH variable that is currently in place. ATB, Mark. -- Mark Cave-Ayland - Senior Technical Architect PostgreSQL - PostGIS Sirius Corporation plc - control through freedom http://www.siriusit.co.uk t: +44 870 608 0063 Sirius Labs: http://www.siriusit.co.uk/labs
Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> writes: > Alvaro Herrera wrote: >> As a proof of its usefulness, you could remove DATA_TSEARCH and replace >> it with usage of MODULEDIR, right? > Not in its current form because PGXS always places files underneath a > contrib/ subdirectory within datadir. However, if people are happier > with this approach then it shouldn't be too hard to alter things so that > my PGXS Makefile would look like this: > MODULE_big=postgis-1.5 > MODULEDIR=contrib/$(MODULE_big) If you can set it up in such a way that the default behavior doesn't change, this would be workable. I don't think we want people to suddenly find their stuff installing in the wrong place. It probably wouldn't be that hard, something along the lines ofifndef MODULEDIRMODULEDIR=contribendif ought to do it no? regards, tom lane
Tom Lane wrote: > If you can set it up in such a way that the default behavior doesn't > change, this would be workable. I don't think we want people to > suddenly find their stuff installing in the wrong place. > > It probably wouldn't be that hard, something along the lines of > ifndef MODULEDIR > MODULEDIR=contrib > endif > ought to do it no? Yeah, that was pretty much along the lines of what I was thinking. Please find the revised v2 patch attached for comment. The one thing I have done is separated out the moduledir variable into datamoduledir and docmoduledir so there is a little bit of wiggle room if someone needs to install DATA items and DOCS items in different locations. I did have a brief look at seeing whether it would be possible to use this instead of DATA_TSEARCH, however this won't work because the DATA and DATA_TSEARCH targets need their files installed in two separate locations. ATB, Mark. -- Mark Cave-Ayland - Senior Technical Architect PostgreSQL - PostGIS Sirius Corporation plc - control through freedom http://www.siriusit.co.uk t: +44 870 608 0063 Sirius Labs: http://www.siriusit.co.uk/labs diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index a83dad3..feb7fc2 100644 --- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -19,8 +19,11 @@ # # MODULES -- list of shared objects to be build from source file with # same stem (do not include suffix in this list) -# DATA -- random files to install into $PREFIX/share/contrib -# DATA_built -- random files to install into $PREFIX/share/contrib, +# MODULEDIR -- subdirectory under contrib into which DATA and DOCS are +# installed (if not set, DATA and DOCS files are installed directly +# into the contrib/ directory) +# DATA -- random files to install into $PREFIX/share/$MODULEDIR +# DATA_built -- random files to install into $PREFIX/share/$MODULEDIR, # which need to be built first # DATA_TSEARCH -- random files to install into $PREFIX/share/tsearch_data # DOCS -- random files to install under $PREFIX/doc/contrib @@ -86,12 +89,20 @@ include $(top_srcdir)/src/Makefile.shlib all: all-lib endif # MODULE_big +ifndef MODULEDIR +datamoduledir = contrib +docmoduledir = contrib +else +datamoduledir = $(MODULEDIR) +docmoduledir = $(MODULEDIR) +endif + install: all installdirs ifneq (,$(DATA)$(DATA_built)) @for file in $(addprefix $(srcdir)/, $(DATA)) $(DATA_built); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/contrib'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/contrib'; \ + echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'"; \ + $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'; \ done endif # DATA ifneq (,$(DATA_TSEARCH)) @@ -109,8 +120,8 @@ endif # MODULES ifdef DOCS ifdef docdir @for file in $(addprefix $(srcdir)/, $(DOCS)); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/contrib'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/contrib'; \ + echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/$(docmoduledir)'"; \ + $(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/$(docmoduledir)'; \ done endif # docdir endif # DOCS @@ -137,7 +148,7 @@ endif # MODULE_big installdirs: ifneq (,$(DATA)$(DATA_built)) - $(MKDIR_P) '$(DESTDIR)$(datadir)/contrib' + $(MKDIR_P) '$(DESTDIR)$(datadir)/$(datamoduledir)' endif ifneq (,$(DATA_TSEARCH)) $(MKDIR_P) '$(DESTDIR)$(datadir)/tsearch_data' @@ -147,7 +158,7 @@ ifneq (,$(MODULES)) endif ifdef DOCS ifdef docdir - $(MKDIR_P) '$(DESTDIR)$(docdir)/contrib' + $(MKDIR_P) '$(DESTDIR)$(docdir)/$(docmoduledir)' endif # docdir endif # DOCS ifneq (,$(PROGRAM)$(SCRIPTS)$(SCRIPTS_built)) @@ -161,7 +172,7 @@ endif # MODULE_big uninstall: ifneq (,$(DATA)$(DATA_built)) - rm -f $(addprefix '$(DESTDIR)$(datadir)'/contrib/, $(notdir $(DATA) $(DATA_built))) + rm -f $(addprefix '$(DESTDIR)$(datadir)'/$(datamoduledir)/, $(notdir $(DATA) $(DATA_built))) endif ifneq (,$(DATA_TSEARCH)) rm -f $(addprefix '$(DESTDIR)$(datadir)'/tsearch_data/, $(notdir $(DATA_TSEARCH))) @@ -170,7 +181,7 @@ ifdef MODULES rm -f $(addprefix '$(DESTDIR)$(pkglibdir)'/, $(addsuffix $(DLSUFFIX), $(MODULES))) endif ifdef DOCS - rm -f $(addprefix '$(DESTDIR)$(docdir)'/contrib/, $(DOCS)) + rm -f $(addprefix '$(DESTDIR)$(docdir)'/$(docmoduledir)/, $(DOCS)) endif ifdef PROGRAM rm -f '$(DESTDIR)$(bindir)/$(PROGRAM)$(X)'
Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> writes: > Please find the revised v2 patch attached for comment. The one thing I > have done is separated out the moduledir variable into datamoduledir and > docmoduledir so there is a little bit of wiggle room if someone needs to > install DATA items and DOCS items in different locations. Why do DOCS still go into doc/contrib? Shouldn't that become doc/$MODULEDIR for consistency? regards, tom lane
Tom Lane wrote: > Why do DOCS still go into doc/contrib? Shouldn't that become > doc/$MODULEDIR for consistency? Hmmm it looks as if the code was correct but I missed the comment at the top of the file. Sorry for the confusion - revised version attached. ATB, Mark. -- Mark Cave-Ayland - Senior Technical Architect PostgreSQL - PostGIS Sirius Corporation plc - control through freedom http://www.siriusit.co.uk t: +44 870 608 0063 Sirius Labs: http://www.siriusit.co.uk/labs diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index a83dad3..76b585f 100644 --- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -19,11 +19,14 @@ # # MODULES -- list of shared objects to be build from source file with # same stem (do not include suffix in this list) -# DATA -- random files to install into $PREFIX/share/contrib -# DATA_built -- random files to install into $PREFIX/share/contrib, +# MODULEDIR -- subdirectory under contrib into which DATA and DOCS are +# installed (if not set, DATA and DOCS files are installed directly +# into the contrib/ directory) +# DATA -- random files to install into $PREFIX/share/$MODULEDIR +# DATA_built -- random files to install into $PREFIX/share/$MODULEDIR, # which need to be built first # DATA_TSEARCH -- random files to install into $PREFIX/share/tsearch_data -# DOCS -- random files to install under $PREFIX/doc/contrib +# DOCS -- random files to install under $PREFIX/doc/$MODULEDIR # SCRIPTS -- script files (not binaries) to install into $PREFIX/bin # SCRIPTS_built -- script files (not binaries) to install into $PREFIX/bin, # which need to be built first @@ -86,12 +89,19 @@ include $(top_srcdir)/src/Makefile.shlib all: all-lib endif # MODULE_big +ifndef MODULEDIR +datamoduledir = contrib +docmoduledir = contrib +else +datamoduledir = $(MODULEDIR) +docmoduledir = $(MODULEDIR) +endif install: all installdirs ifneq (,$(DATA)$(DATA_built)) @for file in $(addprefix $(srcdir)/, $(DATA)) $(DATA_built); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/contrib'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/contrib'; \ + echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'"; \ + $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'; \ done endif # DATA ifneq (,$(DATA_TSEARCH)) @@ -109,8 +119,8 @@ endif # MODULES ifdef DOCS ifdef docdir @for file in $(addprefix $(srcdir)/, $(DOCS)); do \ - echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/contrib'"; \ - $(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/contrib'; \ + echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/$(docmoduledir)'"; \ + $(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/$(docmoduledir)'; \ done endif # docdir endif # DOCS @@ -137,7 +147,7 @@ endif # MODULE_big installdirs: ifneq (,$(DATA)$(DATA_built)) - $(MKDIR_P) '$(DESTDIR)$(datadir)/contrib' + $(MKDIR_P) '$(DESTDIR)$(datadir)/$(datamoduledir)' endif ifneq (,$(DATA_TSEARCH)) $(MKDIR_P) '$(DESTDIR)$(datadir)/tsearch_data' @@ -147,7 +157,7 @@ ifneq (,$(MODULES)) endif ifdef DOCS ifdef docdir - $(MKDIR_P) '$(DESTDIR)$(docdir)/contrib' + $(MKDIR_P) '$(DESTDIR)$(docdir)/$(docmoduledir)' endif # docdir endif # DOCS ifneq (,$(PROGRAM)$(SCRIPTS)$(SCRIPTS_built)) @@ -161,7 +171,7 @@ endif # MODULE_big uninstall: ifneq (,$(DATA)$(DATA_built)) - rm -f $(addprefix '$(DESTDIR)$(datadir)'/contrib/, $(notdir $(DATA) $(DATA_built))) + rm -f $(addprefix '$(DESTDIR)$(datadir)'/$(datamoduledir)/, $(notdir $(DATA) $(DATA_built))) endif ifneq (,$(DATA_TSEARCH)) rm -f $(addprefix '$(DESTDIR)$(datadir)'/tsearch_data/, $(notdir $(DATA_TSEARCH))) @@ -170,7 +180,7 @@ ifdef MODULES rm -f $(addprefix '$(DESTDIR)$(pkglibdir)'/, $(addsuffix $(DLSUFFIX), $(MODULES))) endif ifdef DOCS - rm -f $(addprefix '$(DESTDIR)$(docdir)'/contrib/, $(DOCS)) + rm -f $(addprefix '$(DESTDIR)$(docdir)'/$(docmoduledir)/, $(DOCS)) endif ifdef PROGRAM rm -f '$(DESTDIR)$(bindir)/$(PROGRAM)$(X)'
Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> writes: > Hmmm it looks as if the code was correct but I missed the comment at the > top of the file. Sorry for the confusion - revised version attached. Applied with minor fixups (mostly improving the documentation, which was not in very good shape beforehand...) regards, tom lane