OpenWrt Forum Archive

Topic: How to apply patches in Openwrt?

The content of this topic has been archived on 10 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

A rookie question:

When I have a patch file, how should I apply this patch? If I add a new patch file lying in the patch directory of a certain package, will it automatically be patched?

Thanks.

Thank you for your answer.

After reading the link, I am having another question about the patch system. For example, there is a source file with version A and a patch file that can make the source file from A to B. Once I drop the patch file to the patch directory and run "make", will the content of the source file change? In other words, does the patch procedure triggered by "make" actually change the original source file content according to the new patch file? Or it applies the patch file on-the-fly every time it runs?

If the patch system applies patches every time it runs and keeps the original file unchanged, there comes another question. Imagine that I have already made some changes to the source file before I apply the patch and essentially the source file now is version A'. Will the patch file still work? If not, what is the proper way to change the source code based on its latest version?

Thanks.

(Last edited by VincentGW on 15 Sep 2011, 20:33)

During the "prepare" stage of the build process, the source code is copied or extracted to a temporary build directory and patched. A "make clean" removes this directory.

Whether or not a patch will still apply after making changes to the original source is dependent on whether or not the changes are conflicting. Nine out of ten times the patch will still apply, but there will be fuzz or offset. Issuing a "make package/xxx/refresh" will refresh the patches using quilt and reconcile any offsets.

The discussion might have continued from here.