CONTRIBUTING.md: patch creation how-to

This commit is contained in:
Leonid Pliushch 2021-12-26 19:34:35 +02:00
parent 01e46c8bb8
commit d4db7ccbde
No known key found for this signature in database
GPG Key ID: 45F2964132545795

View File

@ -330,6 +330,54 @@ Use of forks is allowed only under a good reason.
More about `build.sh` variables you can read on [developer's wiki](https://github.com/termux/termux-packages/wiki/Creating-new-package#table-of-available-package-control-fields).
### Creating patch files
Many packages will require changes that can't be done through configuring
build system. In this cases you need to directly modify the source code
and obtain files that describe your changes in machine readable format.
We use patches made in [Unified Format](https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html)
generated by either GNU `diff`, `git` or other compatible utility.
See below on how to make a patch with GNU `diff`:
1. Get source code, for example with this command:
```
cd ./packages/your-package
(source build.sh 2>/dev/null; curl -LO "$TERMUX_PKG_SRCURL")
```
2. Extract tarball and make a copy of source code tree:
```
tar xf package-1.0.tar.gz
cp -a package-1.0 package-1.0.mod
```
3. Change current directory to source code tree:
```
cd package-1.0.mod
```
4. Make changes:
```
vim sourcefile.c
```
5. Generate difference between original and modified sources:
```
cd ..
diff -uNr package-1.0 package-1.0.mod > very-nice-improvement.patch
```
Patch file names should be self descriptive, so it will be easier for other
people to understand what your patch does. Also it is preferred that every
modification is stored in a separate patch file.
## Updating packages
[![asciicast](https://asciinema.org/a/gVwMqf1bGbqrXmuILvxozy3IG.svg)](https://asciinema.org/a/gVwMqf1bGbqrXmuILvxozy3IG?autoplay=1&speed=2.0)
@ -430,4 +478,3 @@ No LICENSE file was installed for ...
This error happens when build system cannot find license file and it should be
specified manually through `TERMUX_PKG_LICENSE_FILE`.