Commit 24d1280c authored by Tom Lane's avatar Tom Lane

Clean up installation directory choices for extensions.

Arrange for the control files to be in $SHAREDIR/extension not
$SHAREDIR/contrib, since we're generally trying to deprecate the term
"contrib" and this is a once-in-many-moons opportunity to get rid of it in
install paths.  Fix PGXS to install the $EXTENSION file into that directory
no matter what MODULEDIR is set to; a nondefault MODULEDIR should only
affect the script and secondary extension files.  Fix the control file
directory parameter to be interpreted relative to $SHAREDIR, to avoid a
surprising disconnect between how you specify that and what you set
MODULEDIR to.

Per discussion with David Wheeler.
parent 12147499
...@@ -365,13 +365,13 @@ ...@@ -365,13 +365,13 @@
The <xref linkend="sql-createextension"> command relies on a control The <xref linkend="sql-createextension"> command relies on a control
file for each extension, which must be named the same as the extension file for each extension, which must be named the same as the extension
with a suffix of <literal>.control</>, and must be placed in the with a suffix of <literal>.control</>, and must be placed in the
installation's <literal>SHAREDIR/contrib</literal> directory. There installation's <literal>SHAREDIR/extension</literal> directory. There
must also be at least one <acronym>SQL</> script file, which follows the must also be at least one <acronym>SQL</> script file, which follows the
naming pattern naming pattern
<literal><replaceable>extension</>-<replaceable>version</>.sql</literal> <literal><replaceable>extension</>-<replaceable>version</>.sql</literal>
(for example, <literal>foo-1.0.sql</> for version <literal>1.0</> of (for example, <literal>foo-1.0.sql</> for version <literal>1.0</> of
extension <literal>foo</>). By default, the script file(s) are also extension <literal>foo</>). By default, the script file(s) are also
placed in the <literal>SHAREDIR/contrib</literal> directory; but the placed in the <literal>SHAREDIR/extension</literal> directory; but the
control file can specify a different directory for the script file(s). control file can specify a different directory for the script file(s).
</para> </para>
...@@ -395,7 +395,9 @@ ...@@ -395,7 +395,9 @@
<para> <para>
The directory containing the extension's <acronym>SQL</> script The directory containing the extension's <acronym>SQL</> script
file(s). Unless an absolute path is given, the name is relative to file(s). Unless an absolute path is given, the name is relative to
the <literal>SHAREDIR/contrib</literal> directory. the installation's <literal>SHAREDIR</literal> directory. The
default behavior is equivalent to specifying
<literal>directory = 'extension'</>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -905,23 +907,26 @@ include $(PGXS) ...@@ -905,23 +907,26 @@ include $(PGXS)
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><varname>MODULEDIR</varname></term> <term><varname>EXTENSION</varname></term>
<listitem> <listitem>
<para> <para>
subdirectory into which EXTENSION, DATA and DOCS files should be extension name(s); for each name you must provide an
installed (if not set, default is <literal>contrib</literal>) <literal><replaceable>extension</replaceable>.control</literal> file,
which will be installed into
<literal><replaceable>prefix</replaceable>/share/extension</literal>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>EXTENSION</varname></term> <term><varname>MODULEDIR</varname></term>
<listitem> <listitem>
<para> <para>
extension name(s); for each name you must provide an subdirectory of <literal><replaceable>prefix</>/share</literal>
<literal><replaceable>extension</replaceable>.control</literal> file, into which DATA and DOCS files should be installed
which will be installed into (if not set, default is <literal>extension</literal> if
<literal><replaceable>prefix</replaceable>/share/$MODULEDIR</literal> <varname>EXTENSION</varname> is set,
or <literal>contrib</literal> if not)
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
...@@ -67,7 +67,7 @@ CREATE EXTENSION <replaceable class="parameter">extension_name</replaceable> ...@@ -67,7 +67,7 @@ CREATE EXTENSION <replaceable class="parameter">extension_name</replaceable>
The name of the extension to be The name of the extension to be
installed. <productname>PostgreSQL</productname> will create the installed. <productname>PostgreSQL</productname> will create the
extension using details from the file extension using details from the file
<literal>SHAREDIR/contrib/</literal><replaceable class="parameter">extension</replaceable><literal>.control</literal>. <literal>SHAREDIR/extension/</literal><replaceable class="parameter">extension_name</replaceable><literal>.control</literal>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
...@@ -278,7 +278,7 @@ get_extension_control_directory(void) ...@@ -278,7 +278,7 @@ get_extension_control_directory(void)
get_share_path(my_exec_path, sharepath); get_share_path(my_exec_path, sharepath);
result = (char *) palloc(MAXPGPATH); result = (char *) palloc(MAXPGPATH);
snprintf(result, MAXPGPATH, "%s/contrib", sharepath); snprintf(result, MAXPGPATH, "%s/extension", sharepath);
return result; return result;
} }
...@@ -291,7 +291,7 @@ get_extension_control_filename(const char *extname) ...@@ -291,7 +291,7 @@ get_extension_control_filename(const char *extname)
get_share_path(my_exec_path, sharepath); get_share_path(my_exec_path, sharepath);
result = (char *) palloc(MAXPGPATH); result = (char *) palloc(MAXPGPATH);
snprintf(result, MAXPGPATH, "%s/contrib/%s.control", snprintf(result, MAXPGPATH, "%s/extension/%s.control",
sharepath, extname); sharepath, extname);
return result; return result;
...@@ -305,7 +305,7 @@ get_extension_script_directory(ExtensionControlFile *control) ...@@ -305,7 +305,7 @@ get_extension_script_directory(ExtensionControlFile *control)
/* /*
* The directory parameter can be omitted, absolute, or relative to the * The directory parameter can be omitted, absolute, or relative to the
* control-file directory. * installation's share directory.
*/ */
if (!control->directory) if (!control->directory)
return get_extension_control_directory(); return get_extension_control_directory();
...@@ -315,8 +315,7 @@ get_extension_script_directory(ExtensionControlFile *control) ...@@ -315,8 +315,7 @@ get_extension_script_directory(ExtensionControlFile *control)
get_share_path(my_exec_path, sharepath); get_share_path(my_exec_path, sharepath);
result = (char *) palloc(MAXPGPATH); result = (char *) palloc(MAXPGPATH);
snprintf(result, MAXPGPATH, "%s/contrib/%s", snprintf(result, MAXPGPATH, "%s/%s", sharepath, control->directory);
sharepath, control->directory);
return result; return result;
} }
......
...@@ -25,9 +25,10 @@ ...@@ -25,9 +25,10 @@
# #
# The following variables can also be set: # The following variables can also be set:
# #
# MODULEDIR -- subdirectory into which EXTENSION, DATA and DOCS files
# should be installed (if not set, default is "contrib")
# EXTENSION -- name of extension (there must be a $EXTENSION.control file) # EXTENSION -- name of extension (there must be a $EXTENSION.control file)
# MODULEDIR -- subdirectory of $PREFIX/share into which DATA and DOCS files
# should be installed (if not set, default is "extension" if EXTENSION
# is set, or "contrib" if not)
# DATA -- random files to install into $PREFIX/share/$MODULEDIR # DATA -- random files to install into $PREFIX/share/$MODULEDIR
# DATA_built -- random files to install into $PREFIX/share/$MODULEDIR, # DATA_built -- random files to install into $PREFIX/share/$MODULEDIR,
# which need to be built first # which need to be built first
...@@ -72,11 +73,16 @@ override CFLAGS += $(CFLAGS_SL) ...@@ -72,11 +73,16 @@ override CFLAGS += $(CFLAGS_SL)
endif endif
ifdef MODULEDIR ifdef MODULEDIR
datamoduledir = $(MODULEDIR) datamoduledir := $(MODULEDIR)
docmoduledir = $(MODULEDIR) docmoduledir := $(MODULEDIR)
else else
datamoduledir = contrib ifdef EXTENSION
docmoduledir = contrib datamoduledir := extension
docmoduledir := extension
else
datamoduledir := contrib
docmoduledir := contrib
endif
endif endif
ifdef PG_CPPFLAGS ifdef PG_CPPFLAGS
...@@ -96,8 +102,14 @@ endif # MODULE_big ...@@ -96,8 +102,14 @@ endif # MODULE_big
install: all installdirs install: all installdirs
ifneq (,$(DATA)$(DATA_built)$(EXTENSION)) ifneq (,$(EXTENSION))
@for file in $(addprefix $(srcdir)/, $(DATA)) $(DATA_built) $(addsuffix .control, $(EXTENSION)); do \ @for file in $(addprefix $(srcdir)/, $(addsuffix .control, $(EXTENSION))); do \
echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/extension'"; \
$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/extension'; \
done
endif # EXTENSION
ifneq (,$(DATA)$(DATA_built))
@for file in $(addprefix $(srcdir)/, $(DATA)) $(DATA_built); do \
echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'"; \ echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'"; \
$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'; \ $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'; \
done done
...@@ -168,8 +180,11 @@ endif # MODULE_big ...@@ -168,8 +180,11 @@ endif # MODULE_big
uninstall: uninstall:
ifneq (,$(DATA)$(DATA_built)$(EXTENSION)) ifneq (,$(EXTENSION))
rm -f $(addprefix '$(DESTDIR)$(datadir)/$(datamoduledir)'/, $(notdir $(DATA) $(DATA_built) $(addsuffix .control, $(EXTENSION)))) rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(addsuffix .control, $(EXTENSION))))
endif
ifneq (,$(DATA)$(DATA_built))
rm -f $(addprefix '$(DESTDIR)$(datadir)/$(datamoduledir)'/, $(notdir $(DATA) $(DATA_built)))
endif endif
ifneq (,$(DATA_TSEARCH)) ifneq (,$(DATA_TSEARCH))
rm -f $(addprefix '$(DESTDIR)$(datadir)/tsearch_data'/, $(notdir $(DATA_TSEARCH))) rm -f $(addprefix '$(DESTDIR)$(datadir)/tsearch_data'/, $(notdir $(DATA_TSEARCH)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment