Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fda15b3

Browse files
committed
As part of the work for making relocatable installs, I have re-factored
all the code that looks for other binaries. I move FindExec into port/exec.c (and renamed it to find_my_binary()). I also added find_other_binary that looks for another binary in the same directory as the calling program, and checks the version string. The only behavior change was that initdb and pg_dump would look in the hard-coded bindir directory if it can't find the requested binary in the same directory as the caller. The new code throws an error. The old behavior seemed too error prone for version mismatches.
1 parent 270c9aa commit fda15b3

File tree

15 files changed

+305
-447
lines changed

15 files changed

+305
-447
lines changed

configure

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12011,7 +12011,6 @@ case $host_os in mingw*)
1201112011
LIBOBJS="$LIBOBJS copydir.$ac_objext"
1201212012
LIBOBJS="$LIBOBJS gettimeofday.$ac_objext"
1201312013
LIBOBJS="$LIBOBJS open.$ac_objext"
12014-
LIBOBJS="$LIBOBJS pipe.$ac_objext"
1201512014
LIBOBJS="$LIBOBJS rand.$ac_objext"
1201612015

1201712016
cat >>confdefs.h <<\_ACEOF

configure.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.345 2004/05/07 00:24:57 tgl Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.346 2004/05/11 21:57:13 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -892,7 +892,6 @@ case $host_os in mingw*)
892892
AC_LIBOBJ(copydir)
893893
AC_LIBOBJ(gettimeofday)
894894
AC_LIBOBJ(open)
895-
AC_LIBOBJ(pipe)
896895
AC_LIBOBJ(rand)
897896
AC_DEFINE(USE_PGTZ, 1,
898897
[Define to 1 to use our own timezone library])

src/Makefile.global.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.181 2004/05/07 00:24:57 tgl Exp $
2+
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.182 2004/05/11 21:57:14 momjian Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -339,7 +339,7 @@ endif
339339
#
340340
# substitute implementations of the C library
341341

342-
LIBOBJS = @LIBOBJS@ noblock.o path.o pgsleep.o pgstrcasecmp.o sprompt.o thread.o
342+
LIBOBJS = @LIBOBJS@ exec.o noblock.o path.o pipe.o pgsleep.o pgstrcasecmp.o sprompt.o thread.o
343343

344344
ifneq (,$(LIBOBJS))
345345
LIBS += -lpgport

src/backend/postmaster/postmaster.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.382 2004/05/06 19:23:25 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.383 2004/05/11 21:57:14 momjian Exp $
4141
*
4242
* NOTES
4343
*
@@ -692,7 +692,7 @@ PostmasterMain(int argc, char *argv[])
692692
/*
693693
* On some systems our dynloader code needs the executable's pathname.
694694
*/
695-
if (FindExec(pg_pathname, progname, "postgres") < 0)
695+
if (find_my_binary(pg_pathname, progname, "postgres") < 0)
696696
ereport(FATAL,
697697
(errmsg("%s: could not locate postgres executable",
698698
progname)));
@@ -3222,7 +3222,7 @@ CreateOptsFile(int argc, char *argv[])
32223222
FILE *fp;
32233223
int i;
32243224

3225-
if (FindExec(fullprogname, argv[0], "postmaster") < 0)
3225+
if (find_my_binary(fullprogname, argv[0], "postmaster") < 0)
32263226
{
32273227
elog(LOG, "could not locate postmaster");
32283228
return false;

src/backend/tcop/postgres.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.402 2004/05/07 01:53:41 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.403 2004/05/11 21:57:14 momjian Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -2649,7 +2649,7 @@ PostgresMain(int argc, char *argv[], const char *username)
26492649
* On some systems our dynloader code needs the executable's
26502650
* pathname. (If under postmaster, this was done already.)
26512651
*/
2652-
if (FindExec(pg_pathname, argv[0], "postgres") < 0)
2652+
if (find_my_binary(pg_pathname, argv[0], "postgres") < 0)
26532653
ereport(FATAL,
26542654
(errmsg("%s: could not locate postgres executable",
26552655
argv[0])));

src/backend/utils/init/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Makefile for utils/init
55
#
66
# IDENTIFICATION
7-
# $PostgreSQL: pgsql/src/backend/utils/init/Makefile,v 1.16 2003/11/29 19:52:01 pgsql Exp $
7+
# $PostgreSQL: pgsql/src/backend/utils/init/Makefile,v 1.17 2004/05/11 21:57:14 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
subdir = src/backend/utils/init
1212
top_builddir = ../../../..
1313
include $(top_builddir)/src/Makefile.global
1414

15-
OBJS = findbe.o globals.o miscinit.o postinit.o
15+
OBJS = globals.o miscinit.o postinit.o
1616

1717
all: SUBSYS.o
1818

src/bin/initdb/Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,27 @@
55
# Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/bin/initdb/Makefile,v 1.36 2004/04/26 17:40:48 momjian Exp $
8+
# $PostgreSQL: pgsql/src/bin/initdb/Makefile,v 1.37 2004/05/11 21:57:14 momjian Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

1212
subdir = src/bin/initdb
1313
top_builddir = ../../..
1414
include $(top_builddir)/src/Makefile.global
1515

16-
override CPPFLAGS := -DPGBINDIR=\"$(bindir)\" -DPGDATADIR=\"$(datadir)\" -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
16+
override CPPFLAGS := -DPGDATADIR=\"$(datadir)\" -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
1717

18-
OBJS= initdb.o
18+
OBJS= initdb.o \
19+
$(filter exec.o, $(LIBOBJS))
1920

2021
all: submake-libpq submake-libpgport initdb
2122

2223
initdb: $(OBJS) $(libpq_builddir)/libpq.a
2324
$(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
2425

26+
exec.c: % : $(top_srcdir)/src/port/%
27+
rm -f $@ && $(LN_S) $< .
28+
2529
install: all installdirs
2630
$(INSTALL_PROGRAM) initdb$(X) $(DESTDIR)$(bindir)/initdb$(X)
2731

@@ -32,8 +36,8 @@ uninstall:
3236
rm -f $(DESTDIR)$(bindir)/initdb$(X)
3337

3438
clean distclean maintainer-clean:
35-
rm -f initdb$(X) $(OBJS)
39+
rm -f initdb$(X) $(OBJS) exec.c
3640

3741

38-
# ensure that changes in bindir etc. propagate into object file
42+
# ensure that changes in datadir propagate into object file
3943
initdb.o: initdb.c $(top_builddir)/src/Makefile.global

0 commit comments

Comments
 (0)