In openwrt, as we known, usually the patches for a certain package should be put in package/[pkg]/patches and it will be applied in Makefile via $(Build/Patch). Example:
package/test/0001-1.0.1.8.fix-A.patch
package/test/0002-1.0.1.8.fix-B.patch
When the package update to a new version, the patches sometimes also need to be updated. Example:
- package/test/0001-1.0.1.9.fix-A.patch
- package/test/0002-1.0.1.9.fix-B.patch
OR
- package/test/0001-1.0.2.0.fix-A.patch
- package/test/0002-1.0.2.0.fix-B.patch
For a single certain package version, this works well. The only thing is to update the package version and patches manually.
For a certion reason the old patch can not be applied and submit to package source when pacakge upgrade. So they have to be maintained via patches.
What I am doing is that, if the Makefile could automatically find the right patches based on the package version. I choose to put all these patches in "package/test/file/patches/" directory base on package verion, such as:
- package/test/file/patches/1.0.1.8/0001-v1.0.1.8.fix-A.patch
- package/test/file/patches/1.0.1.8/0002-1.0.1.8.fix-B.patch
- package/test/file/patches/1.0.1.9/0001-1.0.1.9.fix-A.patch
- package/test/file/patches/1.0.1.9/0002-1.0.1.9.fix-B.patch
- package/test/file/patches/1.0.2.0/0001-1.0.2.0.fix-A.patch
- package/test/file/patches/1.0.2.0/0002-1.0.2.0.fix-B.patch
In the Makefile, the right patches should be copied to "package/test/patches/" directory first in "define Build/Prepare" section, before $(Build/Patch).
Match rule: (I don't know how to insert a table here, I put an image instead ...)
So, in this way, all the patches can be stored in the "pacakge/test" directory and they will be auto matched and applied when building.
The question is , how can I achieve to find out the right match? Since it's a little complex to compare and match the version, especially in Makefile rather than in shell script.
Actually I found some interesting script to do part of this, such as:
how-to-compare-two-strings-in-dot-separated-version-format-in-bash