From fb572428d4452fe658e3fe744046374671eba2e6 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Fri, 18 May 2012 09:05:55 -0400
Subject: [PATCH 2/2] SSSDConfig: Make default config and schema file
 locations configurable

https://fedorahosted.org/sssd/ticket/1008
---
 Makefile.am                                           |   12 ++++++++----
 configure.ac                                          |    4 +++-
 po/POTFILES.in                                        |    2 +-
 src/config/SSSDConfig/{__init__.py => __init__.py.in} |   12 ++++++------
 src/config/{setup.py => setup.py.in}                  |    2 +-
 5 files changed, 19 insertions(+), 13 deletions(-)
 rename src/config/SSSDConfig/{__init__.py => __init__.py.in} (99%)
 rename src/config/{setup.py => setup.py.in} (97%)

diff --git a/Makefile.am b/Makefile.am
index 2b168ed16c27d3d78d0feaae13064d7262e76d7b..31dbfc54a1373a8343b2b81c466b93fde4b19808 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1440,15 +1440,17 @@ endif !HAVE_DOXYGEN
 
 all-local: ldb_mod_test_dir
 if BUILD_PYTHON_BINDINGS
-	cd $(srcdir)/src/config; $(PYTHON) setup.py build --build-base $(abs_builddir)/src/config
+	-cp $(srcdir)/src/config/SSSDConfig/ipachangeconf.py $(builddir)/src/config/SSSDConfig/
+	-cp $(srcdir)/src/config/SSSDConfig/sssd_upgrade_config.py $(builddir)/src/config/SSSDConfig/
+	cd $(builddir)/src/config; $(PYTHON) setup.py build --build-base $(abs_builddir)/src/config
 endif
 
 install-exec-hook: installsssddirs
 if BUILD_PYTHON_BINDINGS
 	if [ "$(DESTDIR)" = "" ]; then \
-		cd $(srcdir)/src/config; $(PYTHON) setup.py build --build-base $(abs_builddir)/src/config install $(DISTSETUPOPTS) --prefix=$(PYTHON_PREFIX) --record=$(abs_builddir)/src/config/.files; \
+		cd $(builddir)/src/config; $(PYTHON) setup.py build --build-base $(abs_builddir)/src/config install $(DISTSETUPOPTS) --prefix=$(PYTHON_PREFIX) --record=$(abs_builddir)/src/config/.files; \
 	else \
-		cd $(srcdir)/src/config; $(PYTHON) setup.py build --build-base $(abs_builddir)/src/config install $(DISTSETUPOPTS) --prefix=$(PYTHON_PREFIX) --root=$(DESTDIR) --record=$(abs_builddir)/src/config/.files; \
+		cd $(builddir)/src/config; $(PYTHON) setup.py build --build-base $(abs_builddir)/src/config install $(DISTSETUPOPTS) --prefix=$(PYTHON_PREFIX) --root=$(DESTDIR) --record=$(abs_builddir)/src/config/.files; \
 	fi
 endif
 	for doc in $(SSSD_DOCS); do \
@@ -1481,7 +1483,9 @@ uninstall-hook:
 
 clean-local:
 if BUILD_PYTHON_BINDINGS
-	cd $(srcdir)/src/config; $(PYTHON) setup.py build --build-base $(abs_builddir)/src/config clean --all
+	rm -f $(builddir)/src/config/SSSDConfig/ipachangeconf.py
+	rm -f $(builddir)/src/config/SSSDConfig/sssd_upgrade_config.py
+	cd $(builddir)/src/config; $(PYTHON) setup.py build --build-base $(abs_builddir)/src/config clean --all
 endif
 	for doc in $(SSSD_DOCS); do \
 		rm -Rf $$doc; \
