| |
@@ -25,6 +25,7 @@
|
| |
import os.path
|
| |
import re
|
| |
import shlex
|
| |
+ import mockbuild.util
|
| |
|
| |
from glob import glob
|
| |
from subprocess import call, Popen, PIPE, STDOUT, CalledProcessError
|
| |
@@ -119,7 +120,9 @@
|
| |
|
| |
def _setup_default_config_opts():
|
| |
""" sets up default configuration. """
|
| |
- config_opts = {}
|
| |
+ config_opts = mockbuild.util.TemplatedDictionary()
|
| |
+ config_opts['__jinja_expand'] = True
|
| |
+ config_opts['config_paths'] = []
|
| |
config_opts['basedir'] = '/var/lib/mock' # root name is automatically added to this
|
| |
config_opts['resultdir'] = '%(basedir)s/%(root)s/result'
|
| |
config_opts['cache_topdir'] = '/var/cache/mock'
|
| |
@@ -375,6 +378,23 @@
|
| |
raise ReviewError("Can't build x86_64 on i86 host")
|
| |
return macros
|
| |
|
| |
+ def process_include(self, config_file, config_opts):
|
| |
+ str_mx = re.compile(r'^\s*include\((.*)\)')
|
| |
+ if os.path.exists(config_file):
|
| |
+ if config_file in config_opts['config_paths']:
|
| |
+ raise exception.ConfigError("Multiple inclusion of %s" % config_file)
|
| |
+ config_opts['config_paths'].append(config_file)
|
| |
+ with open(config_file) as f:
|
| |
+ content = f.read()
|
| |
+ res = str_mx.search(content)
|
| |
+ if res is not None:
|
| |
+ sub_config_file = eval(res.groups()[0])
|
| |
+ sub_content = self.process_include(sub_config_file, config_opts)
|
| |
+ content = re.sub(r'^\s*nclude\(.*\)', sub_content, content, count=1)
|
| |
+ return content
|
| |
+ else:
|
| |
+ raise exception.ConfigError("Could not find included config file: %s" % config_file)
|
| |
+
|
| |
def _get_root(self):
|
| |
""" Return mock's root according to Settings. """
|
| |
config = "default"
|
| |
@@ -388,14 +408,12 @@
|
| |
)
|
| |
|
| |
config_opts = _setup_default_config_opts()
|
| |
- with open(path) as f:
|
| |
- content = f.read()
|
| |
- content = re.sub(r'include\((.*)\)',
|
| |
- r'exec(open(\g<1>).read(), {}, locals())',
|
| |
- content)
|
| |
- config = compile(content, path, 'exec')
|
| |
- exec(config)
|
| |
+ #config_opts = mockbuild.util.setup_default_config_opts(None, "unknown",
|
| |
+ # "/usr/lib/python3.7/site-packages/mockbuild/")
|
| |
+ content = self.process_include(path, config_opts)
|
| |
+ exec(content)
|
| |
self.mock_root = config_opts["root"]
|
| |
+ print ("self.mock_root = %s" % self.mock_root)
|
| |
if Settings.uniqueext:
|
| |
self.mock_root += Settings.uniqueext
|
| |
|
| |
A Quick fix , which works I will discuss with mock development a way to use mockbuild.utils for now is now possible for some function so this commit is more a copy of mock code , but I have done some on my own , also I will review my own code with mock development .