Changeset View
Changeset View
Standalone View
Standalone View
bin/BuildSystem/BuildSystemBase.py
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | 145 | def patchInstallPrefix(self, files : [str], oldPaths : [str]=None, newPath : str=CraftCore.standardDirs.craftRoot()) -> bool: | |||
---|---|---|---|---|---|
146 | if isinstance(oldPaths, str): | 146 | if isinstance(oldPaths, str): | ||
147 | oldPaths = [oldPaths] | 147 | oldPaths = [oldPaths] | ||
148 | elif not oldPaths: | 148 | elif not oldPaths: | ||
149 | oldPaths = [self.subinfo.buildPrefix] | 149 | oldPaths = [self.subinfo.buildPrefix] | ||
150 | for fileName in files: | 150 | for fileName in files: | ||
151 | if not os.path.exists(fileName): | 151 | if not os.path.exists(fileName): | ||
152 | CraftCore.log.warning(f"File {fileName} not found.") | 152 | CraftCore.log.warning(f"File {fileName} not found.") | ||
153 | return False | 153 | return False | ||
154 | with open(fileName, "rt") as f: | 154 | with open(fileName, "rb") as f: | ||
155 | content = f.read() | 155 | content = f.read() | ||
156 | for oldPath in oldPaths: | 156 | for oldPath in oldPaths: | ||
157 | oldPath = oldPath.encode() | ||||
157 | if oldPath in content: | 158 | if oldPath in content: | ||
158 | CraftCore.log.info(f"Patching {fileName}: replacing {oldPath} with {newPath}") | 159 | CraftCore.log.info(f"Patching {fileName}: replacing {oldPath} with {newPath}") | ||
159 | content = content.replace(oldPath, newPath) | 160 | content = content.replace(oldPath, newPath.encode()) | ||
160 | with open(fileName, "wt") as f: | 161 | with open(fileName, "wb") as f: | ||
161 | f.write(content) | 162 | f.write(content) | ||
162 | return True | 163 | return True | ||
163 | 164 | | |||
164 | def internalPostInstall(self): | 165 | def internalPostInstall(self): | ||
165 | if not super().internalPostInstall(): | 166 | if not super().internalPostInstall(): | ||
166 | return False | 167 | return False | ||
167 | # a post install routine to fix the prefix (make things relocatable) | 168 | # a post install routine to fix the prefix (make things relocatable) | ||
168 | pkgconfigPath = os.path.join(self.imageDir(), "lib", "pkgconfig") | 169 | pkgconfigPath = os.path.join(self.imageDir(), "lib", "pkgconfig") | ||
Show All 12 Lines |