Commit ff4d0d43 authored by Marc G. Fournier's avatar Marc G. Fournier

Here's a patch that I discussed recently on pg95-dev that changes the

way one creates a database system.  Parts that were in "make install"
are not either in "make all" or initdb.  Nothing goes in the PGDATA
directory besides user data.  Creating multiple database systems is
easier.

In addition to applying the patch, it is necessary to move the file
libpq/pg_hba to backend/libpq/pg_hba.sample.

Submitted by: Bryan Henderson <bryanh@giraffe.netgate.net>
parent e7c3adcd
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.6 1996/09/21 06:27:11 scrappy Exp $ # $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.7 1996/09/23 08:21:52 scrappy Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -17,13 +17,11 @@ ...@@ -17,13 +17,11 @@
# in your custom makefile, ../Makefile.custom.) # in your custom makefile, ../Makefile.custom.)
BIGOBJS= true BIGOBJS= true
PROG= postgres global1.bki.source local1_template1.bki.source
PROG= postgres
MKDIR= ../mk MKDIR= ../mk
include $(MKDIR)/postgres.mk include $(MKDIR)/postgres.mk
include $(CURDIR)/access/Makefile.inc include $(CURDIR)/access/Makefile.inc
include $(CURDIR)/bootstrap/Makefile.inc include $(CURDIR)/bootstrap/Makefile.inc
include $(CURDIR)/catalog/Makefile.inc include $(CURDIR)/catalog/Makefile.inc
...@@ -60,6 +58,7 @@ OBJS:= $(subst .s,.o,$(SRCS:%.c=$(objdir)/%.o)) ...@@ -60,6 +58,7 @@ OBJS:= $(subst .s,.o,$(SRCS:%.c=$(objdir)/%.o))
CLEANFILES+= $(notdir $(OBJS)) CLEANFILES+= $(notdir $(OBJS))
endif endif
############################################################################# #############################################################################
# #
# TIOGA stuff # TIOGA stuff
...@@ -86,7 +85,7 @@ CFLAGS+= -DPOSTGRESDIR='"$(POSTGRESDIR)"' \ ...@@ -86,7 +85,7 @@ CFLAGS+= -DPOSTGRESDIR='"$(POSTGRESDIR)"' \
-I$(CURDIR)/$(objdir) \ -I$(CURDIR)/$(objdir) \
-I$(CURDIR)/include \ -I$(CURDIR)/include \
-I$(CURDIR)/port/$(PORTNAME) \ -I$(CURDIR)/port/$(PORTNAME) \
-I$(SRCDIR)/include -I../include
# turn this on if you prefer European style dates instead of American # turn this on if you prefer European style dates instead of American
# style dates # style dates
...@@ -192,52 +191,33 @@ endif ...@@ -192,52 +191,33 @@ endif
# #
# Installation. # Installation.
# #
# Install the bki files to the data directory. We also copy a version # Install the backend program (postgres) to the binary directory and
# of them that has "PGUID" intact, so one can change the value of the # make a link as "postmaster". Install the bki files templates and sample
# postgres userid before running initdb in the case of customizing the # files to the library directory.
# binary release (i.e., fixing up PGUID w/o recompiling the system).
# Those files are copied out as foo.source. The program newbki(1) can
# be run later to reset the postgres login id (but it must be run before
# initdb is run, or after clearing the data directory with
# cleardbdir(1)). [newbki distributed with v4r2 but not with Postgres95.]
# #
# (History: Before Release 2, make install generated a bki.source file
# NAMEDATALEN=`egrep "^#define NAMEDATALEN" $(CURDIR)/include/postgres.h | awk '{print $$3}'`; \ # and then used build parameters to convert it to a bki file, then installed
# OIDNAMELEN=`egrep "^#define OIDNAMELEN" $(CURDIR)/include/postgres.h | awk '{print $$3}'`; \ # that bki file in the /files subdirectory of the default data directory.
# Initdb then used the bki file to generate the database catalog classes.
install: beforeinstall pg_id $(BKIFILES) postgres # That had to change because (1) there can be more than one database system,
$(INSTALL) $(INSTL_EXE_OPTS) $(objdir)/postgres $(DESTDIR)$(BINDIR)/postgres # and (2) the parameters of a database system should be set at initdb time,
# not at postgres build time.
install: beforeinstall postgres fmgr.h\
global1.bki.source local1_template1.bki.source \
libpq/pg_hba.sample
$(INSTALL) $(INSTL_EXE_OPTS) $(objdir)/postgres \
$(DESTDIR)$(BINDIR)/postgres
@rm -f $(DESTDIR)$(BINDIR)/postmaster @rm -f $(DESTDIR)$(BINDIR)/postmaster
cd $(DESTDIR)$(BINDIR); ln -s postgres postmaster cd $(DESTDIR)$(BINDIR); ln -s postgres postmaster
@cd $(objdir); \ $(INSTALL) $(INSTLOPTS) $(objdir)/fmgr.h $(HEADERDIR)/fmgr.h
PG_UID=`./pg_id $(POSTGRESLOGIN)`; \ $(INSTALL) $(INSTLOPTS) $(objdir)/global1.bki.source \
POSTGRESLOGIN=$(POSTGRESLOGIN);\ $(DESTDIR)$(LIBDIR)/global1.bki.source
echo "NAMEDATALEN = $(NAMEDATALEN)"; \ $(INSTALL) $(INSTLOPTS) $(objdir)/local1_template1.bki.source \
echo "OIDNAMELEN = $(OIDNAMELEN)"; \ $(DESTDIR)$(LIBDIR)/local1_template1.bki.source
case $$PG_UID in "NOUSER") \ $(INSTALL) $(INSTLOPTS) libpq/pg_hba.sample \
echo "Warning: no account named $(POSTGRESLOGIN), using yours";\ $(DESTDIR)$(LIBDIR)/pg_hba.sample
POSTGRESLOGIN=`whoami`; \
PG_UID=`./pg_id`;; \
esac ;\
for bki in $(BKIFILES); do \
sed \
-e "s/postgres PGUID/$$POSTGRESLOGIN $$PG_UID/" \
-e "s/NAMEDATALEN/$(NAMEDATALEN)/g" \
-e "s/OIDNAMELEN/$(OIDNAMELEN)/g" \
-e "s/PGUID/$$PG_UID/" \
< $$bki > $$bki.sed ; \
echo "Installing $(DESTDIR)$(DATADIR)/files/$$bki."; \
$(INSTALL) $(INSTLOPTS) \
$$bki.sed $(DESTDIR)$(DATADIR)/files/$$bki; \
rm -f $$bki.sed; \
echo "Installing $(DESTDIR)$(DATADIR)/files/$$bki.source."; \
$(INSTALL) $(INSTLOPTS) \
$$bki $(DESTDIR)$(DATADIR)/files/$$bki.source; \
done;
@echo "Installing $(DATADIR)/pg_hba";
@cp $(srcdir)/libpq/pg_hba $(DATADIR)
@chmod 644 $(DATADIR)/pg_hba
# so we can get the UID of the postgres owner (w/o moving pg_id to # so we can get the UID of the postgres owner (w/o moving pg_id to
# src/tools). We just want the vanilla LDFLAGS for pg_id # src/tools). We just want the vanilla LDFLAGS for pg_id
...@@ -247,10 +227,8 @@ ifeq ($(CC), cc) ...@@ -247,10 +227,8 @@ ifeq ($(CC), cc)
IDLDFLAGS+= -Aa -D_HPUX_SOURCE IDLDFLAGS+= -Aa -D_HPUX_SOURCE
endif endif
endif endif
pg_id: $(srcdir)/bin/pg_id/pg_id.c
$(CC) $(IDLDFLAGS) -o $(objdir)/$(@F) $<
CLEANFILES+= pg_id postgres CLEANFILES+= postgres
############################################################################# #############################################################################
......
...@@ -7,13 +7,14 @@ ...@@ -7,13 +7,14 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/catalog/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:14 scrappy Exp $ # $Header: /cvsroot/pgsql/src/backend/catalog/Attic/Makefile.inc,v 1.2 1996/09/23 08:22:04 scrappy Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
catdir=$(CURDIR)/catalog catdir=$(CURDIR)/catalog
VPATH:=$(VPATH):$(catdir) VPATH:=$(VPATH):$(catdir)
cat_hdr_dir= ../include/catalog
SRCS_CATALOG= catalog.c heap.c index.c indexing.c \ SRCS_CATALOG= catalog.c heap.c index.c indexing.c \
pg_aggregate.c pg_operator.c pg_proc.c pg_type.c pg_aggregate.c pg_operator.c pg_proc.c pg_type.c
...@@ -28,7 +29,7 @@ HEADERS+= catalog.h catname.h heap.h index.h indexing.h pg_aggregate.h \ ...@@ -28,7 +29,7 @@ HEADERS+= catalog.h catname.h heap.h index.h indexing.h pg_aggregate.h \
pg_user.h pg_variable.h pg_version.h pg_user.h pg_variable.h pg_version.h
# #
# The following is to create the .bki files. # The following is to create the .bki.source files.
# TODO: sort headers, (figure some automatic way of of determining # TODO: sort headers, (figure some automatic way of of determining
# the bki sources?) # the bki sources?)
# #
...@@ -41,29 +42,27 @@ BKIOPTS= -DALLOW_PG_GROUP ...@@ -41,29 +42,27 @@ BKIOPTS= -DALLOW_PG_GROUP
endif endif
GENBKI= $(catdir)/genbki.sh GENBKI= $(catdir)/genbki.sh
BKIFILES= global1.bki local1_template1.bki
GLOBALBKI_SRCS= pg_database.h pg_demon.h pg_magic.h pg_defaults.h \ GLOBALBKI_SRCS= $(addprefix $(cat_hdr_dir)/, \
pg_database.h pg_demon.h pg_magic.h pg_defaults.h \
pg_variable.h pg_server.h pg_user.h pg_hosts.h \ pg_variable.h pg_server.h pg_user.h pg_hosts.h \
pg_group.h pg_log.h pg_time.h pg_group.h pg_log.h pg_time.h \
)
LOCALBKI_SRCS= pg_proc.h pg_type.h pg_attribute.h pg_class.h \ LOCALBKI_SRCS= $(addprefix $(cat_hdr_dir)/, \
pg_inherits.h pg_index.h pg_version.h pg_statistic.h pg_operator.h \ pg_proc.h pg_type.h pg_attribute.h pg_class.h \
pg_opclass.h pg_am.h pg_amop.h pg_amproc.h pg_language.h pg_parg.h \ pg_inherits.h pg_index.h pg_version.h pg_statistic.h \
pg_operator.h pg_opclass.h pg_am.h pg_amop.h pg_amproc.h \
pg_language.h pg_parg.h \
pg_aggregate.h pg_ipl.h pg_inheritproc.h \ pg_aggregate.h pg_ipl.h pg_inheritproc.h \
pg_rewrite.h pg_listener.h indexing.h pg_rewrite.h pg_listener.h indexing.h \
)
global1.bki: $(GENBKI) $(GLOBALBKI_SRCS) global1.bki.source: $(GENBKI) $(GLOBALBKI_SRCS)
sh $(SHOPTS) $(GENBKI) $(BKIOPTS) \ sh $(SHOPTS) $(GENBKI) $(BKIOPTS) $(GLOBALBKI_SRCS) > $(objdir)/$(@F)
$(patsubst $(GENBKI),,$^) > $(objdir)/$(@F)
local1_template1.bki.source: $(GENBKI) $(LOCALBKI_SRCS)
sh $(SHOPTS) $(GENBKI) $(BKIOPTS) $(LOCALBKI_SRCS) > $(objdir)/$(@F)
local1_template1.bki: $(GENBKI) $(LOCALBKI_SRCS) CLEANFILES+= global.bki.source local1_template1.bki.source
sh $(SHOPTS) $(GENBKI) $(BKIOPTS) \
$(patsubst $(GENBKI),,$^) > $(objdir)/$(@F)
#${PROG}: ${BKIFILES}
#
CLEANFILES+= ${BKIFILES}
...@@ -4,34 +4,24 @@ ...@@ -4,34 +4,24 @@
# cleardbdir.sh-- # cleardbdir.sh--
# completely clear out the database directory # completely clear out the database directory
# #
# this program clears out the database directory, but leaves the .bki # A program by this name used to be necessary because the database
# files so that initdb(1) can be run again. # files were mixed in with postgres program files. Now, the database
# files are in their own directory so you can just rm it.
# #
# We have to ship this program, which now just tells the user there's
# no such program, to make sure that the old program from
# a prior release gets deleted. If it hung around, it could confuse
# the user.
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/cleardbdir/Attic/cleardbdir.sh,v 1.1.1.1 1996/07/09 06:22:11 scrappy Exp $ # $Header: /cvsroot/pgsql/src/bin/cleardbdir/Attic/cleardbdir.sh,v 1.2 1996/09/23 08:23:03 scrappy Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
[ -z "$PGDATA" ] && PGDATA=_fUnKy_DATADIR_sTuFf_ echo "The cleardbir program no longer exists. To remove an old database"
echo "system, simply wipe out the whole directory that contains it."
echo "This program completely destroys all the databases in the directory" echo
echo "$PGDATA" echo "You can create a new database system with initdb."
echo _fUnKy_DASH_N_sTuFf_ "Are you sure you want to do this (y/n) [n]? "_fUnKy_BACKSLASH_C_sTuFf_
read resp || exit
case $resp in
y*) : ;;
*) exit ;;
esac
cd $PGDATA || exit
for i in *
do
if [ $i != "files" -a $i != "pg_hba" ]
then
/bin/rm -rf $i
fi
done
...@@ -2,221 +2,266 @@ ...@@ -2,221 +2,266 @@
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# initdb.sh-- # initdb.sh--
# create a postgres template database # Create (initialize) a Postgres database system.
# #
# this program feeds the proper input to the ``postgres'' program # A database system is a collection of Postgres databases all managed
# to create a postgres database and register it in the # by the same postmaster.
# shared ``pg_database'' database. #
# To create the database system, we create the directory that contains
# all its data, create the files that hold the global classes, create
# a few other control files for it, and create one database: the
# template database.
#
# The template database is an ordinary Postgres database. Its data
# never changes, though. It exists to make it easy for Postgres to
# create other databases -- it just copies.
#
# Optionally, we can skip creating the database system and just create
# (or replace) the template database.
#
# To create all those classes, we run the postgres (backend) program and
# feed it data from bki files that are in the Postgres library directory.
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.5 1996/09/21 06:24:41 scrappy Exp $ # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.6 1996/09/23 08:23:17 scrappy Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# ---------------- # ----------------
# Set paths from environment or default values. # Set paths from environment or default values.
# The _fUnKy_..._sTuFf_ gets set when the script is installed # The _fUnKy_..._sTuFf_ gets set when the script is built (with make)
# from the default value for this build. # from parameters set in the make file.
# Currently the only thing wee look for from the environment is # Currently the only thing we look for from the environment is
# PGDATA, PGHOST, and PGPORT # PGDATA, PGHOST, and PGPORT. However, we should have environment
# variables for all the paths.
# #
# ---------------- # ----------------
[ -z "$PGDATA" ] && { PGDATA=_fUnKy_DATADIR_sTuFf_; export PGDATA; } [ -z "$PGDATA" ] && { PGDATA=_fUnKy_DATADIR_sTuFf_; export PGDATA; }
[ -z "$PGPORT" ] && { PGPORT=_fUnKy_POSTPORT_sTuFf_; export PGPORT; } [ -z "$PGPORT" ] && { PGPORT=_fUnKy_POSTPORT_sTuFf_; export PGPORT; }
[ -z "$PGHOST" ] && { PGHOST=localhost; export PGHOST; } [ -z "$PGHOST" ] && { PGHOST=localhost; export PGHOST; }
POSTGRESDIR=_fUnKy_POSTGRESDIR_sTuFf_
BINDIR=_fUnKy_BINDIR_sTuFf_ BINDIR=_fUnKy_BINDIR_sTuFf_
FILESDIR=$PGDATA/files LIBDIR=_fUnKy_LIBDIR_sTuFf_
NAMEDATALEN=_fUnKy_NAMEDATALEN_sTuFf_
OIDNAMELEN=_fUnKy_OIDNAMELEN_sTuFf_
PATH=$BINDIR:$PATH PATH=$BINDIR:$PATH
export PATH export PATH
CMDNAME=`basename $0` CMDNAME=`basename $0`
# ---------------- # Set defaults:
# check arguments:
# -d indicates debug mode.
# -n means don't clean up on error (so your cores don't go away)
# ----------------
debug=0 debug=0
noclean=0 noclean=0
verbose=0 template_only=0
POSTGRES_SUPERUSERNAME=$USER
for ARG
do for ARG ; do
case "$ARG" in if [ $ARG = "--debug" -o $ARG = "-d" ]; then
-d) debug=1; echo "$CMDNAME: debug mode on";; debug=1
-n) noclean=1; echo "$CMDNAME: noclean mode on";; echo "Running with debug mode on."
-v) verbose=1; echo "$CMDNAME: verbose mode on";; elif [ $ARG = "--noclean" -o $ARG = "-n" ]; then
*) echo "initdb [-d][-n][-v]\n -d : debug mode\n -n : noclean mode, leaves temp files around \n -v : verbose mode"; exit 0; noclean=1
esac echo "Running with noclean mode on. Mistakes will not be cleaned up."
elif [ $ARG = "--template" ]; then
template_only=1
echo "updating template1 database only."
elif [ ${ARG#--username=} != $ARG ]; then
POSTGRES_SUPERUSERNAME=${ARG,"--username="}
elif [ ${ARG#--pgdata=} != $ARG ]; then
PGDATA=${ARG#--pgdata=}
else
echo "initdb [--template] [--debug] [--noclean]" \
"[--username=SUPERUSER] [--pgdata=DATADIR]"
fi
done done
# ---------------- if [ "$debug" -eq 1 ]; then
# if the debug flag is set, then
# ----------------
if test "$debug" -eq 1
then
BACKENDARGS="-boot -C -F -d" BACKENDARGS="-boot -C -F -d"
else else
BACKENDARGS="-boot -C -F -Q" BACKENDARGS="-boot -C -F -Q"
fi fi
TEMPLATE=$LIBDIR/local1_template1.bki.source
GLOBAL=$LIBDIR/global1.bki.source
PG_HBA_SAMPLE=$LIBDIR/pg_hba.sample
TEMPLATE=$FILESDIR/local1_template1.bki #-------------------------------------------------------------------------
GLOBAL=$FILESDIR/global1.bki # Find the input files
if [ ! -f $TEMPLATE -o ! -f $GLOBAL ] #-------------------------------------------------------------------------
then
echo "$CMDNAME: error: database initialization files not found." for PREREQ_FILE in $TEMPLATE $GLOBAL $PG_HBA_SAMPLE; do
echo "$CMDNAME: either gmake install has not been run or you're trying to" if [ ! -f $PREREQ_FILE ]; then
echo "$CMDNAME: run this program on a machine that does not store the" echo "$CMDNAME does not find the file '$PREREQ_FILE'."
echo "$CMDNAME: database (PGHOST doesn't work for this)." echo "This means Postgres95 is incorrectly installed."
exit 1 exit 1
fi fi
done
if test "$verbose" -eq 1 echo "$CMDNAME: using $TEMPLATE as input to create the template database."
then if [ $template_only -eq 0 ]; then
echo "$CMDNAME: using $TEMPLATE" echo "$CMDNAME: using $GLOBAL as input to create the global classes."
echo "$CMDNAME: using $GLOBAL" echo "$CMDNAME: using $PG_HBA_SAMPLE as the host-based authentication" \
"control file."
fi fi
# #---------------------------------------------------------------------------
# Figure out who I am... # Figure out who the Postgres superuser for the new database system will be.
# #---------------------------------------------------------------------------
PG_UID=`pg_id`
if test $PG_UID -eq 0 if [ -z $POSTGRES_SUPERUSERNAME ]; then
then echo "Can't tell what username to use. You don't have the USER"
echo "$CMDNAME: do not install POSTGRES as root" echo "environment variable set to your username and didn't specify the "
echo "--username option"
exit 1 exit 1
fi fi
# ---------------- POSTGRES_SUPERUID=`pg_id $POSTGRES_SUPERUSERNAME`
# create the template database if necessary
# the first we do is create data/base, so we'll check for that.
# ----------------
if test -d "$PGDATA/base" if [ $POSTGRES_SUPERUID = NOUSER ]; then
then echo "Valid username not given. You must specify the username for "
echo "$CMDNAME: error: it looks like initdb has already been run. You must" echo "the Postgres superuser for the database system you are "
echo "clean out the database directory first with the cleardbdir program" echo "initializing, either with the --username option or by default "
exit 1 echo "to the USER environment variable."
exit 10
fi fi
if [ $POSTGRES_SUPERUID -ne `pg_id` -a `pg_id` -ne 0 ]; then
echo "Only the unix superuser may initialize a database with a different"
echo "Postgres superuser. (You must be able to create files that belong"
echo "to the specified Postgres userid)."
exit 2
fi
echo "We are initializing the database system with username" \
"$POSTGRES_SUPERUSERNAME (uid=$POSTGRES_SUPERUID)."
echo "Please be aware that Postgres is not secure. Anyone who can connect"
echo "to the database can act as user $POSTGRES_SUPERUSERNAME " \
"with very little effort."
# -----------------------------------------------------------------------
# Create the data directory if necessary
# -----------------------------------------------------------------------
# umask must disallow access to group, other for files and dirs # umask must disallow access to group, other for files and dirs
umask 077 umask 077
mkdir $PGDATA/base $PGDATA/base/template1 if [ -d "$PGDATA" ]; then
if [ $template_only -eq 0 ]; then
if test "$verbose" -eq 1 echo "$CMDNAME: error: Directory $PGDATA already exists."
then echo "This probably means initdb has already been run and the "
echo "$CMDNAME: creating SHARED relations in $PGDATA" echo "database system already exists."
echo "$CMDNAME: creating template database in $PGDATA/base/template1" echo
echo "postgres $BACKENDARGS template1 < $TEMPLATE " echo "If you want to create a new database system, either remove "
echo "the $PGDATA directory or run initdb with environment variable"
echo "PGDATA set to something other than $PGDATA."
exit 1
fi
else
if [ ! -d $PGDATA ]; then
echo "Creating Postgres database system directory $PGDATA"
mkdir $PGDATA
if [ $? -ne 0 ]; then exit 5; fi
fi
if [ ! -d $PGDATA/base ]; then
echo "Creating Postgres database system directory $PGDATA/base"
mkdir $PGDATA/base
if [ $? -ne 0 ]; then exit 5; fi
fi
fi fi
postgres $BACKENDARGS template1 < $TEMPLATE #----------------------------------------------------------------------------
# Create the template1 database
#----------------------------------------------------------------------------
rm -rf $PGDATA/base/template1
mkdir $PGDATA/base/template1
echo "$CMDNAME: creating template database in $PGDATA/base/template1"
echo "Running: postgres $BACKENDARGS template1"
if test $? -ne 0 cat $TEMPLATE \
then | sed -e "s/postgres PGUID/$POSTGRES_SUPERUSERNAME $POSTGRES_SUPERUID/" \
-e "s/NAMEDATALEN/$NAMEDATALEN/g" \
-e "s/OIDNAMELEN/$OIDNAMELEN/g" \
-e "s/PGUID/$POSTGRES_SUPERUID/" \
| postgres $BACKENDARGS template1
if [ $? -ne 0 ]; then
echo "$CMDNAME: could not create template database" echo "$CMDNAME: could not create template database"
if test $noclean -eq 0 if [ $noclean -eq 0 ]; then
then echo "$CMDNAME: cleaning up by wiping out $PGDATA/base/template1"
echo "$CMDNAME: cleaning up." rm -rf $PGDATA/base/template1
cd $PGDATA
for i in *
do
if [ $i != "files" -a $i != "pg_hba" ]
then
/bin/rm -rf $i
fi
done
else else
echo "$CMDNAME: cleanup not done (noclean mode set)." echo "$CMDNAME: cleanup not done because noclean options was used."
fi fi
exit 1; exit 1;
fi fi
pg_version $PGDATA/base/template1 pg_version $PGDATA/base/template1
# #----------------------------------------------------------------------------
# Add the template database to pg_database # Create the global classes, if requested.
# #----------------------------------------------------------------------------
echo "open pg_database" > /tmp/create.$$ if [ $template_only -eq 0 ]; then
echo "insert (template1 $PG_UID template1)" >> /tmp/create.$$ echo "$CMDNAME: creating global classes in $PGDATA"
#echo "show" >> /tmp/create.$$
echo "close pg_database" >> /tmp/create.$$
if test "$verbose" -eq 1 echo "Creating global classes in $PG_DATA/base"
then echo "Running: postgres $BACKENDARGS template1"
echo "postgres $BACKENDARGS template1 < $GLOBAL"
fi
postgres $BACKENDARGS template1 < $GLOBAL cat $GLOBAL \
| sed -e "s/postgres PGUID/$POSTGRES_SUPERUSERNAME $POSTGRES_SUPERUID/" \
-e "s/NAMEDATALEN/$NAMEDATALEN/g" \
-e "s/OIDNAMELEN/$OIDNAMELEN/g" \
-e "s/PGUID/$POSTGRES_SUPERUID/" \
| postgres $BACKENDARGS template1
if (test $? -ne 0) if (test $? -ne 0)
then
echo "$CMDNAME: could create shared relations"
if (test $noclean -eq 0)
then then
echo "$CMDNAME: could not create global classes."
if (test $noclean -eq 0); then
echo "$CMDNAME: cleaning up." echo "$CMDNAME: cleaning up."
cd $PGDATA rm -rf $PGDATA
for i in *
do
if [ $i != "files" ]
then
/bin/rm -rf $i
fi
done
else else
echo "$CMDNAME: cleanup not done (noclean mode set)." echo "$CMDNAME: cleanup not done (noclean mode set)."
fi fi
exit 1; exit 1;
fi fi
pg_version $PGDATA pg_version $PGDATA
if test "$verbose" -eq 1 cp $PG_HBA_SAMPLE $PGDATA/pg_hba
then
echo "postgres $BACKENDARGS template1 < /tmp/create.$$" echo "Adding template1 database to pg_database..."
fi
echo "open pg_database" > /tmp/create.$$
echo "insert (template1 $POSTGRES_SUPERUID template1)" >> /tmp/create.$$
#echo "show" >> /tmp/create.$$
echo "close pg_database" >> /tmp/create.$$
echo "Running: postgres $BACKENDARGS template1 < /tmp/create.$$"
postgres $BACKENDARGS template1 < /tmp/create.$$ postgres $BACKENDARGS template1 < /tmp/create.$$
if test $? -ne 0 if [ $? -ne 0 ]; then
then
echo "$CMDNAME: could not log template database" echo "$CMDNAME: could not log template database"
if (test $noclean -eq 0) if [ $noclean -eq 0 ]; then
then
echo "$CMDNAME: cleaning up." echo "$CMDNAME: cleaning up."
cd $PGDATA rm -rf $PGDATA
for i in *
do
if [ $i != "files" ]
then
/bin/rm -rf $i
fi
done
else else
echo "$CMDNAME: cleanup not done (noclean mode set)." echo "$CMDNAME: cleanup not done (noclean mode set)."
fi fi
exit 1; exit 1;
fi
rm -f /tmp/create.$$
fi fi
if test $debug -eq 0 if [ $debug -eq 0 ]; then
then
if test "$verbose" -eq 1
then
echo "vacuuming template1" echo "vacuuming template1"
fi
echo "vacuum" | postgres -F -Q template1 > /dev/null echo "vacuum" | postgres -F -Q template1 > /dev/null
fi fi
rm -f /tmp/create.$$
...@@ -7,94 +7,98 @@ ...@@ -7,94 +7,98 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.4 1996/08/28 23:02:43 scrappy Exp $ # $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.5 1996/09/23 08:23:33 scrappy Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
LIB= pq
MKDIR= ../mk MKDIR= ../mk
include $(MKDIR)/postgres.mk include $(MKDIR)/postgres.mk
CFLAGS+= -I$(srcdir)/backend/include \ CFLAGS+= -I../backend/include \
-I$(srcdir)/include \ -I$../include \
-I$(srcdir)/backend \ -I$../backend \
-I$(CURDIR) \ -I. \
ifdef KRBVERS ifdef KRBVERS
CFLAGS+= $(KRBFLAGS) CFLAGS+= $(KRBFLAGS)
endif endif
# dllist.c is found in backend/lib # dllist.c is found in backend/lib
VPATH:= $(VPATH):$(srcdir)/backend/lib VPATH:= $(VPATH):../backend/lib
LIBSRCS= fe-auth.c fe-connect.c fe-exec.c fe-misc.c fe-lobj.c \ LIBSRCS= fe-auth.c fe-connect.c fe-exec.c fe-misc.c fe-lobj.c \
dllist.c pqsignal.c dllist.c pqsignal.c
ifeq ($(PORTNAME), next) ifeq ($(PORTNAME), next)
VPATH:=$(VPATH):$(srcdir)/backend/port/$(PORTNAME) VPATH:=$(VPATH):../backend/port/$(PORTNAME)
LIBSRCS+= getcwd.c putenv.c LIBSRCS+= getcwd.c putenv.c
endif endif
all:: libpq.a postgres.h c.h
postgres.h: ../backend/include/postgres.h
# Note: ../backend/include/postgres.h needs to be named something different
# to avoid confusion with this thing we're building now.
#
# hardwire NAMEDATALEN and OIDNAMELEN into the postgres.h for this installation
rm -f obj/postgres.h
echo "#define NAMEDATALEN $(NAMEDATALEN)" >> obj/postgres.h
echo "#define OIDNAMELEN $(OIDNAMELEN)" >> obj/postgres.h
cat ../backend/include/postgres.h >> obj/postgres.h
c.h: ../backend/include/c.h
rm -f obj/c.h
echo "#undef PORTNAME" > obj/c.h
echo "#define PORTNAME $(PORTNAME)" >> obj/c.h
echo "#undef PORTNAME_$(PORTNAME)" >> obj/c.h
echo "#define PORTNAME_$(PORTNAME)" >> obj/c.h
cat ../backend/include/c.h >> obj/c.h
.PHONY: beforeinstall-headers install-headers .PHONY: beforeinstall-headers install-headers
ifndef NO_BEFOREINSTL ifndef NO_BEFOREINSTL
beforeinstall-headers: beforeinstall-headers:
@-if [ ! -d $(HEADERDIR) ]; then mkdir $(HEADERDIR); fi @if [ ! -d $(HEADERDIR) ]; then mkdir $(HEADERDIR); fi
@-if [ ! -d $(HEADERDIR)/port ]; then mkdir $(HEADERDIR)/port; fi @if [ ! -d $(HEADERDIR)/port ]; then mkdir $(HEADERDIR)/port; fi
@-if [ ! -d $(HEADERDIR)/port/$(PORTNAME) ]; \ @if [ ! -d $(HEADERDIR)/port/$(PORTNAME) ]; \
then mkdir $(HEADERDIR)/port/$(PORTNAME); fi then mkdir $(HEADERDIR)/port/$(PORTNAME); fi
@-if [ ! -d $(HEADERDIR)/include ]; \ @if [ ! -d $(HEADERDIR)/include ]; \
then mkdir $(HEADERDIR)/include; fi then mkdir $(HEADERDIR)/include; fi
@-if [ ! -d $(HEADERDIR)/lib ]; \ @if [ ! -d $(HEADERDIR)/lib ]; \
then mkdir $(HEADERDIR)/lib; fi then mkdir $(HEADERDIR)/lib; fi
@-if [ ! -d $(HEADERDIR)/libpq ]; \ @if [ ! -d $(HEADERDIR)/libpq ]; \
then mkdir $(HEADERDIR)/libpq; fi then mkdir $(HEADERDIR)/libpq; fi
@-if [ ! -d $(HEADERDIR)/utils ]; \ @if [ ! -d $(HEADERDIR)/utils ]; \
then mkdir $(HEADERDIR)/utils; fi then mkdir $(HEADERDIR)/utils; fi
else else
beforeinstall-headers: .dosomething beforeinstall-headers: .dosomething
endif endif
HEADERFILES = include/postgres.h \
libpq/pqcomm.h \
libpq/libpq-fs.h \
lib/dllist.h \
utils/geo-decls.h
ifeq ($(PORTNAME), hpux)
HEADERFILES += port/hpux/fixade.h
endif
TEMPDIR=obj TEMPDIR=obj
install-headers: beforeinstall-headers install-headers: beforeinstall-headers postgres.h c.h
@for i in ${HEADERFILES}; do \ $(INSTALL) $(INSTLOPTS) ../backend/include/postgres.h \
echo "Installing $(HEADERDIR)/$$i."; \ $(HEADERDIR)/postgres.h
$(INSTALL) $(INSTLOPTS) $(srcdir)/backend/$$i $(HEADERDIR)/$$i; \ $(INSTALL) $(INSTLOPTS) ../include/libpq/pqcomm.h \
done $(HEADERDIR)/libpq/pqcomm.h
$(INSTALL) $(INSTLOPTS) ../include/libpq/libpq-fs.h \
$(HEADERDIR)/libpq/libpq-fs.h
$(INSTALL) $(INSTLOPTS) ../include/lib/dllist.h \
$(HEADERDIR)/libpq/dllist.h
$(INSTALL) $(INSTLOPTS) ../include/utils/geo-decls.h \
$(HEADERDIR)/utils/geo-decls.h
$(INSTALL) $(INSTLOPTS) libpq-fe.h $(HEADERDIR)/libpq-fe.h $(INSTALL) $(INSTLOPTS) libpq-fe.h $(HEADERDIR)/libpq-fe.h
@mv -f $(HEADERDIR)/include/* $(HEADERDIR) ifeq ($(PORTNAME), hpux)
@rmdir $(HEADERDIR)/include $(INSTALL) $(INSTLOPTS) ../backend/port/hpux/fixade.h \
# XXX - installing fmgr.h depends on the backend being built $(HEADERDIR)/port/hpux/fixade.h
$(INSTALL) $(INSTLOPTS) $(srcdir)/backend/$(objdir)/fmgr.h $(HEADERDIR)/fmgr.h endif
@rm -f $(TEMPDIR)/c.h $(INSTALL) $(INSTLOPTS) obj/c.h $(HEADERDIR)/c.h
@echo "#undef PORTNAME" > $(TEMPDIR)/c.h $(INSTALL) $(INSTLOPTS) obj/postgres.h $(HEADERDIR)/postgres.h
@echo "#define PORTNAME $(PORTNAME)" >> $(TEMPDIR)/c.h
@echo "#undef PORTNAME_$(PORTNAME)" >> $(TEMPDIR)/c.h
@echo "#define PORTNAME_$(PORTNAME)" >> $(TEMPDIR)/c.h
@cat $(srcdir)/backend/include/c.h >> $(TEMPDIR)/c.h
$(INSTALL) $(INSTLOPTS) $(TEMPDIR)/c.h $(HEADERDIR)/c.h
@rm -f $(TEMPDIR)/postgres.h
# hardwire NAMEDATALEN and OIDNAMELEN into the postgres.h for this installation
@echo "#define NAMEDATALEN $(NAMEDATALEN)" >> $(TEMPDIR)/postgres.h
@echo "#define OIDNAMELEN $(OIDNAMELEN)" >> $(TEMPDIR)/postgres.h
@cat $(srcdir)/backend/include/postgres.h >> $(TEMPDIR)/postgres.h
$(INSTALL) $(INSTLOPTS) $(TEMPDIR)/postgres.h $(HEADERDIR)/postgres.h
@rm -f $(TEMPDIR)/c.h $(TEMPDIR)/postgres.h
install:: install-headers install:: install-headers
CLEANFILES+= c.h postgres.h
LIB= pq
include $(MKDIR)/postgres.lib.mk include $(MKDIR)/postgres.lib.mk
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/mk/Attic/postgres.mk,v 1.2 1996/07/27 02:04:12 scrappy Exp $ # $Header: /cvsroot/pgsql/src/mk/Attic/postgres.mk,v 1.3 1996/09/23 08:24:11 scrappy Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -123,10 +123,8 @@ beforeinstall: localobj ...@@ -123,10 +123,8 @@ beforeinstall: localobj
then mkdir $(DESTDIR)$(LIBDIR); fi then mkdir $(DESTDIR)$(LIBDIR); fi
@-if test ! -d $(DESTDIR)$(BINDIR); \ @-if test ! -d $(DESTDIR)$(BINDIR); \
then mkdir $(DESTDIR)$(BINDIR); fi then mkdir $(DESTDIR)$(BINDIR); fi
@-if test ! -d $(DESTDIR)$(DATADIR); \ @-if test ! -d $(HEADERDIR); \
then mkdir $(DESTDIR)$(DATADIR); fi then mkdir $(HEADERDIR); fi
@-if test ! -d $(DESTDIR)$(DATADIR)/files; \
then mkdir $(DESTDIR)$(DATADIR)/files; fi
else else
beforeinstall: localobj beforeinstall: localobj
endif endif
......
...@@ -11,28 +11,33 @@ ...@@ -11,28 +11,33 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/mk/Attic/postgres.shell.mk,v 1.1.1.1 1996/07/09 06:22:19 scrappy Exp $ # $Header: /cvsroot/pgsql/src/mk/Attic/postgres.shell.mk,v 1.2 1996/09/23 08:24:13 scrappy Exp $
# #
# NOTES # NOTES
# the shell script you write might include the following strings which # the shell script you write might include the following strings which
# will be turned into the values listed below: # will be turned into the values listed below:
# #
# _fUnKy_BINDIR_sTuFf_ - location of installed binaries # _fUnKy_BINDIR_sTuFf_ - location of installed binaries
# _fUnKy_DATADIR_sTuFf_ - location of the data directory # _fUnKy_LIBDIR_sTuFf_ - location of installed library stuff
# _fUnKy_DATADIR_sTuFf_ - location of the default data directory
# _fUnKy_POSTGRESDIR_sTuFf_ - location of the postgres "home" directory # _fUnKy_POSTGRESDIR_sTuFf_ - location of the postgres "home" directory
# _fUnKy_NAMEDATALEN_sTuFf_ - length of a datum of type "name"
# _fUnKy_OIDNAMELEN_sTuFf_ - ?
# _fUnKy_IPCCLEANPATH_sTuFf_ - location of the ipcs and ipcrm programs # _fUnKy_IPCCLEANPATH_sTuFf_ - location of the ipcs and ipcrm programs
# _fUnKy_DASH_N_sTuFf_ - -n flag used in echo # _fUnKy_DASH_N_sTuFf_ - -n flag used in echo
# _fUnKy_BACKSLASH_C_sTuFf_ - continuation (echo) # _fUnKy_BACKSLASH_C_sTuFf_ - continuation (echo)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# And all the shell scripts here get stuffed with the default # Insert installation-dependent filepaths into the shell script
# values for BINDIR, DATADIR, and POSTGRESDIR
# #
SEDSCRIPT= -e "s^_fUnKy_BINDIR_sTuFf_^$(BINDIR)^g" \ SEDSCRIPT= \
-e "s^_fUnKy_BINDIR_sTuFf_^$(BINDIR)^g" \
-e "s^_fUnKy_LIBDIR_sTuFf_^$(LIBDIR)^g" \
-e "s^_fUnKy_DATADIR_sTuFf_^$(DATADIR)^g" \ -e "s^_fUnKy_DATADIR_sTuFf_^$(DATADIR)^g" \
-e "s^_fUnKy_IPCCLEANPATH_sTuFf_^$(IPCSDIR)^g" \ -e "s^_fUnKy_IPCCLEANPATH_sTuFf_^$(IPCSDIR)^g" \
-e "s^_fUnKy_POSTGRESDIR_sTuFf_^$(POSTGRESDIR)^g" -e "s^_fUnKy_NAMEDATALEN_sTuFf_^$(NAMEDATALEN)^g" \
-e "s^_fUnKy_OIDNAMELEN_sTuFf_^$(OIDNAMELEN)^g"
# #
# We also need to fix up the scripts to deal with the lack of installed # We also need to fix up the scripts to deal with the lack of installed
......
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