Skip to content

Commit

Permalink
Add a Makefile to the distribution so that 'sudo make install' and 's…
Browse files Browse the repository at this point in the history
…udo make uninstall' commands respectively installs and uninstalls E-Maj. The components are installed into the Postgres installation directories. More precisely: 1) the SQL scripts are copied into a <PG_SHAREDIR>/emaj subdirectory, the emaj.control file is created into the regular <PG_SHAREDIR>/extension directory, 2) the 4 clients components are installed in the <PG_BINDIR> directory and 3) the distributed documentation is copied into the <PG_DOCDIR>/emaj subdirectory. The distribution can also be installed/uninstalled using the pgxn client. Note that the standart PGXS mechanism has not been used because it fails to uninstall documentation and client files coming from subdirectories. However, the Makefile uses the same files locations as PGXS. The documentation is updated to reflect the new installation procedure. (Many thanks to David Wheeler for the reported issue and his valuable advice)
  • Loading branch information
beaud76 committed May 18, 2024
1 parent 94783fe commit b367d0a
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 42 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ E-Maj - Change log
<devel>
------
###Enhancements:###

* Add a Makefile to help installing and uninstalling the E-Maj software,
allowing also the pgxn client's usage.

###Bug fixes:###

Expand Down
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# File: Makefile
# E-Maj extension

# This Makefile doesn't use PGXS because PGXS fails to remove all doc and bin
# files at uninstall time when these files come from subdirectories.
# But it places the components at the same place, as if we had:
# EXTENSION = emaj
# MODULEDIR = emaj
# DATA = $(wildcard sql/*)
# DOCS = $(wildcard doc/*)
# SCRIPTS = $(wildcard client/*)
# PG_CONFIG ?= pg_config
# PGXS := $(shell $(PG_CONFIG) --pgxs)
# include $(PGXS)

PG_CONFIG ?= pg_config
PG_SHAREDIR := $(shell $(PG_CONFIG) --sharedir)
PG_BINDIR := $(shell $(PG_CONFIG) --bindir)
PG_DOCDIR := $(shell $(PG_CONFIG) --docdir)

all:

