Skip to content

Commit

Permalink
add DESTDIR parameter to configure (closes #28)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nunzio Tocci committed Feb 10, 2018
1 parent bbb88ed commit 499af93
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
43 changes: 22 additions & 21 deletions src/Makefile.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
TEST_CONFIGS = -c config/pgmanage.conf -d config/pgmanage-connections-test.conf -n true -t 300
TEST_WEBROOTS = -r ./web_root
DESTDIR = @destdir@
PREFIX = @prefix@
WEBROOT = @webroot@
INSTALL_DEPS = $(PREFIX)/sbin/ \
$(PREFIX)/etc/pgmanage/ \
$(PREFIX)/etc/pgmanage/pgmanage.conf \
$(PREFIX)/etc/pgmanage/pgmanage-connections.conf
INSTALL_DEPS = $(DESTDIR)/$(PREFIX)/sbin/ \
$(DESTDIR)/$(PREFIX)/etc/pgmanage/ \
$(DESTDIR)/$(PREFIX)/etc/pgmanage/pgmanage.conf \
$(DESTDIR)/$(PREFIX)/etc/pgmanage/pgmanage-connections.conf
SOCK_DIR_PARAMETER = @sock_dir_parameter@

VERSION = \"$(shell cat ../VERSION)\"
Expand Down Expand Up @@ -75,38 +76,38 @@ clean:
@echo "Clean Successful"

#### INSTALL
$(PREFIX)/sbin/:
mkdir -p $(PREFIX)/sbin/
$(DESTDIR)/$(PREFIX)/sbin/:
mkdir -p $(DESTDIR)/$(PREFIX)/sbin/

$(PREFIX)/etc/pgmanage/:
mkdir -p $(PREFIX)/etc/pgmanage/
$(DESTDIR)/$(PREFIX)/etc/pgmanage/:
mkdir -p $(DESTDIR)/$(PREFIX)/etc/pgmanage/

$(PREFIX)/etc/pgmanage/pgmanage.conf: $(PREFIX)/etc/pgmanage/ config/pgmanage.conf
test -f $(PREFIX)/etc/pgmanage/pgmanage.conf || install config/pgmanage.conf $(PREFIX)/etc/pgmanage/pgmanage.conf;
$(DESTDIR)/$(PREFIX)/etc/pgmanage/pgmanage.conf: $(DESTDIR)/$(PREFIX)/etc/pgmanage/ config/pgmanage.conf
test -f $(DESTDIR)/$(PREFIX)/etc/pgmanage/pgmanage.conf || install config/pgmanage.conf $(DESTDIR)/$(PREFIX)/etc/pgmanage/pgmanage.conf;

$(PREFIX)/etc/pgmanage/pgmanage-connections.conf: $(PREFIX)/etc/pgmanage/ config/pgmanage-connections.conf
test -f $(PREFIX)/etc/pgmanage/pgmanage-connections.conf || install config/pgmanage-connections.conf $(PREFIX)/etc/pgmanage/pgmanage-connections.conf;
$(DESTDIR)/$(PREFIX)/etc/pgmanage/pgmanage-connections.conf: $(DESTDIR)/$(PREFIX)/etc/pgmanage/ config/pgmanage-connections.conf
test -f $(DESTDIR)/$(PREFIX)/etc/pgmanage/pgmanage-connections.conf || install config/pgmanage-connections.conf $(DESTDIR)/$(PREFIX)/etc/pgmanage/pgmanage-connections.conf;

install: $(INSTALL_DEPS)
mkdir -p $(WEBROOT)/pgmanage $(PREFIX)/sbin $(PREFIX)/@MANDIR@/man1
mkdir -p $(WEBROOT)/pgmanage $(DESTDIR)/$(PREFIX)/sbin $(DESTDIR)/$(PREFIX)/@MANDIR@/man1
cp -rf ./web_root/pgmanage/* $(WEBROOT)/pgmanage/
install config/pgmanage.conf $(PREFIX)/etc/pgmanage/pgmanage.conf.example
install config/pgmanage-connections.conf $(PREFIX)/etc/pgmanage/pgmanage-connections.conf.example
install pgmanage $(PREFIX)/sbin/
install man/man1/pgmanage.1 $(PREFIX)/@MANDIR@/man1/pgmanage.1
install config/pgmanage.conf $(DESTDIR)/$(PREFIX)/etc/pgmanage/pgmanage.conf.example
install config/pgmanage-connections.conf $(DESTDIR)/$(PREFIX)/etc/pgmanage/pgmanage-connections.conf.example
install pgmanage $(DESTDIR)/$(PREFIX)/sbin/
install man/man1/pgmanage.1 $(DESTDIR)/$(PREFIX)/@MANDIR@/man1/pgmanage.1
@echo
@echo "Installation Successful"

uninstall:
rm $(PREFIX)/sbin/pgmanage
rm $(DESTDIR)/$(PREFIX)/sbin/pgmanage
rm -rf $(WEBROOT)/
rm -rf $(PREFIX)/etc/pgmanage/*.example
rm -rf $(DESTDIR)/$(PREFIX)/etc/pgmanage/*.example
@echo
@echo "Uninstall Successful"

destroy:
rm $(PREFIX)/sbin/pgmanage
rm -rf $(PREFIX)/etc/pgmanage
rm $(DESTDIR)/$(PREFIX)/sbin/pgmanage
rm -rf $(DESTDIR)/$(PREFIX)/etc/pgmanage
@echo
@echo "Destroy Successful"
@echo "NOTE: Even though all configuration files have been destroyed, your sql files have been preserved. They should be in you home folder under .pgmanage"
Expand Down
4 changes: 2 additions & 2 deletions src/config/pgmanage.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# man pgmanage

# Link to file with list of connections.
connection_file = @prefix@/etc/pgmanage/pgmanage-connections.conf
connection_file = @destdir@/@prefix@/etc/pgmanage/pgmanage-connections.conf

# When set to true, allow users to connect to a custom connection string from the login screen.
# allow_custom_connections = false
Expand All @@ -21,7 +21,7 @@ connection_file = @prefix@/etc/pgmanage/pgmanage-connections.conf
# login_timeout = 0

# Location of the web_root where the pgManage pages are.
web_root = @webroot@
web_root = @destdir@/@webroot@

# Where the the sql tabs are stored.
# sql_root = ~/.pgmanage/sql
Expand Down
15 changes: 12 additions & 3 deletions src/configure
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@

usage() {
echo "usage: ./configure [ options ]" 1>&2;
echo " -d <path>, --destdir <path> set destdir folder" 1>&2;
echo " -p <path>, --prefix <path> set install prefix (default /usr/local)" 1>&2;
echo " -w <path>, --webroot <path> set webroot folder (default /usr/local/etc/pgmanage/web_root)" 1>&2;
}

PREFIX="/usr/local"
DESTDIR=""
PREFIX="usr/local"
WEBROOT="@prefix@/etc/pgmanage/web_root"

while [[ $# -gt 0 ]]
do
key="$1"

case $key in
-d|--destdir)
DESTDIR="$2"
shift # past argument
shift # past value
;;
-p|--prefix)
PREFIX="$2"
shift # past argument
Expand Down Expand Up @@ -291,7 +298,8 @@ echo "$has_new_sock_directory_parameter_postgres"
sed -e "s|@sock_dir_parameter@|$directory_parameter|g" \
-e "s|@LDFLAGS@|$LDFLAGS|g" \
-e "s|@CPPFLAGS@|$CPPFLAGS|g" \
-e "s|@webroot@|$WEBROOT|g" \
-e "s|@destdir@|$DESTDIR|g" \
-e "s|@webroot@|$WEBROOT|g" \
-e "s|@prefix@|$PREFIX|g" \
-e "s|@MANDIR@|$MANDIR|g" \
-e "s|@libev_CPPFLAGS@|$libev_CPPFLAGS|g" \
Expand All @@ -304,7 +312,8 @@ sed -e "s|@webroot@|$WEBROOT|g" \
-e "s|@prefix@|$PREFIX|g" < man/man1/pgmanage.1.in > man/man1/pgmanage.1

#### CONFIGURE CONFIG FILE
sed -e "s|@webroot@|$WEBROOT|g" \
sed -e "s|@destdir@|$DESTDIR|g" \
-e "s|@webroot@|$WEBROOT|g" \
-e "s|@prefix@|$PREFIX|g" < config/pgmanage.conf.in >config/pgmanage.conf

echo
Expand Down

0 comments on commit 499af93

Please sign in to comment.