@@ -49,6 +49,22 @@ def __init__(
4949
5050
5151class InstallerConfig :
52+
53+ # map some detected device codes to their real code.
54+ device_code_mapping = {
55+ # Sony issues
56+ "C6603" : "yuga" ,
57+ # OnePlus issues
58+ "OnePlus6" : "enchilada" ,
59+ "OnePlus6T" : "fajita" ,
60+ "OnePlus7" : "guacamoleb" ,
61+ "OnePlus7Pro" : "guacamole" ,
62+ "OnePlus7T" : "hotdogb" ,
63+ "OnePlus7TPro" : "hotdog" ,
64+ "Nord" : "avicii" ,
65+ "NordN200" : "dre" ,
66+ }
67+
5268 def __init__ (
5369 self ,
5470 unlock_bootloader : List [Step ],
@@ -62,6 +78,10 @@ def __init__(
6278 self .install_os = install_os
6379 self .metadata = metadata
6480 self .requirements = requirements
81+ self .device_code = metadata .get ("devicecode" )
82+ self .alternative_device_code = self .device_code_mapping .get (
83+ self .device_code , self .device_code
84+ )
6585
6686 @classmethod
6787 def from_file (cls , path ):
@@ -107,15 +127,18 @@ def _load_config(device_code: str, config_path: Path) -> Optional[InstallerConfi
107127 Try to load local file in the same directory as the executable first, then load from assets.
108128 """
109129 # try loading a custom local file first
110- custom_path = Path .cwd ().joinpath (Path (f"{ device_code } .yaml" ))
130+ mapped_device_code = InstallerConfig .device_code_mapping .get (
131+ device_code , device_code
132+ )
133+ custom_path = Path .cwd ().joinpath (Path (f"{ mapped_device_code } .yaml" ))
111134 try :
112135 config = InstallerConfig .from_file (custom_path )
113136 logger .info (f"Loaded custom device config from { custom_path } ." )
114137 logger .info (f"Config metadata: { config .metadata } ." )
115138 return config
116139 except FileNotFoundError :
117140 # if no localfile, then try to load a config file from assets
118- path = config_path .joinpath (Path (f"{ device_code } .yaml" ))
141+ path = config_path .joinpath (Path (f"{ mapped_device_code } .yaml" ))
119142 try :
120143 config = InstallerConfig .from_file (path )
121144 logger .info (f"Loaded device config from { path } ." )
0 commit comments