1 |
This commit adds deep copying operations when initializing config
|
2 |
objects from a default config. This prevents the config from being
|
3 |
a shallow copy of the default, ensuring that modifications to the
|
4 |
config do not modify the default.
|
5 |
|
6 |
In particular, this fixes a check in write_make_conf, where the PORTDIR
|
7 |
variable is only written to the generated make.conf when a non-default
|
8 |
repo_basedir is set in /etc/catalyst/catalyst.conf. This check is never
|
9 |
satisfied, because confvalues is a shallow copy of confdefaults,
|
10 |
therefore both will always hold the same value for repo_basedir.
|
11 |
|
12 |
For self.mounts / MOUNT_DEFAULTS this problem can also be observed, the
|
13 |
modifications done to self.mounts are also visible in MOUNT_DEFAULTS.
|
14 |
I am not aware of any bugs due to this shallow copy, but I would prefer
|
15 |
adding a deep copy to prevent future bugs, in case a comparision
|
16 |
against the default mounts is ever needed.
|
17 |
---
|
18 |
catalyst/base/stagebase.py | 3 ++-
|
19 |
catalyst/main.py | 3 ++-
|
20 |
2 files changed, 4 insertions(+), 2 deletions(-)
|
21 |
|
22 |
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
|
23 |
index df1cb844..ac0f4f24 100644
|
24 |
--- a/catalyst/base/stagebase.py
|
25 |
+++ b/catalyst/base/stagebase.py
|
26 |
@@ -1,4 +1,5 @@
|
27 |
|
28 |
+import copy
|
29 |
import os
|
30 |
import platform
|
31 |
import shutil
|
32 |
@@ -183,7 +184,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
|
33 |
file_locate(self.settings, ["portage_confdir"], expand=0)
|
34 |
|
35 |
# Setup our mount points.
|
36 |
- self.mount = MOUNT_DEFAULTS.copy()
|
37 |
+ self.mount = copy.deepcopy(MOUNT_DEFAULTS)
|
38 |
|
39 |
self.mount['portdir']['source'] = self.snapshot
|
40 |
self.mount['portdir']['target'] =
|
41 |
self.settings['repo_basedir'] + '/' + self.settings['repo_name']
|
42 |
diff --git a/catalyst/main.py b/catalyst/main.py
|
43 |
index 543895c6..8e0bc5fb 100644
|
44 |
--- a/catalyst/main.py
|
45 |
+++ b/catalyst/main.py
|
46 |
@@ -1,4 +1,5 @@
|
47 |
import argparse
|
48 |
+import copy
|
49 |
import datetime
|
50 |
import hashlib
|
51 |
import os
|
52 |
@@ -20,7 +21,7 @@ from catalyst.defaults import (confdefaults,
|
53 |
option_messages,
|
54 |
from catalyst.support import CatalystError
|
55 |
from catalyst.version import get_version
|
56 |
|
57 |
-conf_values = confdefaults
|
58 |
+conf_values = copy.deepcopy(confdefaults)
|
59 |
|
60 |
|
61 |
def version():
|
62 |
--
|
63 |
2.28.0 |