Closed gerases closed 5 months ago
???
While mock -r foo
searches for the files you mentioned, you can still use mock -r some/path/foo.cfg
and mock will use this full path.
When the parameter has suffix .cfg it is interpreted as a path.
Is this sufficient for you?
So I have the main configuration files (e.g. centos7) under /etc/mock
and mock is already called with something like -r /etc/mock/centos7
.
Now, if I want to tweak something without changing that system wide config, I could override a config opt by putting my them into ~/.config/mock.cfg
, right? But that's not great for my case because each of my builds may require a different override and I would have to change ~/.config/mock.cfg
for each custom build, no?
If the above is how it works, then I would like to instruct mock to look into an additional place for the overrides - via an environment variable perhaps.
Let me know if this makes sense or not
Here's what I'm proposing:
diff --git a/mock/py/mockbuild/config.py b/mock/py/mockbuild/config.py
index 2178c5b7..0f8116f0 100644
--- a/mock/py/mockbuild/config.py
+++ b/mock/py/mockbuild/config.py
@@ -891,6 +891,9 @@ def load_config(config_path, name):
cfg = os.path.join(os.path.expanduser(
'~' + pwd.getpwuid(os.getuid())[0]), '.config/mock.cfg')
do_update_config(log, config_opts, cfg, name)
+ cfg = os.environ.get("MOCK_CFG_PATH", None)
+ if cfg:
+ do_update_config(log, config_opts, cfg, name)
I understand what you are trying to achieve. But I think this add unnecessary complexity to Mock.
You can achieve the same by
$ cat ~/my/configs/for/tests/one.cfg
include('/etc/mock/centos+epel-7-x86_64.cfg')
#your specific overrides
config_opts['foo1'] = 'bar1'
$ cat ~/my/configs/for/tests/two.cfg
include('/etc/mock/centos+epel-7-x86_64.cfg')
#your specific overrides
config_opts['foo2'] = 'bar2'
$ WHAT=one
$ mock -r ~/my/configs/for/tests/${WHAT}.cfg some.src.rpm
or
$ cat ~/testdir1/centos7.cfg
include('/etc/mock/centos+epel-7-x86_64.cfg')
#your specific overrides
config_opts['foo1'] = 'bar1'
$ cat ~/testdir2/centos7.cfg
include('/etc/mock/centos+epel-7-x86_64.cfg')
#your specific overrides
config_opts['foo2'] = 'bar2'
$ WHAT=testdir2
$ mock -r ~/${WHAT}/centos7.cfg some.src.rpm
The last one does exactly what you are trying to achieve. Right?
Or, can you use something like this wrapper?
$ cat ~/bin/mymock
#! /bin/sh
test -n "$MOCK_CFG_PATH" && exec mock -r "$MOCK_CFG_PATH" "$@"
exec mock "$@"
I understand what you are trying to achieve. But I think this add unnecessary complexity to Mock.
You can achieve the same by
$ cat ~/my/configs/for/tests/one.cfg include('/etc/mock/centos+epel-7-x86_64.cfg') #your specific overrides config_opts['foo1'] = 'bar1' $ cat ~/my/configs/for/tests/two.cfg include('/etc/mock/centos+epel-7-x86_64.cfg') #your specific overrides config_opts['foo2'] = 'bar2' $ WHAT=one $ mock -r ~/my/configs/for/tests/${WHAT}.cfg some.src.rpm
or
$ cat ~/testdir1/centos7.cfg include('/etc/mock/centos+epel-7-x86_64.cfg') #your specific overrides config_opts['foo1'] = 'bar1' $ cat ~/testdir2/centos7.cfg include('/etc/mock/centos+epel-7-x86_64.cfg') #your specific overrides config_opts['foo2'] = 'bar2' $ WHAT=testdir2 $ mock -r ~/${WHAT}/centos7.cfg some.src.rpm
The last one does exactly what you are trying to achieve. Right?
Ah yeah this could work indeed. The problem include directive is crucial here. I can go with this and post here in case there’s some unexpected complication. Thank you!!
i am closing this for now.
Ability to specify location of the user mock.cfg with an environmental variable
I would like to be able to specify an additional location for the user-based mock.cfg file based on an environmental variable. Currently these locations are:
The reason is that I have tens of projects with different customizations and unless it's done it's difficult to manage.