1
From 678198995adc4c57e35f83bbdfcd91b979ae1622 Mon Sep 17 00:00:00 2001
2
From: Ben Pfaff <blp@nicira.com>
3
Date: Thu, 2 Aug 2012 16:01:49 -0700
4
Subject: [PATCH] dirs: dbdir default must be based on sysconfdir.
6
Some in-tree and out-of-tree code sets the OVS_SYSCONFDIR environment
7
variable to control where /etc files go (mostly for test purposes). When
8
the database directory (dbdir) was split off from the sysconfdir, the
9
configure-time default continued to be based on the sysconfdir, but
10
overriding the sysconfdir at runtime with OVS_SYSCONFDIR didn't have any
11
effect on the dbdir, which caused a visible change in behavior for code
12
that set the OVS_SYSCONFDIR environment variable. This commit reverts that
13
change in behavior, by basing the dbdir on OVS_SYSCONFDIR if that
14
environment variable is set (but the OVS_DBDIR environment variable is
17
Signed-off-by: Ben Pfaff <blp@nicira.com>
19
lib/dirs.c.in | 15 +++++++++++++--
20
python/automake.mk | 29 +++++++++++++++++++++++------
21
python/ovs/dirs.py | 20 ++++++++++++--------
22
python/ovs/dirs.py.template | 17 +++++++++++++++++
23
utilities/ovs-lib.in | 11 +++++++++--
24
5 files changed, 74 insertions(+), 18 deletions(-)
25
create mode 100644 python/ovs/dirs.py.template
27
Index: b/lib/dirs.c.in
28
===================================================================
38
const char *value; /* Actual value; NULL if not yet determined. */
39
@@ -68,8 +69,18 @@ ovs_logdir(void)
43
- static struct directory d = { NULL, @DBDIR@, "OVS_DBDIR" };
45
+ static const char *dbdir;
47
+ dbdir = getenv("OVS_DBDIR");
48
+ if (!dbdir || !dbdir[0]) {
49
+ char *sysconfdir = getenv("OVS_SYSCONFDIR");
52
+ ? xasprintf("%s/openvswitch", sysconfdir)
60
Index: b/python/automake.mk
61
===================================================================
62
--- a/python/automake.mk
63
+++ b/python/automake.mk
64
@@ -36,12 +36,15 @@ if HAVE_PYTHON
65
nobase_pkgdata_DATA = $(ovs_pyfiles) $(ovstest_pyfiles)
66
ovs-install-data-local:
68
- (echo "import os" && \
69
- echo 'PKGDATADIR = os.environ.get("OVS_PKGDATADIR", """$(pkgdatadir)""")' && \
70
- echo 'RUNDIR = os.environ.get("OVS_RUNDIR", """@RUNDIR@""")' && \
71
- echo 'LOGDIR = os.environ.get("OVS_LOGDIR", """@LOGDIR@""")' && \
72
- echo 'DBDIR = os.environ.get("OVS_DBDIR", """@DBDIR@""")' && \
73
- echo 'BINDIR = os.environ.get("OVS_BINDIR", """$(bindir)""")') \
76
+ -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \
77
+ -e 's,[@]RUNDIR[@],$(RUNDIR),g' \
78
+ -e 's,[@]LOGDIR[@],$(LOGDIR),g' \
79
+ -e 's,[@]bindir[@],$(bindir),g' \
80
+ -e 's,[@]sysconfdir[@],$(sysconfdir),g' \
81
+ -e 's,[@]DBDIR[@],$(DBDIR),g' \
82
+ < $(srcdir)/python/ovs/dirs.py.template \
83
> python/ovs/dirs.py.tmp
84
$(MKDIR_P) $(DESTDIR)$(pkgdatadir)/python/ovs
85
$(INSTALL_DATA) python/ovs/dirs.py.tmp $(DESTDIR)$(pkgdatadir)/python/ovs/dirs.py
86
@@ -55,3 +58,17 @@ install-data-local: ovs-install-data-loc
87
UNINSTALL_LOCAL += ovs-uninstall-local
89
rm -f $(DESTDIR)$(pkgdatadir)/python/ovs/dirs.py
91
+ALL_LOCAL += $(srcdir)/python/ovs/dirs.py
92
+$(srcdir)/python/ovs/dirs.py: python/ovs/dirs.py.template
95
+ -e 's,[@]pkgdatadir[@],/usr/local/share/openvswitch,g' \
96
+ -e 's,[@]RUNDIR[@],/var/run,g' \
97
+ -e 's,[@]LOGDIR[@],/usr/local/var/log,g' \
98
+ -e 's,[@]bindir[@],/usr/local/bin,g' \
99
+ -e 's,[@]sysconfdir[@],/usr/local/etc,g' \
100
+ -e 's,[@]DBDIR[@],/usr/local/etc/openvswitch,g' \
103
+EXTRA_DIST += python/ovs/dirs.py python/ovs/dirs.py.template
104
Index: b/python/ovs/dirs.py
105
===================================================================
106
--- a/python/ovs/dirs.py
107
+++ b/python/ovs/dirs.py
109
-# These are the default directories. They will be replaced by the
110
-# configured directories at install time.
113
-PKGDATADIR = os.environ.get("OVS_PKGDATADIR", "/usr/local/share/openvswitch")
114
-RUNDIR = os.environ.get("OVS_RUNDIR", "/var/run")
115
-LOGDIR = os.environ.get("OVS_LOGDIR", "/usr/local/var/log")
116
-DBDIR = os.environ.get("OVS_DBDIR", "/usr/local/etc/openvswitch")
117
-BINDIR = os.environ.get("OVS_BINDIR", "/usr/local/bin")
118
+PKGDATADIR = os.environ.get("OVS_PKGDATADIR", """/usr/local/share/openvswitch""")
119
+RUNDIR = os.environ.get("OVS_RUNDIR", """/var/run""")
120
+LOGDIR = os.environ.get("OVS_LOGDIR", """/usr/local/var/log""")
121
+BINDIR = os.environ.get("OVS_BINDIR", """/usr/local/bin""")
123
+DBDIR = os.environ.get("OVS_DBDIR")
125
+ sysconfdir = os.environ.get("OVS_SYSCONFDIR")
127
+ DBDIR = "%s/openvswitch" % sysconfdir
129
+ DBDIR = """/usr/local/etc/openvswitch"""
130
Index: b/python/ovs/dirs.py.template
131
===================================================================
133
+++ b/python/ovs/dirs.py.template
135
+## The @variables@ in this file are replaced by default directories for
136
+## use in python/ovs/dirs.py in the source directory and replaced by the
137
+## configured directories for use in the installed python/ovs/dirs.py.
140
+PKGDATADIR = os.environ.get("OVS_PKGDATADIR", """@pkgdatadir@""")
141
+RUNDIR = os.environ.get("OVS_RUNDIR", """@RUNDIR@""")
142
+LOGDIR = os.environ.get("OVS_LOGDIR", """@LOGDIR@""")
143
+BINDIR = os.environ.get("OVS_BINDIR", """@bindir@""")
145
+DBDIR = os.environ.get("OVS_DBDIR")
147
+ sysconfdir = os.environ.get("OVS_SYSCONFDIR")
149
+ DBDIR = "%s/openvswitch" % sysconfdir
151
+ DBDIR = """@DBDIR@"""
152
Index: b/utilities/ovs-lib.in
153
===================================================================
154
--- a/utilities/ovs-lib.in
155
+++ b/utilities/ovs-lib.in
157
# All of these should be substituted by the Makefile at build time.
158
logdir=${OVS_LOGDIR-'@LOGDIR@'} # /var/log/openvswitch
159
rundir=${OVS_RUNDIR-'@RUNDIR@'} # /var/run/openvswitch
160
-dbdir=${OVS_DBDIR-'@DBDIR@'} # /etc/openvswitch
161
- # or /var/lib/openvswitch
162
sysconfdir=${OVS_SYSCONFDIR-'@sysconfdir@'} # /etc
163
etcdir=$sysconfdir/openvswitch # /etc/openvswitch
164
datadir=${OVS_PKGDATADIR-'@pkgdatadir@'} # /usr/share/openvswitch
165
bindir=${OVS_BINDIR-'@bindir@'} # /usr/bin
166
sbindir=${OVS_SBINDIR-'@sbindir@'} # /usr/sbin
168
+# /etc/openvswitch or /var/lib/openvswitch
169
+if test X"$OVS_DBDIR" != X; then
171
+elif test X"$OVS_SYSCONFDIR" != X; then
172
+ dbdir=$OVS_SYSCONFDIR/openvswitch
179
[1-9]*) BUILDNR='+build@BUILDNR@' ;;