|
39 | 39 | * Portions Copyright (c) 1994, Regents of the University of California
|
40 | 40 | * Portions taken from FreeBSD.
|
41 | 41 | *
|
42 |
| - * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.30 2004/05/1713:17:29 momjian Exp $ |
| 42 | + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.31 2004/05/1714:35:33 momjian Exp $ |
43 | 43 | *
|
44 | 44 | *-------------------------------------------------------------------------
|
45 | 45 | */
|
@@ -69,11 +69,8 @@ intoptreset;
|
69 | 69 |
|
70 | 70 | /*
|
71 | 71 | * these values are passed in by makefile defines
|
72 |
| - * |
73 |
| - * Note that "datadir" is not the directory we're going to initialize, |
74 |
| - * it's merely how Autoconf names PREFIX/share. |
75 | 72 | */
|
76 |
| -char*datadir=PGDATADIR; |
| 73 | +char*share_path=NULL; |
77 | 74 |
|
78 | 75 | /* values to be obtained from arguments */
|
79 | 76 | char*pg_data="";
|
@@ -129,7 +126,7 @@ static const char *backend_options = "-F -O -c search_path=pg_catalog -c exit_on
|
129 | 126 |
|
130 | 127 |
|
131 | 128 | /* path to 'initdb' binary directory */
|
132 |
| -charbindir[MAXPGPATH]; |
| 129 | +charbin_path[MAXPGPATH]; |
133 | 130 | charbackend_exec[MAXPGPATH];
|
134 | 131 |
|
135 | 132 | staticvoid*xmalloc(size_tsize);
|
@@ -730,8 +727,8 @@ mkdatadir(char *subdir)
|
730 | 727 | staticvoid
|
731 | 728 | set_input(char**dest,char*filename)
|
732 | 729 | {
|
733 |
| -*dest=xmalloc(strlen(datadir)+strlen(filename)+2); |
734 |
| -sprintf(*dest,"%s/%s",datadir,filename); |
| 730 | +*dest=xmalloc(strlen(share_path)+strlen(filename)+2); |
| 731 | +sprintf(*dest,"%s/%s",share_path,filename); |
735 | 732 | }
|
736 | 733 |
|
737 | 734 | /*
|
@@ -1849,7 +1846,7 @@ main(int argc, char *argv[])
|
1849 | 1846 | printf(_("Running in noclean mode. Mistakes will not be cleaned up.\n"));
|
1850 | 1847 | break;
|
1851 | 1848 | case'L':
|
1852 |
| -datadir=xstrdup(optarg); |
| 1849 | +share_path=xstrdup(optarg); |
1853 | 1850 | break;
|
1854 | 1851 | case1:
|
1855 | 1852 | locale=xstrdup(optarg);
|
@@ -1951,9 +1948,15 @@ main(int argc, char *argv[])
|
1951 | 1948 | }
|
1952 | 1949 |
|
1953 | 1950 | /* store binary directory */
|
1954 |
| -strcpy(bindir,backend_exec); |
1955 |
| -*last_path_separator(bindir)='\0'; |
1956 |
| - |
| 1951 | +strcpy(bin_path,backend_exec); |
| 1952 | +*last_path_separator(bin_path)='\0'; |
| 1953 | + |
| 1954 | +if (!share_path) |
| 1955 | +{ |
| 1956 | +share_path=xmalloc(MAXPGPATH); |
| 1957 | +get_share_path(backend_exec,share_path); |
| 1958 | +} |
| 1959 | + |
1957 | 1960 | if ((short_version=get_short_version())==NULL)
|
1958 | 1961 | {
|
1959 | 1962 | fprintf(stderr,_("%s: could not determine valid short version string\n"),progname);
|
@@ -1983,13 +1986,13 @@ main(int argc, char *argv[])
|
1983 | 1986 | {
|
1984 | 1987 | fprintf(stderr,
|
1985 | 1988 | "VERSION=%s\n"
|
1986 |
| -"PGDATA=%s\ndatadir=%s\nPGPATH=%s\n" |
| 1989 | +"PGDATA=%s\nshare_path=%s\nPGPATH=%s\n" |
1987 | 1990 | "ENCODING=%s\nENCODINGID=%s\n"
|
1988 | 1991 | "POSTGRES_SUPERUSERNAME=%s\nPOSTGRES_BKI=%s\n"
|
1989 | 1992 | "POSTGRES_DESCR=%s\nPOSTGRESQL_CONF_SAMPLE=%s\n"
|
1990 | 1993 | "PG_HBA_SAMPLE=%s\nPG_IDENT_SAMPLE=%s\n",
|
1991 | 1994 | PG_VERSION,
|
1992 |
| -pg_data,datadir,bindir, |
| 1995 | +pg_data,share_path,bin_path, |
1993 | 1996 | encoding,encodingid,
|
1994 | 1997 | username,bki_file,
|
1995 | 1998 | desc_file,conf_file,
|
@@ -2182,8 +2185,8 @@ main(int argc, char *argv[])
|
2182 | 2185 | " %s%s%s/postmaster -D %s%s%s\n"
|
2183 | 2186 | "or\n"
|
2184 | 2187 | " %s%s%s/pg_ctl -D %s%s%s -l logfile start\n\n"),
|
2185 |
| -QUOTE_PATH,bindir,QUOTE_PATH,QUOTE_PATH,pg_data,QUOTE_PATH, |
2186 |
| -QUOTE_PATH,bindir,QUOTE_PATH,QUOTE_PATH,pg_data,QUOTE_PATH); |
| 2188 | +QUOTE_PATH,bin_path,QUOTE_PATH,QUOTE_PATH,pg_data,QUOTE_PATH, |
| 2189 | +QUOTE_PATH,bin_path,QUOTE_PATH,QUOTE_PATH,pg_data,QUOTE_PATH); |
2187 | 2190 |
|
2188 | 2191 | return0;
|
2189 | 2192 | }
|