This directory keeps reproducible source snapshots for third-party libraries. Each library snapshot is derived from:
- an upstream Git URL;
- an exact upstream commit hash;
- an ordered local patch series.
The tracked library directories are snapshots, not working repositories. Use
_work/ for local Git commits and _cache/ for upstream mirrors.
set-library-source.sh
|
v
+---------------------------+
| _manifests/<name>.env | tracked input
| NAME, URL, REVISION, |
| PATCH_DIR |
+-------------+-------------+
|
| checkout-library.sh / restore-library.sh
v
+---------------------------+
| _cache/<name>.git | ignored upstream mirror
+-------------+-------------+
|
v
+---------------------------+
| _work/<name>/ | ignored editable Git worktree
+-------------+-------------+
|
commits | publish-library.sh
v
+---------------------------+
| _patches/<series>/*.patch | tracked local patch series
+-------------+-------------+
|
| restore-library.sh / publish-library.sh
v
+---------------------------+
| <name>/ | tracked source snapshot
+---------------------------+
| Path | Tracked | Role | Created or overwritten by |
|---|---|---|---|
_manifests/<name>.env |
yes | Source of truth for NAME, URL, REVISION, and PATCH_DIR. |
set-library-source.sh |
_patches/<series>/ |
yes | Local commits exported with git format-patch. Empty series are valid. |
publish-library.sh overwrites the selected series |
<name>/ |
yes | Materialized source snapshot used by builds. Never edit directly. | restore-library.sh, publish-library.sh |
_cache/<name>.git |
no | Bare mirror of the upstream repository. | Any command that needs upstream objects |
_work/<name>/ |
no | Editable Git worktree for local patch commits. | checkout-library.sh, restore-library.sh |
_tools/*.sh |
yes | Maintenance commands. | Edited manually with normal repository changes |
_tools/common.sh |
yes | Shared implementation sourced by commands. Not an entrypoint. | Edited manually with normal repository changes |
NAME=<library-name>
URL=https://example.org/upstream.git
REVISION=<40-character-upstream-commit-hash>
PATCH_DIR=_patches/<patch-series-name>
NAMEselects_cache/<name>.git,_work/<name>/, and<name>/.URLmust be an HTTPS Git URL ending in.git.REVISIONis the upstream base commit. Local patches are applied on top.PATCH_DIRis a relative path under_patches/. It may differ fromNAMEwhen one upstream snapshot needs alternate patch series.
Run commands from vendor/ unless shown otherwise.
| Command | Inputs | Overwrites or creates | Does not change |
|---|---|---|---|
./_tools/set-library-source.sh <name> <url> <revision> [patch-dir] |
CLI arguments, upstream Git repository | _cache/<name>.git, _manifests/<name>.env, selected patch directory if missing |
<name>/, _work/<name>/, existing patches |
./_tools/checkout-library.sh <name> |
Manifest, upstream cache, selected patch series | _cache/<name>.git, _work/<name>/ |
<name>/, _patches/<series>/ |
./_tools/restore-library.sh <name> |
Manifest, upstream cache, selected patch series | _cache/<name>.git, _work/<name>/, <name>/ |
_patches/<series>/ |
./_tools/publish-library.sh <name> |
Manifest, clean _work/<name>/ |
_patches/<series>/, <name>/ |
_manifests/<name>.env, _cache/<name>.git |
Important overwrite points:
checkout-library.shdeletes and recreates_work/<name>/.restore-library.shdeletes and recreates both_work/<name>/and<name>/.publish-library.shdeletes and recreates the selectedPATCH_DIR, then refreshes<name>/.publish-library.shrefuses to run if_work/<name>/has uncommitted or untracked changes.
cd vendor
./_tools/set-library-source.sh <name> <git-url> <40-char-commit-hash>
./_tools/restore-library.sh <name>This creates the manifest, creates an empty patch directory, and materializes
<name>/.
cd vendor
./_tools/set-library-source.sh <name> <git-url> <40-char-commit-hash> _patches/<series>
./_tools/restore-library.sh <name>Use this when the patch series name intentionally differs from the library name, for example to keep alternate compatibility series.
cd vendor
./_tools/checkout-library.sh <name>
cd _work/<name>
git add -- <paths>
git commit -m "Describe one local change"
cd ../..
./_tools/publish-library.sh <name>
./_tools/restore-library.sh <name>Keep one logical local change per commit. The commit subject and body become the patch explanation, so write them as permanent maintenance notes.
cd vendor
./_tools/restore-library.sh <name>Use this to verify that a tracked snapshot can be reproduced from
_manifests/ and _patches/ alone.
| Question | Look here |
|---|---|
| Which upstream repository and commit are used? | _manifests/<name>.env |
| Which patch series is active? | PATCH_DIR in _manifests/<name>.env |
| Why does a local change exist? | Patch commit message in _patches/<series>/*.patch |
| What will be committed to the main repository? | _manifests/, _patches/, and <name>/ |
| What is safe to delete locally? | _cache/ and _work/; scripts can recreate them |
Why did git am fail? |
The failing patch in _patches/<series>/ and the upstream REVISION |
Why did publish-library.sh fail? |
git -C _work/<name> status --short; the worktree must be clean |
Why does git diff --check mention patch files? |
Patch files may contain intentional diff syntax such as + or -- ; check whether the problem is in source content or only in patch metadata |
- Do not edit tracked snapshots in
<name>/directly; edit_work/<name>/and publish. - Do not edit generated patch files by hand; rebuild them through
publish-library.sh. - Do not commit
_work/,_cache/, build outputs, or nested.gitdirectories. - Keep patch series ordered from foundational build/runtime changes to narrower model or compatibility changes.
- Keep library-specific rationale in patch commit messages, not in this generic workflow document.