diff --git a/configure.ac b/configure.ac
index 1ca53b5232823dcc92fca893006694a3c79776af..d4647d8a0ad8e7e2555b97b13acee114e9a81a65 100644
--- a/configure.ac
+++ b/configure.ac
@@ -250,5 +250,7 @@ AC_CONFIG_FILES([Makefile contrib/sssd.spec src/examples/rwtab src/doxy.config
                  src/providers/ipa/ipa_hbac.pc src/providers/ipa/ipa_hbac.doxy
                  src/lib/idmap/sss_idmap.pc src/lib/idmap/sss_idmap.doxy
                  src/sss_client/sudo/libsss_sudo.pc
-                 src/sss_client/sudo/sss_sudo.doxy])
+                 src/sss_client/sudo/sss_sudo.doxy
+                 src/config/setup.py
+                 src/config/SSSDConfig/__init__.py])
 AC_OUTPUT
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 24da6c25a33e410527f43e6c57f8d022e6592991..ee532def223fdd5db632ad98fd11a57e38d0e125 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,6 @@
 # List of source files which contain translatable strings.
 src/confdb/confdb_setup.c
-src/config/SSSDConfig/__init__.py
+src/config/SSSDConfig/__init__.py.in
 src/monitor/monitor.c
 src/providers/krb5/krb5_child.c
 src/providers/ldap/ldap_child.c
diff --git a/src/config/SSSDConfig/__init__.py b/src/config/SSSDConfig/__init__.py.in
similarity index 99%
rename from src/config/SSSDConfig/__init__.py
rename to src/config/SSSDConfig/__init__.py.in
index 11da7cf2ba42076f3088cbbff81b69b39a0dc449..e594713b71c35b2766ad3e404431d9659f941d30 100644
--- a/src/config/SSSDConfig/__init__.py
+++ b/src/config/SSSDConfig/__init__.py.in
@@ -338,9 +338,9 @@ class SSSDConfigSchema(SSSDChangeConf):
         SSSDChangeConf.__init__(self)
         #TODO: get these from a global setting
         if not schemafile:
-            schemafile = '/usr/share/sssd/sssd.api.conf'
+            schemafile = '@datadir@/sssd/sssd.api.conf'
         if not schemaplugindir:
-            schemaplugindir = '/usr/share/sssd/sssd.api.d'
+            schemaplugindir = '@datadir@/sssd/sssd.api.d'
 
         try:
             #Read the primary config file
@@ -1242,10 +1242,10 @@ class SSSDConfig(SSSDChangeConf):
 
         schemafile:
           The path to the api schema config file. Usually
-          /usr/share/sssd/sssd.api.conf
+          @datadir@/sssd/sssd.api.conf
         schemaplugindir:
           The path the directory containing the provider schema config files.
-          Usually /usr/share/sssd/sssd.api.d
+          Usually @datadir@/sssd/sssd.api.d
 
         === Returns ===
         The newly-created SSSDConfig object.
@@ -1271,7 +1271,7 @@ class SSSDConfig(SSSDChangeConf):
 
         configfile:
           The path to the SSSD config file. If not specified, use the system
-          default, usually /etc/sssd/sssd.conf
+          default, usually @sysconfdir@/sssd.conf
 
         === Returns ===
         No return value
@@ -1290,7 +1290,7 @@ class SSSDConfig(SSSDChangeConf):
 
         if not configfile:
             #TODO: get this from a global setting
-            configfile = '/etc/sssd/sssd.conf'
+            configfile = '@sysconfdir@/sssd.conf'
         # open will raise an IOError if it fails
         fd = open(configfile, 'r')
 
diff --git a/src/config/setup.py b/src/config/setup.py.in
similarity index 97%
rename from src/config/setup.py
rename to src/config/setup.py.in
index d3617e13db6a204c02492471698ce777cf6565e3..4d5f0e8932e3e3faff2aa7559b9594aefbead9e2 100644
--- a/src/config/setup.py
+++ b/src/config/setup.py.in
@@ -25,7 +25,7 @@ from distutils.core import setup
 
 setup(
     name='SSSDConfig',
-    version='1',
+    version='@VERSION@',
     license='GPLv3+',
     url='http://fedorahosted.org/sssd',
     packages=['SSSDConfig'],
-- 
1.7.10.1

