From 88f78eb660c20ef6cc9775b1672630d1e2ed33a3 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 25 Aug 2007 20:29:25 +0000 Subject: [PATCH] Adjust with-system-tzdata patch to not attempt to install a symlink, but just hardwire the specified timezone database path into the executable. Per discussion, this avoids some packaging disadvantages of using a symlink. --- doc/src/sgml/installation.sgml | 36 +++++++++++++++++----------------- src/timezone/Makefile | 17 +++++++++++----- src/timezone/pgtz.c | 14 +++++++++---- 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml index 8fb93f228f..9c8645a041 100644 --- a/doc/src/sgml/installation.sgml +++ b/doc/src/sgml/installation.sgml @@ -1028,20 +1028,21 @@ su - postgres - PostgreSQL includes its own time zone database, which it - requires for date and time operations. This time zone - database is in fact compatible with the time zone database - provided by many operating systems such as FreeBSD, Linux, - and Solaris, so it would be redundant to install it again. - When this option is used, the operating system supplied time - zone database in DIRECTORY is used - instead of the one included in the PostgreSQL source - distribution. /usr/share/zoneinfo/ is a + PostgreSQL includes its own time zone database, + which it requires for date and time operations. This time zone + database is in fact compatible with the zic time zone + database provided by many operating systems such as FreeBSD, + Linux, and Solaris, so it would be redundant to install it again. + When this option is used, the system-supplied time zone database + in DIRECTORY is used instead of the one + included in the PostgreSQL source distribution. + DIRECTORY must be specified as an + absolute path. /usr/share/zoneinfo is a likely directory on some operating systems. Note that the - installation routine does not detect mismatching or erroneous - time zone data. You are advised to run the regression tests - to verify that the time zone data you have pointed to works - correctly. + installation routine will not detect mismatching or erroneous time + zone data. If you use this option, you are advised to run the + regression tests to verify that the time zone data you have + pointed to works correctly with PostgreSQL. @@ -1049,11 +1050,10 @@ su - postgres who know their target operating system well. The main advantage of using this option is that the PostgreSQL package won't need to be upgraded whenever any of the many local - daylight-saving time rules changes. Another completely - incidental advantage is that PostgreSQL can be - cross-compiledcross - compilation straightforwardly if the - time-zone database does not need to be built during the + daylight-saving time rules change. Another advantage is that + PostgreSQL can be cross-compiledcross + compilation more straightforwardly if the + time zone database files do not need to be built during the installation. diff --git a/src/timezone/Makefile b/src/timezone/Makefile index d9176e2a83..ce02fa7b78 100644 --- a/src/timezone/Makefile +++ b/src/timezone/Makefile @@ -27,21 +27,26 @@ TZDATAFILES = $(TZDATA:%=$(srcdir)/data/%) # for POSIX-style timezone specs POSIXRULES = US/Eastern -all: SUBSYS.o submake-libpgport zic +# use system timezone data? +ifneq (,$(with_system_tzdata)) +override CPPFLAGS += '-DSYSTEMTZDIR="$(with_system_tzdata)"' +endif + +all: SUBSYS.o + +ifeq (,$(with_system_tzdata)) +all: submake-libpgport zic +endif SUBSYS.o: $(OBJS) $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS) -ifeq (,$(with_system_tzdata)) zic: $(ZICOBJS) $(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LIBS) -o $@$(X) -endif install: all installdirs ifeq (,$(with_system_tzdata)) ./zic -d '$(DESTDIR)$(datadir)/timezone' -p '$(POSIXRULES)' $(TZDATAFILES) -else - ln -s '$(with_system_tzdata)' '$(DESTDIR)$(datadir)/timezone' endif $(MAKE) -C tznames $@ @@ -49,7 +54,9 @@ installdirs: $(mkinstalldirs) '$(DESTDIR)$(datadir)' uninstall: +ifeq (,$(with_system_tzdata)) rm -rf '$(DESTDIR)$(datadir)/timezone' +endif $(MAKE) -C tznames $@ clean distclean maintainer-clean: diff --git a/src/timezone/pgtz.c b/src/timezone/pgtz.c index f7c42494d2..de3260507e 100644 --- a/src/timezone/pgtz.c +++ b/src/timezone/pgtz.c @@ -38,9 +38,6 @@ pg_tz *gmt_timezone = NULL; static pg_tz gmt_timezone_data; -static char tzdir[MAXPGPATH]; -static bool done_tzdir = false; - static bool scan_directory_ci(const char *dirname, const char *fname, int fnamelen, char *canonname, int canonnamelen); @@ -52,9 +49,14 @@ static pg_tz *select_default_timezone(void); /* * Return full pathname of timezone data directory */ -static char * +static const char * pg_TZDIR(void) { +#ifndef SYSTEMTZDIR + /* normal case: timezone stuff is under our share dir */ + static bool done_tzdir = false; + static char tzdir[MAXPGPATH]; + if (done_tzdir) return tzdir; @@ -63,6 +65,10 @@ pg_TZDIR(void) done_tzdir = true; return tzdir; +#else + /* we're configured to use system's timezone database */ + return SYSTEMTZDIR; +#endif } -- 2.39.5