~james-page/ubuntu/raring/openvswitch/lts-raring-backport-dkms

« back to all changes in this revision

Viewing changes to debian/patches/bug-681880-9-dirs-dbdir-default-must-be-based-on-sysconfdir.patch

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-08-07 16:00:53 UTC
  • mfrom: (5.1.25 sid)
  • Revision ID: package-import@ubuntu.com-20120807160053-nj4pgmkn6bp8t4md
Tags: 1.4.2+git20120612-9ubuntu1
* Merge from Debian unstable; remaining changes:
  - d/control: Disable openvswitch-datapath-dkms package.
* Dropped changes:
  - d/patches/kernel_3.5_support.patch: Superceded by 
    bug-684057-ovs-ctl-Add-support-for-newer-module-name.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
5
 
 
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
 
15
not).
 
16
 
 
17
Signed-off-by: Ben Pfaff <blp@nicira.com>
 
18
---
 
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
 
26
 
 
27
Index: b/lib/dirs.c.in
 
28
===================================================================
 
29
--- a/lib/dirs.c.in
 
30
+++ b/lib/dirs.c.in
 
31
@@ -18,6 +18,7 @@
 
32
 #include <config.h>
 
33
 #include "dirs.h"
 
34
 #include <stdlib.h>
 
35
+#include "util.h"
 
36
 
 
37
 struct directory {
 
38
     const char *value;          /* Actual value; NULL if not yet determined. */
 
39
@@ -68,8 +69,18 @@ ovs_logdir(void)
 
40
 const char *
 
41
 ovs_dbdir(void)
 
42
 {
 
43
-    static struct directory d = { NULL, @DBDIR@, "OVS_DBDIR" };
 
44
-    return get_dir(&d);
 
45
+    static const char *dbdir;
 
46
+    if (!dbdir) {
 
47
+        dbdir = getenv("OVS_DBDIR");
 
48
+        if (!dbdir || !dbdir[0]) {
 
49
+            char *sysconfdir = getenv("OVS_SYSCONFDIR");
 
50
+
 
51
+            dbdir = (sysconfdir
 
52
+                     ? xasprintf("%s/openvswitch", sysconfdir)
 
53
+                     : @DBDIR@);
 
54
+        }
 
55
+    }
 
56
+    return dbdir;
 
57
 }
 
58
 
 
59
 const char *
 
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:
 
67
        $(MKDIR_P) python/ovs
 
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)""")') \
 
74
+       sed \
 
75
+               -e '/^##/d' \
 
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
 
88
 ovs-uninstall-local:
 
89
        rm -f $(DESTDIR)$(pkgdatadir)/python/ovs/dirs.py
 
90
+
 
91
+ALL_LOCAL += $(srcdir)/python/ovs/dirs.py
 
92
+$(srcdir)/python/ovs/dirs.py: python/ovs/dirs.py.template
 
93
+       sed \
 
94
+               -e '/^##/d' \
 
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' \
 
101
+               < $? > $@.tmp
 
102
+       mv $@.tmp $@
 
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
 
108
@@ -1,9 +1,13 @@
 
109
-# These are the default directories.  They will be replaced by the
 
110
-# configured directories at install time.
 
111
-
 
112
 import os
 
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""")
 
122
+
 
123
+DBDIR = os.environ.get("OVS_DBDIR")
 
124
+if not DBDIR:
 
125
+    sysconfdir = os.environ.get("OVS_SYSCONFDIR")
 
126
+    if sysconfdir:
 
127
+        DBDIR = "%s/openvswitch" % sysconfdir
 
128
+    else:
 
129
+        DBDIR = """/usr/local/etc/openvswitch"""
 
130
Index: b/python/ovs/dirs.py.template
 
131
===================================================================
 
132
--- /dev/null
 
133
+++ b/python/ovs/dirs.py.template
 
134
@@ -0,0 +1,17 @@
 
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.
 
138
+##
 
139
+import os
 
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@""")
 
144
+
 
145
+DBDIR = os.environ.get("OVS_DBDIR")
 
146
+if not DBDIR:
 
147
+    sysconfdir = os.environ.get("OVS_SYSCONFDIR")
 
148
+    if sysconfdir:
 
149
+        DBDIR = "%s/openvswitch" % sysconfdir
 
150
+    else:
 
151
+        DBDIR = """@DBDIR@"""
 
152
Index: b/utilities/ovs-lib.in
 
153
===================================================================
 
154
--- a/utilities/ovs-lib.in
 
155
+++ b/utilities/ovs-lib.in
 
156
@@ -22,14 +22,21 @@
 
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
 
167
 
 
168
+# /etc/openvswitch or /var/lib/openvswitch
 
169
+if test X"$OVS_DBDIR" != X; then
 
170
+    dbdir=$OVS_DBDIR
 
171
+elif test X"$OVS_SYSCONFDIR" != X; then
 
172
+    dbdir=$OVS_SYSCONFDIR/openvswitch
 
173
+else
 
174
+    dbdir='@DBDIR@'
 
175
+fi
 
176
+
 
177
 VERSION='@VERSION@'
 
178
 case @BUILDNR@ in
 
179
     [1-9]*) BUILDNR='+build@BUILDNR@' ;;