Skip to content

Commit 7908127

Browse files
committed
Docs
1 parent 25bda8d commit 7908127

File tree

4 files changed

+76
-2
lines changed

4 files changed

+76
-2
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@ bake --image-version 0.0.0-dev
5555
The GitHub action called `Build (and optionally publish) 0.0.0-dev images` can be triggered manually to do build all images in all versions.
5656
When triggered manually it will _not_ push the images to the registry.
5757

58+
## Patches
59+
60+
Many products apply Stackable-specific patches, managed by [Patchable](rust/patchable).
61+
62+
### Check out patched sources locally
63+
64+
This is not required for building the images, but is useful when debugging or hacking on our patch sets.
65+
66+
```sh
67+
cargo patchable checkout druid 26.0.0
68+
```
69+
70+
### Save patched sources
71+
72+
```sh
73+
cargo patchable export druid 26.0.0
74+
```
75+
5876
## Verify Product Images
5977

6078
To verify if Apache Zookeeper validate against OpenShift preflight, run:

rust/patchable/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Patchable
2+
3+
Patchable is a tool for managing patches for the third-party products distributed by Stackable as part of the Stackable Data Platform.
4+
5+
Patchable works by keeping a series of .patch files (in `docker-images/<PRODUCT>/stackable/patches/<VERSION>`)
6+
as its source of truth, but using temporary Git repositories as an interface to modify those patches.
7+
This lets us track the history of patches over time, but reuse the existing familiarity and tooling around Git.
8+
9+
Patchable designates a commit as the upstream _base_ for each version, and considers each commit made on top of that
10+
to be an individual patch.
11+
12+
## Usage
13+
14+
```sh
15+
cargo patchable checkout druid 26.0.0
16+
pushd $(git rev-parse --show-toplevel)/druid/patchable-work/worktree/26.0.0/
17+
# do stuff
18+
git commit
19+
popd
20+
cargo patchable export druid 26.0.0
21+
git status
22+
```
23+
24+
For more details, run `cargo patchable --help`.
25+
26+
## Notes
27+
28+
- patchable only supports linear patch series (no merges beyond the base commit)
29+
- patchable doesn't support support merging "materialized" trees, merge the .patch files instead, and `checkout`/`export` to update the hashes
30+
- `patchable checkout` doesn't support resolving patch conflicts, use `git am` instead (and then `patchable export` the resolved patches)
31+
- Always run patchable via `cargo patchable` (rather than `cargo install`ing it), to ensure that you use the correct version for a given checkout of docker-images
32+
33+
## Configuration
34+
35+
Patchable stores a per-version file in `docker-images/<PRODUCT>/stackable/patches/<VERSION>/patchable.toml`.
36+
It currently recognizes the following keys:
37+
38+
- `upstream` - the URL of the upstream repository (such as `https://github.com/apache/druid.git`)
39+
- `base` - the commit hash of the upstream base commit (such as `7cffb81a8e124d5f218f9af16ad685acf5e9c67c`)

rust/patchable/src/main.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,32 @@ impl ProductVersionContext<'_> {
7171
}
7272
}
7373

74+
/// Patchable is a tool for managing patches for the third-party products distributed by Stackable.
7475
#[derive(clap::Parser)]
76+
#[clap(
77+
// Encourage people to let cargo decide the current version
78+
bin_name = "cargo patchable",
79+
)]
7580
struct Opts {
7681
#[clap(subcommand)]
7782
cmd: Cmd,
7883
}
7984

8085
#[derive(clap::Parser)]
8186
enum Cmd {
87+
/// Check out a patched source tree to docker-images/<PRODUCT>/patchable-work/worktree/<VERSION>
88+
///
89+
/// The patches will be pulled from docker-images/<PRODUCT>/stackable/patches/<VERSION>
90+
///
91+
/// The source tree will be overwritten if it already exists (equivalent to `git switch`).
8292
Checkout {
8393
#[clap(flatten)]
8494
pv: ProductVersion,
8595
},
96+
97+
/// Export the patches from the source tree at docker-images/<PRODUCT>/patchable-work/worktree/<VERSION>
98+
///
99+
/// The patches will be saved to docker-images/<PRODUCT>/stackable/patches/<VERSION>
86100
Export {
87101
#[clap(flatten)]
88102
pv: ProductVersion,

rust/patchable/src/repo.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ pub enum Error {
2121
branch: String,
2222
commit: error::CommitId,
2323
},
24-
#[snafu(display("failed to create worktree folder at {path:?}"))]
24+
#[snafu(display("failed to create worktree parent folder at {path:?}"))]
2525
CreateWorktreePath {
2626
source: std::io::Error,
2727
path: PathBuf,
2828
},
29-
#[snafu(display("failed to create worktree {path:?} pointing at {branch} in {repo}"))]
29+
#[snafu(display(
30+
"failed to create worktree {path:?} pointing at {branch} in {repo} (hint: {})",
31+
"it may have been created but deleted in the past, try `git -C {repo} worktree prune`"
32+
))]
3033
CreateWorktree {
3134
source: git2::Error,
3235
repo: error::RepoPath,

0 commit comments

Comments
 (0)