MCPcopy Create free account
hub / github.com/daijro/camoufox / Patcher

Class Patcher

scripts/patch.py:38–187  ·  view source on GitHub ↗

Patch and prepare the Camoufox source

Source from the content-addressed store, hash-verified

36
37def reset_to_unpatched():
38 """Reset this source repository without discovering a parent repository."""
39 if not os.path.exists('.git'):
40 return
41
42 print("Resetting to unpatched state...")
43 run('git reset --hard unpatched && ./mach clobber && git clean -fdx')
44
45
46@dataclass
47class Patcher:
48 """Patch and prepare the Camoufox source"""
49
50 moz_target: str
51 target: str
52
53 def camoufox_patches(self):
54 """
55 Apply all patches
56 """
57 version, release = extract_args()
58 with temp_cd(find_src_dir('.', version, release)):
59 # Reset only when the source tree has its own local repository.
60 reset_to_unpatched()
61
62 # Re-copy additions and settings after reset
63 print("Re-copying additions and settings...")
64 run(f'bash ../scripts/copy-additions.sh {version} {release}')
65
66 # Create the base mozconfig file
67 run('cp -v ../assets/base.mozconfig mozconfig')
68 # Set cross building target
69 print(f'Using target: {self.moz_target}')
70 self._update_mozconfig()
71
72 if not options.mozconfig_only:
73 # Apply patches with roverfox patches at the very end
74 all_patches = list_patches()
75 # Normalize paths and partition into non-roverfox and roverfox
76 non_roverfox = []
77 roverfox = []
78 for p in all_patches:
79 norm = os.path.normpath(p)
80 parts = norm.split(os.sep)
81 if 'roverfox' in parts:
82 roverfox.append(p)
83 else:
84 non_roverfox.append(p)
85
86 # Track patch failures
87 failed_patches = []
88
89 # Apply non-roverfox patches first
90 for patch_file in non_roverfox:
91 rejects = self._apply_and_check(patch_file)
92 if rejects:
93 failed_patches.append((patch_file, rejects))
94
95 # Apply roverfox patches last

Callers 1

patch.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected