Skip to content

Commit e94a000

Browse files
committed
docs: add squid patch application documentation
Add comprehensive documentation for the squid patch application system, detailing directory structure, selection rules, priority ordering, and build behavior with examples.
1 parent 6a2c185 commit e94a000

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

docs/squid-patches.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Squid Patches
2+
3+
This project supports applying version-specific patches during the Docker build.
4+
Patches are discovered under `/src/patch` (copied from the local `patch/` directory)
5+
and applied in a deterministic order based on Squid version, specificity, and
6+
priority.
7+
8+
## Directory layout
9+
10+
Use the following structure for patch files:
11+
12+
```text
13+
patch/
14+
v6/
15+
10_fix-foo.patch
16+
20 fix-bar.patch
17+
1/
18+
10_fix-foo.patch
19+
30_add-baz.patch
20+
2/
21+
05_critical.patch
22+
```
23+
24+
The build maps `SQUID_VERSION` to a patch base directory:
25+
26+
- Major only: `patch/v<major>/` (e.g. `patch/v7/`)
27+
- Major + minor: `patch/v<major>/<minor>/` (e.g. `patch/v7/4/`)
28+
- Major + minor + patch: `patch/v<major>/<minor>/<patch>/` (e.g. `patch/v7/4/1/`)
29+
30+
## Selection rules
31+
32+
1. **Specificity wins**: patches for `major.minor.patch` override `major.minor`,
33+
which override `major` when file names match.
34+
2. **De-duplication by filename**: if `a.patch` exists in both `v7/` and
35+
`v7/4/`, only the more specific file (`v7/4/a.patch`) is applied.
36+
3. **Priority order (descending)**: files are applied by numeric prefix:
37+
- `10_a.patch` or `10 a.patch`
38+
- higher numbers apply first
39+
- files without a numeric prefix default to priority `0`
40+
41+
## Applying order
42+
43+
Patches are collected in this order:
44+
45+
1. `patch/v<major>/<minor>/<patch>/`
46+
2. `patch/v<major>/<minor>/`
47+
3. `patch/v<major>/`
48+
49+
Within the final selection set, patches are applied by **priority descending**.
50+
51+
## Build behavior
52+
53+
- Each patch file is logged before application.
54+
- Patches are applied with `patch -p1 --forward --batch` for idempotent,
55+
non-interactive operation.
56+
- Any failed patch **fails the build immediately**.
57+
- Missing version directories are skipped gracefully.
58+
59+
## Examples
60+
61+
Given:
62+
63+
- `SQUID_VERSION=7.4.1`
64+
- `patch/v7/a.patch`
65+
- `patch/v7/4/a.patch`
66+
- `patch/v7/4/1/05_hotfix.patch`
67+
- `patch/v7/4/1/10_feature.patch`
68+
69+
Applied patches:
70+
71+
1. `10_feature.patch` (priority 10)
72+
2. `05_hotfix.patch` (priority 5)
73+
3. `a.patch` from `v7/4/` (overrides `v7/a.patch`)

0 commit comments

Comments
 (0)