Changing patches
Both browsers keep their changes as .patch files in browser/patches/. Never hand-edit a .patch file: edit the source, then write the diff with the repository's tool, which checks that the result applies. The tools differ.
Camoufox's patches apply to an unpacked Firefox source tree. All commands run from the browser folder.
How to make a patch
- Prepare the source tree and mark it as the base for the diff:
make dir && make first-checkpoint- Make changes in the
camoufox-*/folder as needed. You can test your changes withmake buildandmake run. Rungit add -N <file>in that folder for any new file, so the diff includes it. - Write the diff to a patch file:
make diff > patches/my-change.patchHow to work on an existing patch
- Set the workspace to the patch. This reverses the patch if it's applied, checkpoints the tree, and applies it again, so the diff holds only that patch:
make dir && make workspace ./patches/x.patch- Make your changes, then overwrite the patch file:
make diff > patches/x.patchOther commands
| Command | Description |
|---|---|
make patch ./patches/x.patch |
Apply one patch |
make unpatch ./patches/x.patch |
Reverse one patch |
make revert |
Reset the tree to unpatched Firefox |
make grep <string> |
Search the patches for a string |
make help |
List every target |
Porting the patches to a new Firefox version is covered in the patch upgrading guide.
Camouwolf's patches are authored against a mirror of only the Chromium files they touch, fetched at the pinned tag, so you don't need a full Chromium checkout to write one. Authoring against the exact tag is why every patch applies cleanly rather than with fuzz. All commands run from the root of the repository.
- Mirror the pinned tag's copy of the patched files (listed in
browser/scripts/patched-files.txt; add a file there before patching it for the first time), and copy it to a work tree:
bash browser/scripts/fetch-sources.sh
cp -r browser/.pristine/<version> browser/.work- Edit the files in
browser/.work/. - Write the diff to a patch.
mkpatch.pydiffs the work tree against the mirror and checks that the result reverse-applies:
python3 browser/scripts/mkpatch.py 0002-navigator-identity <file> [<file> ...]- Check the series against the pinned tag: the series file is complete, every hunk applies, every Chromium API a patch calls exists, and every config key the browser reads is named by the launcher:
python3 -m ci.run_patch_guardsA new patch also needs its name in browser/patches/series, which sets the order the patches apply in. Then rebuild with bash scripts/build-camouwolf-incremental.sh.
Each patch changes a single surface, so it can be reverted on its own when a Chromium bump breaks it. Every patched accessor falls through to Chromium's own code when its config key is absent, so an unconfigured Camouwolf binary behaves as Chromium. Each patch is described in PATCHES.md.
To move to a new Chromium version, edit version in browser/upstream.sh, run python3 scripts/check-dead-patches.py to test every hunk against the new tag, and reconcile what no longer applies before building.