|
17 | 17 | # along with this program; if not, write to the Free Software |
18 | 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | 19 |
|
| 20 | +import os |
20 | 21 | import yaml |
21 | 22 | from snagrecover.utils import ( |
22 | 23 | cli_error, |
@@ -76,6 +77,20 @@ def check_soc_model(soc_model: str): |
76 | 77 | return None |
77 | 78 |
|
78 | 79 |
|
| 80 | +def patch_firmware_image_paths(fw_config: dict, this_file_path: str) -> dict: |
| 81 | + paths_relative_to_conf = fw_config.pop("paths-relative-to", "CWD") |
| 82 | + if paths_relative_to_conf == "CWD": |
| 83 | + path_relative_to = os.getcwd() |
| 84 | + elif paths_relative_to_conf == "THIS_FILE": |
| 85 | + path_relative_to = os.path.dirname(this_file_path) |
| 86 | + else: |
| 87 | + path_relative_to = path_relative_to_conf |
| 88 | + |
| 89 | + for binary in fw_config.keys(): |
| 90 | + if "path" in fw_config[binary]: |
| 91 | + fw_config[binary]["path"] = os.path.join(path_relative_to, fw_config[binary]["path"]) |
| 92 | + |
| 93 | + |
79 | 94 | def init_config(args: list): |
80 | 95 | # this is the only time that config.recovery_config should be modified! |
81 | 96 | # get soc model |
@@ -127,6 +142,7 @@ def init_config(args: list): |
127 | 142 | cli_error( |
128 | 143 | f"firmware config passed to CLI did not evaluate to dict: {fw_configs}" |
129 | 144 | ) |
| 145 | + fw_config_file = patch_firmware_image_paths(fw_config_file, path) |
130 | 146 | fw_configs = {**fw_configs, **fw_config_file} |
131 | 147 | recovery_config["firmware"] = fw_configs |
132 | 148 |
|
|
0 commit comments