You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.0 KiB
1.0 KiB
Patching
A patch is a source code that updates other source code. It is formatted as a diff, because it represents what is different between two versions of text. You create a diff with thie diff
utility, which is then applied to the source code using the patch
utility.
NOTE: Other version control systems like git provide their own methods of creating diffs or patching software.
This is an example where we are creating a patch from the original source code using diff
and then applying it via patch
.
Patching in 6 easy-ish steps
Preserve the original source code
cp cello.c cello.c.orig
Change the source code
Generate a patch using the diff
utility
diff -Naur cello.c.orig cello.c
Save the patch to a file
diff -Naur cello.c.orig cello.c > cello-output-first-patch.patch
Restore the original file
cp cello.c.orig cello.c
Patch the original with the contents of the new patch file using the patch
utility
patch < cello-output-first.patch