install:
mkdir -p $(PG_SHAREDIR)/extension
mkdir -p $(PG_SHAREDIR)/emaj
mkdir -p $(PG_DOCDIR)/emaj
cp sql/* $(PG_SHAREDIR)/emaj/.
sed -r "s|^#directory\s+=.*$$|directory = 'emaj'|" emaj.control >$(PG_SHAREDIR)/extension/emaj.control
-cp doc/* $(PG_DOCDIR)/emaj/.
cp client/* $(PG_BINDIR)/.

uninstall:
rm -f $(PG_BINDIR)/emaj*
rm -rf $(PG_DOCDIR)/emaj
rm -rf $(PG_SHAREDIR)/emaj
rm -f $(PG_SHAREDIR)/extension/emaj.control
56 changes: 40 additions & 16 deletions docs/en/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,51 @@ E-Maj and its add-ons are also available on the **github.org** Internet site:
Standart installation on Linux
******************************

Download the latest E-Maj version by any convenient way. If the *pgxn client* is installed, just execute the command::
With the pgxn client
^^^^^^^^^^^^^^^^^^^^

pgxn download E-Maj
If the *pgxn* client is installed, just execute the command::

It is also possible to use the *wget* command::
pgxn install E-Maj --sudo

wget https://api.pgxn.org/dist/e-maj/<version>/e-maj-<version>.zip
Without the pgxn client
^^^^^^^^^^^^^^^^^^^^^^^

Download the latest E-Maj version by any convenient way, for instance using the *wget* command::

wget https://api.pgxn.org/dist/e-maj/<version>/e-maj-<version>.zip

Then decompress the downloaded archive file and install the components with the commands::

unzip e-maj-<version>.zip

cd e-maj-<version>/

sudo make install

Components localization
^^^^^^^^^^^^^^^^^^^^^^^

In both cases, the components are installed into the usual PostgreSQL directories. In particular:

* SQL scripts are into *<SHAREDIR_directory>/emaj/*
* CLI clients are into *<BINDIR_directory>*, with PostgreSQL clients
* the documentation is into *<DOCDIR_directory>/emaj/*

The physical localization of *SHAREDIR*, *BINDIR* and *DOCDIR* directories can be found with the *pg_config* command.

Manual installation under Linux
*******************************

Download the latest E-Maj version by any convenient way, for instance using the *wget* command::

wget https://api.pgxn.org/dist/e-maj/<version>/e-maj-<version>.zip

Then decompress the downloaded archive file with the commands::

unzip e-maj-<version>.zip
unzip e-maj-<version>.zip

cd e-maj-<version>/
cd e-maj-<version>/

Identify the precise location of the *SHAREDIR* directory. Depending on the PostgreSQL installation, the *pg_config --sharedir* shell command may directly report this directory name. Otherwise, look at typical locations like:

Expand All @@ -54,13 +86,6 @@ On some environments (like DBaaS clouds for instance), it is not allowed to add

Download the latest E-Maj version by any convenient way and decompress it.

If the *pgxn* client is installed, just execute the commands::

pgxn download E-Maj

unzip e-maj-<version>.zip


The e-maj-<version> directory contains the file tree :doc:`described here <content>`.

The :doc:`extension creation<setup>` will be a little bit different.
Expand All @@ -75,8 +100,8 @@ To install E-Maj on Windows:
* Extract the file tree from the downloaded zip file,
* Copy the files *emaj.control* and *sql/emaj--** into the share\\extension folder of the PostgreSQL installation folder (typically c:\\Program_Files\\PostgreSQL\\<postgres_version>)

Alternate location of SQL installation scripts
**********************************************
Alternate SQL scripts location for manual installations
*******************************************************

The *emaj.control* file located in the *SHAREDIR/extension* directory of the PostgreSQL version, may contain a directive that defines the directory where SQL installation scripts are located.

Expand All @@ -86,4 +111,3 @@ To setup this, just:

* copy the *emaj.contol* file from the root directory of the decompressed structure into the *SHAREDIR/extension* directory,
* adjust the *directory* parameter of the *emaj.control* file to reflect the actual location of the E-Maj SQL scripts.

14 changes: 8 additions & 6 deletions docs/en/quickStart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ The E-Maj installation is described in detail later. But the few following comma
Software install
^^^^^^^^^^^^^^^^

To install E-Maj, log on your postgres (or another) account, download E-Maj from PGXN (https://pgxn.org/dist/e-maj/) and type::
If the *pgxn* client is installed, a single command is required::

unzip e-maj-<version>.zip
pgxn install E-Maj --sudo

cd e-maj-<version>/
Otherwise::

sudo cp emaj.control $(pg_config --sharedir)/extension/.
wget https://api.pgxn.org/dist/e-maj/<version>/e-maj-<version>.zip

sudo cp sql/emaj--* $(pg_config --sharedir)/extension/.
unzip e-maj-<version>.zip

cd e-maj-<version>/

For PostgreSQL versions prior 9.6, see this :ref:`chapter <create_emaj_extension>`.
sudo make install

For more details, or in case of problem, look at :doc:`there <install>`.

Expand Down
19 changes: 18 additions & 1 deletion docs/en/uninstall.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Uninstall
=========

Uninstalling an E-Maj extension from a database
===============================================
***********************************************

To uninstall E-Maj from a database, the user must log on this database with *psql*, as a superuser.

Expand Down Expand Up @@ -34,3 +37,17 @@ The uninstallation script execution displays::
SET
>>> E-maj successfully uninstalled from this database

Removing the E-Maj software
***************************

The way to remove the E-Maj software depends on the way it has been installed.

For a standart install with the *pgxn* client, a single command is required::

pgxn uninstall E-Maj --sudo

For a standart install without the *pgxn* client, reach the initial directory of the E-Maj distribution and type::

sudo make uninstall

For a manual install, the installed components must be removed by reverting the initial installation steps.
49 changes: 37 additions & 12 deletions docs/fr/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,44 @@ E-Maj et ses compléments sont également disponibles sur le site Internet **git
Installation standard sur Linux
*******************************

Téléchargez la dernière version d’E-Maj par un moyen à votre convenance. Si le *client pgxn* est installé, on peut simplement exécuter la commande ::
Avec le client pgxn
^^^^^^^^^^^^^^^^^^^

pgxn download E-Maj
Si le client *pgxn* est installé, une simple commande suffit ::

On peut aussi utiliser la commande *wget* ::
pgxn install E-Maj --sudo

Sans le client pgxn
^^^^^^^^^^^^^^^^^^^

Téléchargez la dernière version d’E-Maj depuis le site pgxn.org, par un moyen à votre convenance, par exemple avec la commande *wget* ::
wget https://api.pgxn.org/dist/e-maj/<version>/e-maj-<version>.zip

Puis décompressez l’archive et installer les composants avec les commandes ::

unzip e-maj-<version>.zip

cd e-maj-<version>/

sudo make install

Localisation des composants
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Dans les 2 cas de figure, les composants sont installés dans les répertoires usuels des composants PostgreSQL. En particulier :

* les scripts SQL sont dans *<répertoire_SHAREDIR>/emaj/*
* les clients en mode ligne de commande sont dans *<répertoire_BINDIR>*, avec les clients PostgreSQL
* la documentation est dans *<répertoire_DOCDIR>/emaj/*

La localisation physique des répertoires *SHAREDIR*, *BINDIR* et *DOCDIR* sur le système peut être retrouvée à l’aide de la commande *pg_config*.

Installation manuelle sur Linux
-------------------------------

Téléchargez la dernière version d’E-Maj depuis le site pgxn.org, par un moyen à votre convenance, par exemple avec la commande *wget* ::

wget https://api.pgxn.org/dist/e-maj/<version>/e-maj-<version>.zip

Puis décompressez l’archive avec les commandes suivantes ::
Expand Down Expand Up @@ -54,12 +86,6 @@ Sur certains environnements (cloud de type DBaaS par exemple), il n’est pas po

Téléchargez la dernière version d’E-Maj par un moyen à votre convenance, et décompressez la.

Par exemple, si le client pgxn est installé, exécutez les commandes ::

pgxn download E-Maj

unzip e-maj-<version>.zip

Le répertoire e-maj-<version> généré contient l’arborescence :doc:`décrite ici <content>`.

La :doc:`création de l’extension <setup>` est alors un peu différente.
Expand All @@ -73,13 +99,12 @@ Pour installer E-Maj sous Windows, il faut :
* Extraire l’arborescence du fichier zip reçu,
* En copier les fichiers *emaj.control* et *sql/emaj--** dans le dossier *share\\extension* du dossier d’installation de la version de PostgreSQL (typiquement *c:\\Program_Files\\PostgreSQL\\<version_postgres>*).

Localisation alternative des scripts SQL d’installation
*******************************************************
Localisation alternative des scripts SQL pour les installations manuelles
*************************************************************************

Le fichier *emaj.control*, positionné dans le répertoire *SHAREDIR/extension* de la version de PostgreSQL, peut contenir une directive indiquant à PostgreSQL le répertoire dans lequel sont localisés les scripts SQL d’installation ou d’upgrade.

Il est donc possible de ne mettre dans ce répertoire *SHAREDIR/extension* que le seul fichier *emaj.control* en créant ce pointeur vers le répertoire de scripts. Pour ce faire, il faut :

* Copier le fichier *emaj.control* fourni dans le répertoire racine de la version décompressée vers le répertoire *SHAREDIR/extension*,
* Adapter la directive *directory* du fichier *emaj.control* pour spécifier le répertoire sql contenant les scripts d’installation d’E-Maj.

12 changes: 8 additions & 4 deletions docs/fr/quickStart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ L’installation d’E-Maj est présentée plus loin en détail. Mais les quelqu
Installation du logiciel
^^^^^^^^^^^^^^^^^^^^^^^^

Pour installer le logiciel E-Maj, connectez-vous à votre compte postgres (ou un autre), téléchargez E-Maj depuis PGXN (https://pgxn.org/dist/e-maj/) et tapez ::
Si le client *pgxn* est installé, une simple commande suffit ::

pgxn install E-Maj --sudo

Sinon ::

wget https://api.pgxn.org/dist/e-maj/<version>/e-maj-<version>.zip

unzip e-maj-<version>.zip

cd e-maj-<version>/

sudo cp emaj.control $(pg_config --sharedir)/extension/.

sudo cp sql/emaj--* $(pg_config --sharedir)/extension/.
sudo make install

Pour plus de détails, ou en cas de problème, allez :doc:`ici <install>`.

Expand Down
20 changes: 18 additions & 2 deletions docs/fr/uninstall.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Désinstallation
===============

Désinstallation d'E-Maj d'une base de données
=============================================
*********************************************

Pour désinstaller E-Maj d'une base de données, l'utilisateur doit se connecter à cette base avec *psql*, en tant que super-utilisateur.

Expand All @@ -16,7 +19,6 @@ Pour désinstaller E-Maj, il faut simplement exécuter le **script fourni** *ema

\i <répertoire_emaj>/sql/emaj_uninstall.sql


Ce script effectue les actions suivantes :

* iI exécute les éventuelles fonctions de nettoyage créées par l'exécution des scripts de démonstration ou de test fournis,
Expand All @@ -35,3 +37,17 @@ L'exécution du script de désinstallation affiche ceci ::
SET
>>> E-maj successfully uninstalled from this database

Suppression du logiciel E-Maj
*****************************

Le mode de suppression du logiciel E-Maj dépend de son mode d’installation.

Pour une installation standard avec le client *pgxn*, une seule commande est requise ::

pgxn uninstall E-Maj --sudo

Pour une installation standard sans le client *pgxn*, se placer dans le répertoire initial de la distribution E-Maj et taper ::

sudo make uninstall

Pour une installation manuelle, il convient de supprimer les composants installés en annulant les opérations exécutées lors de l’installation.
1 change: 1 addition & 0 deletions tar.index
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ emaj/AUTHORS.md
emaj/LICENSE
emaj/META.json
emaj/emaj.control
emaj/Makefile
emaj/sql/emaj--devel.sql
emaj/sql/emaj-devel.sql
emaj/sql/emaj--4.4.0--devel.sql
Expand Down

0 comments on commit b367d0a

Please sign in to comment.