github.com/prysmaticlabs/prysm@v1.4.4/third_party/README.md (about) 1 # Third Party Package Patching 2 3 This directory includes local patches to third party dependencies we use in Prysm. Sometimes, 4 we need to make a small change to some dependency for ease of use in Prysm without wanting 5 to maintain our own fork of the dependency ourselves. Our build tool, [Bazel](https://bazel.build) 6 allows us to include patches in a seamless manner based on simple diff rules. 7 8 This README outlines how patching works in Prysm and an explanation of previously 9 created patches. 10 11 **Given maintaining a patch can be difficult and tedious, 12 patches are NOT the recommended way of modifying dependencies in Prysm 13 unless really needed** 14 15 ## Table of Contents 16 17 - [Prerequisites](#prerequisites) 18 - [Creating a Patch](#creating-a-patch) 19 - [Ethereum APIs Patch](#ethereum-apis-patch) 20 - [Updating Patches](#updating-patches) 21 22 ## Prerequisites 23 24 **Bazel Installation:** 25 - The latest release of [Bazel](https://docs.bazel.build/versions/master/install.html) 26 - A modern UNIX operating system (MacOS included) 27 28 ## Creating a Patch 29 30 To create a patch, we need an original version of a dependency which we will refer to as `a` 31 and the patched version referred to as `b`. 32 33 ``` 34 cd /tmp 35 git clone https://github.com/someteam/somerepo a 36 git clone https://github.com/someteam/somerepo b && cd b 37 ``` 38 Then, make all your changes in `b` and finally create the diff of all your changes as follows: 39 ``` 40 cd .. 41 diff -ur --exclude=".git" a b > $GOPATH/src/github.com/prysmaticlabs/prysm/third_party/YOURPATCH.patch 42 ``` 43 44 Next, we need to tell the Bazel [WORKSPACE](https://github.com/prysmaticlabs/prysm/blob/master/WORKSPACE) to patch the specific dependency. 45 Here's an example for a patch we use today for the [Ethereum APIs](https://github.com/prysmaticlabs/ethereumapis) 46 dependency: 47 48 ``` 49 go_repository( 50 name = "com_github_prysmaticlabs_ethereumapis", 51 commit = "367ca574419a062ae26818f60bdeb5751a6f538", 52 patch_args = ["-p1"], 53 patches = [ 54 "//third_party:com_github_prysmaticlabs_ethereumapis-tags.patch", 55 ], 56 importpath = "github.com/prysmaticlabs/ethereumapis", 57 ) 58 ``` 59 60 Now, when used in Prysm, the dependency you patched will have the patched modifications 61 when you run your code.