Use nicer solution for tzdata file substitution.

This commit is contained in:
Tom Lane 2007-08-25 20:53:39 +00:00
parent 1a0df18342
commit 05e04c889c
2 changed files with 38 additions and 33 deletions

View File

@ -2,38 +2,20 @@ PostgreSQL includes its own copy of the zic timezone database, which is great
for ensuring portable results but not so great from a package maintenance
perspective. Since the data is in the same format as is provided by the
Linux-standard /usr/share/zoneinfo files, we can avoid having to update
postgresql for timezone updates by just symlinking to those files.
postgresql for timezone updates by just using those files instead.
It is allegedly desirable for the link in question to be a relative symlink.
I have strong doubts about this, not least because it requires the horrid
install-time kluge seen below --- we can't use a simple relative symlink when
making the temporary installation used for "make check", since that will be at
an indeterminate location compared to /usr/share. The actual relative link
also depends fundamentally upon knowing where the PG datadir will get
installed, namely /usr/share/pgsql.
And if you thought that was bad, it turns out that RPM has some fundamental
bugs that make it difficult or impossible to replace a directory with a
symlink during RPM upgrade. Rather than risk getting caught in that quagmire,
we choose to name the symlink something different than its predecessor
subdirectory. (This part of the hack could perhaps get undone someday, when
there is no longer any danger of someone trying to rpm-upgrade from an
installation that isn't patched this way.)
Note: as of PG 8.3 this patch will be unnecessary; use configure's
--with-system-tzdata switch instead.
diff -Naur postgresql-8.2.4.orig/src/timezone/Makefile postgresql-8.2.4/src/timezone/Makefile
--- postgresql-8.2.4.orig/src/timezone/Makefile 2007-03-14 13:38:15.000000000 -0400
+++ postgresql-8.2.4/src/timezone/Makefile 2007-08-22 16:57:41.000000000 -0400
@@ -38,14 +38,18 @@
+++ postgresql-8.2.4/src/timezone/Makefile 2007-08-25 16:38:53.000000000 -0400
@@ -38,14 +38,12 @@
$(CC) $(CFLAGS) $(ZICOBJS) $(LDFLAGS) $(LIBS) -o $@$(X)
install: all installdirs
- ./zic -d '$(DESTDIR)$(datadir)/timezone' -p '$(POSIXRULES)' $(TZDATAFILES)
+ if [ x'$(DESTDIR)' = x`echo '$(DESTDIR)' | sed 's,tmp_check/install,,'` ] ; then \
+ ln -s '../zoneinfo' '$(DESTDIR)$(datadir)/zoneinfo' ; \
+ else \
+ ln -s '/usr/share/zoneinfo' '$(DESTDIR)$(datadir)/zoneinfo' ; \
+ fi
$(MAKE) -C tznames $@
installdirs:
@ -41,19 +23,39 @@ diff -Naur postgresql-8.2.4.orig/src/timezone/Makefile postgresql-8.2.4/src/time
uninstall:
- rm -rf '$(DESTDIR)$(datadir)/timezone'
+ rm '$(DESTDIR)$(datadir)/zoneinfo'
$(MAKE) -C tznames $@
clean distclean maintainer-clean:
diff -Naur postgresql-8.2.4.orig/src/timezone/pgtz.c postgresql-8.2.4/src/timezone/pgtz.c
--- postgresql-8.2.4.orig/src/timezone/pgtz.c 2006-11-21 18:11:55.000000000 -0500
+++ postgresql-8.2.4/src/timezone/pgtz.c 2007-08-22 16:57:04.000000000 -0400
@@ -52,7 +52,7 @@
return tzdir;
+++ postgresql-8.2.4/src/timezone/pgtz.c 2007-08-25 16:42:32.000000000 -0400
@@ -31,9 +31,6 @@
pg_tz *global_timezone = NULL;
get_share_path(my_exec_path, tzdir);
-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);
@@ -45,17 +42,10 @@
/*
* Return full pathname of timezone data directory
*/
-static char *
+static const char *
pg_TZDIR(void)
{
- if (done_tzdir)
- return tzdir;
-
- get_share_path(my_exec_path, tzdir);
- strlcpy(tzdir + strlen(tzdir), "/timezone", MAXPGPATH - strlen(tzdir));
+ strlcpy(tzdir + strlen(tzdir), "/zoneinfo", MAXPGPATH - strlen(tzdir));
-
- done_tzdir = true;
- return tzdir;
+ return "/usr/share/zoneinfo";
}
done_tzdir = true;
return tzdir;

View File

@ -81,7 +81,7 @@
Summary: PostgreSQL client programs and libraries
Name: postgresql
Version: 8.2.4
Release: 4%{?dist}
Release: 5%{?dist}
License: BSD
Group: Applications/Databases
Url: http://www.postgresql.org/
@ -743,7 +743,6 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/pgsql/postgres.shdescription
%{_datadir}/pgsql/system_views.sql
%{_datadir}/pgsql/*.sample
%{_datadir}/pgsql/zoneinfo
%{_datadir}/pgsql/timezonesets/
%{_libdir}/pgsql/plpgsql.so
%dir %{_datadir}/pgsql
@ -820,6 +819,10 @@ rm -rf $RPM_BUILD_ROOT
%endif
%changelog
* Sat Aug 25 2007 Tom Lane <tgl@redhat.com> 8.2.4-5
- Use nicer solution for tzdata file substitution: upstream discussion
concluded that hardwiring the path was better than a symlink after all.
* Wed Aug 22 2007 Tom Lane <tgl@redhat.com> 8.2.4-4
- Use tzdata package's data files instead of private copy, so that
postgresql-server need not be turned for routine timezone updates