From 0c9242bb586ccc4d5396e261688644d00435172c Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Wed, 10 Jan 2018 20:15:33 -0500 Subject: [PATCH] Packaging: make config files data files of the avocado module In a pure Python world[1] the "avocado" module requires the existence of these configuration files. Let's make those configuration files "data files" of that module. Since the configuration location can now be a different, the settings module needs adjustments to also attempt to load them from package resources (which is tied to the data files). Finally, when using RPM packages, we need to put the configuration back into the system location (/etc). [1] - that is, ignoring operating system or distribution specific conventions and packaging technologies Signed-off-by: Cleber Rosa --- MANIFEST.in | 1 + avocado/core/settings.py | 13 ++++++++++--- {etc => avocado/etc}/avocado/avocado.conf | 0 {etc => avocado/etc}/avocado/conf.d/README | 0 {etc => avocado/etc}/avocado/conf.d/gdb.conf | 0 {etc => avocado/etc}/avocado/conf.d/jobscripts.conf | 0 .../etc}/avocado/conf.d/result_upload.conf | 0 {etc => avocado/etc}/avocado/conf.d/resultsdb.conf | 0 .../etc}/avocado/scripts/job/post.d/README | 0 .../etc}/avocado/scripts/job/pre.d/README | 0 {etc => avocado/etc}/avocado/sysinfo/commands | 0 {etc => avocado/etc}/avocado/sysinfo/files | 0 {etc => avocado/etc}/avocado/sysinfo/profilers | 0 python-avocado.spec | 6 +++++- setup.py | 12 ++---------- 15 files changed, 18 insertions(+), 14 deletions(-) rename {etc => avocado/etc}/avocado/avocado.conf (100%) rename {etc => avocado/etc}/avocado/conf.d/README (100%) rename {etc => avocado/etc}/avocado/conf.d/gdb.conf (100%) rename {etc => avocado/etc}/avocado/conf.d/jobscripts.conf (100%) rename {etc => avocado/etc}/avocado/conf.d/result_upload.conf (100%) rename {etc => avocado/etc}/avocado/conf.d/resultsdb.conf (100%) rename {etc => avocado/etc}/avocado/scripts/job/post.d/README (100%) rename {etc => avocado/etc}/avocado/scripts/job/pre.d/README (100%) rename {etc => avocado/etc}/avocado/sysinfo/commands (100%) rename {etc => avocado/etc}/avocado/sysinfo/files (100%) rename {etc => avocado/etc}/avocado/sysinfo/profilers (100%) diff --git a/MANIFEST.in b/MANIFEST.in index 83bc1cf2..44602140 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include README.rst include LICENSE include Makefile +recursive-include avocado/etc * recursive-include selftests * diff --git a/avocado/core/settings.py b/avocado/core/settings.py index 9a634957..5c10b3b5 100644 --- a/avocado/core/settings.py +++ b/avocado/core/settings.py @@ -25,6 +25,7 @@ try: except ImportError: import configparser as ConfigParser +from pkg_resources import resource_exists, resource_filename from six import string_types from ..utils import path @@ -40,7 +41,8 @@ _config_dir_system = os.path.join(CFG_DIR, 'avocado') _config_dir_system_extra = os.path.join(CFG_DIR, 'avocado', 'conf.d') _config_dir_local = os.path.join(USER_DIR, '.config', 'avocado') _source_tree_root = os.path.join(sys.modules[__name__].__file__, "..", "..", "..") -_config_path_intree = os.path.join(os.path.abspath(_source_tree_root), 'etc', 'avocado') +_config_path_intree = os.path.join(os.path.abspath(_source_tree_root), + 'avocado', 'etc', 'avocado') _config_path_intree_extra = os.path.join(_config_path_intree, 'conf.d') config_filename = 'avocado.conf' @@ -171,10 +173,15 @@ class Settings(object): config_local = os.path.exists(config_path_local) config_intree = os.path.exists(config_path_intree) config_intree_extra = os.path.exists(_config_path_intree_extra) - if (not config_system) and (not config_local) and (not config_intree): + config_pkg_base = os.path.join('etc', config_filename) + config_pkg = resource_exists('avocado', config_pkg_base) + config_path_pkg = resource_filename('avocado', config_pkg_base) + if not (config_system or config_local or + config_intree or config_pkg): raise ConfigFileNotFound([config_path_system, config_path_local, - config_path_intree]) + config_path_intree, + config_path_pkg]) if config_intree: # In this case, respect only the intree config self.process_config_path(config_path_intree) diff --git a/etc/avocado/avocado.conf b/avocado/etc/avocado/avocado.conf similarity index 100% rename from etc/avocado/avocado.conf rename to avocado/etc/avocado/avocado.conf diff --git a/etc/avocado/conf.d/README b/avocado/etc/avocado/conf.d/README similarity index 100% rename from etc/avocado/conf.d/README rename to avocado/etc/avocado/conf.d/README diff --git a/etc/avocado/conf.d/gdb.conf b/avocado/etc/avocado/conf.d/gdb.conf similarity index 100% rename from etc/avocado/conf.d/gdb.conf rename to avocado/etc/avocado/conf.d/gdb.conf diff --git a/etc/avocado/conf.d/jobscripts.conf b/avocado/etc/avocado/conf.d/jobscripts.conf similarity index 100% rename from etc/avocado/conf.d/jobscripts.conf rename to avocado/etc/avocado/conf.d/jobscripts.conf diff --git a/etc/avocado/conf.d/result_upload.conf b/avocado/etc/avocado/conf.d/result_upload.conf similarity index 100% rename from etc/avocado/conf.d/result_upload.conf rename to avocado/etc/avocado/conf.d/result_upload.conf diff --git a/etc/avocado/conf.d/resultsdb.conf b/avocado/etc/avocado/conf.d/resultsdb.conf similarity index 100% rename from etc/avocado/conf.d/resultsdb.conf rename to avocado/etc/avocado/conf.d/resultsdb.conf diff --git a/etc/avocado/scripts/job/post.d/README b/avocado/etc/avocado/scripts/job/post.d/README similarity index 100% rename from etc/avocado/scripts/job/post.d/README rename to avocado/etc/avocado/scripts/job/post.d/README diff --git a/etc/avocado/scripts/job/pre.d/README b/avocado/etc/avocado/scripts/job/pre.d/README similarity index 100% rename from etc/avocado/scripts/job/pre.d/README rename to avocado/etc/avocado/scripts/job/pre.d/README diff --git a/etc/avocado/sysinfo/commands b/avocado/etc/avocado/sysinfo/commands similarity index 100% rename from etc/avocado/sysinfo/commands rename to avocado/etc/avocado/sysinfo/commands diff --git a/etc/avocado/sysinfo/files b/avocado/etc/avocado/sysinfo/files similarity index 100% rename from etc/avocado/sysinfo/files rename to avocado/etc/avocado/sysinfo/files diff --git a/etc/avocado/sysinfo/profilers b/avocado/etc/avocado/sysinfo/profilers similarity index 100% rename from etc/avocado/sysinfo/profilers rename to avocado/etc/avocado/sysinfo/profilers diff --git a/python-avocado.spec b/python-avocado.spec index d91278c3..66451fce 100644 --- a/python-avocado.spec +++ b/python-avocado.spec @@ -29,7 +29,7 @@ Summary: Framework with tools and libraries for Automated Testing Name: python-%{srcname} Version: 57.0 -Release: 2%{?gitrel}%{?dist} +Release: 3%{?gitrel}%{?dist} License: GPLv2 Group: Development/Tools URL: http://avocado-framework.github.io/ @@ -151,6 +151,7 @@ popd %install %{__python} setup.py install --root %{buildroot} --skip-build +%{__mv} %{buildroot}%{python_sitelib}/avocado/etc %{buildroot} pushd optional_plugins/html %{__python} setup.py install --root %{buildroot} --skip-build popd @@ -440,6 +441,9 @@ examples of how to write tests on your own. %{_datadir}/avocado/varianter_pict %changelog +* Sat Jan 6 2018 Cleber Rosa - 57.0-3 +- Move the avocado package config files to the system location + * Tue Dec 19 2017 Cleber Rosa - 57.0-2 - Removed patch added on release 1, considering it's upstream diff --git a/setup.py b/setup.py index 1ef32568..59b50210 100755 --- a/setup.py +++ b/setup.py @@ -59,16 +59,7 @@ def get_avocado_libexec_dir(): def get_data_files(): - data_files = [(get_dir(['etc', 'avocado']), ['etc/avocado/avocado.conf'])] - data_files += [(get_dir(['etc', 'avocado', 'conf.d']), - ['etc/avocado/conf.d/README', 'etc/avocado/conf.d/gdb.conf'])] - data_files += [(get_dir(['etc', 'avocado', 'sysinfo']), - ['etc/avocado/sysinfo/commands', 'etc/avocado/sysinfo/files', - 'etc/avocado/sysinfo/profilers'])] - data_files += [(get_dir(['etc', 'avocado', 'scripts', 'job', 'pre.d']), - ['etc/avocado/scripts/job/pre.d/README'])] - data_files += [(get_dir(['etc', 'avocado', 'scripts', 'job', 'post.d']), - ['etc/avocado/scripts/job/post.d/README'])] + data_files = [] data_files += [(get_tests_dir(), glob.glob('examples/tests/*.py'))] data_files += [(get_tests_dir(), glob.glob('examples/tests/*.sh'))] for data_dir in glob.glob('examples/tests/*.data'): @@ -157,6 +148,7 @@ if __name__ == '__main__': "Programming Language :: Python :: 2.7", ], packages=find_packages(exclude=('selftests*',)), + include_package_data=True, data_files=get_data_files(), scripts=['scripts/avocado', 'scripts/avocado-rest-client'], -- GitLab