提交 0c9242bb 编写于 作者: C Cleber Rosa 提交者: Lukáš Doktor

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: NCleber Rosa <crosa@redhat.com>
上级 c629db19
include README.rst
include LICENSE
include Makefile
recursive-include avocado/etc *
recursive-include selftests *
......@@ -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)
......
......@@ -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 <cleber@redhat.com> - 57.0-3
- Move the avocado package config files to the system location
* Tue Dec 19 2017 Cleber Rosa <cleber@redhat.com> - 57.0-2
- Removed patch added on release 1, considering it's upstream
......
......@@ -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'],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册