This detailed article description requires reflection.
This is a very good way. The initial extraction will be difficult, but in the following years it will allow us to avoid a lot of work.
But the problem is hidden somewhere else.
I don't see much difference in the way we came to the state in the working directory of the kernel. In what order we applied the patches. One way or another.
The algorithm will miss for some reason. It will fly past the target. This needs to be sorted out.
I'll say more. Some patches do not change the values of variables in the Makefile, but add changes that will eventually add a local version.
That is, in the process of the make command.
For example, the PREEMPT_RT patch (one of the five known to me) or the user can add a local version during kernel configuration..