Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 436424 - kernel-2.eclass v1.277 : Algo for determining PATCH_DEPTH goes wrong when all diffs in a patch file refer to /dev/null
Summary: kernel-2.eclass v1.277 : Algo for determining PATCH_DEPTH goes wrong when all...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: Gentoo Kernel Miscellaneous
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-27 16:57 UTC by Eric F. GARIOUD
Modified: 2012-11-29 14:19 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
TEST-CASE-ONLY : ebuild example to reproduce the problem (ck-sources-3.5.4.ebuild,2.02 KB, text/plain)
2012-09-29 16:55 UTC, Eric F. GARIOUD
Details
TEST-CASE : Example of patch inappropriatly patched p0 (urw-locks.patch,7.28 KB, text/plain)
2012-09-29 17:04 UTC, Eric F. GARIOUD
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric F. GARIOUD 2012-09-27 16:57:34 UTC
- I understand from kernel-2.eclass code that the unipatch() procedure determines the PATCH_LEVEL using some sort of trial and error algorithm consisting in using the lowest level for which the patch --dry-run command does not return an error.

- This might have worked well until now, but, per pure chance only as there is at least one corner case for which it silently fails, leading to an apparently successful emerge but potentially unbuildable kernel.

- This is when it happens that the patch file contains only diffs referencing the old filename as /dev/null, that is to say whenever new files are to be created.

- If we consider that pathnames for kernel patches are generally coded using the following scheme : Some_Author_Dependent_Dir/Some_Kernel_Path/Some_Filename then, of course, such patches are meant to be applied -p1

- Starting the unipatch() while loop with PATCH_LEVEL=0

- If the patch file contains at least one diff for which the old filename is not /dev/null, then the patch command will take the old filename as reference, but it wont find any Some_Author_Dependent_Dir in the local tree and the --dry-run will return an error leading to the increment of PATCH_LEVEL and another try with PATCH_LEVEL=1 which will be successful.

- However, if all diffs' old filenames refer to /dev/null, then the patch command does not look for any existing file to patch as it will create a new file under the name of the new filename. So the unipatch() --dry-runs exits with no error.

- So PATCH_LEVEL = 0 will appear as a valid value and the patch be actually applied -p0, this resulting in the creation of a Some_Author_Dependent_Dir/Some_Kernel_Path/Some_Filename file instead of the creation of the Some_Kernel_Path/Some_Filename file as originally intended.

Reproducible: Always
Comment 1 Eric F. GARIOUD 2012-09-28 11:03:44 UTC
In the description above, please read PATCH_DEPTH instead of PATCH_LEVEL.

Apologizes.
Comment 2 Mike Pagano gentoo-dev 2012-09-29 15:30:51 UTC
Any reproducible steps so I can see it live?
Comment 3 Eric F. GARIOUD 2012-09-29 16:55:15 UTC
Created attachment 325324 [details]
TEST-CASE-ONLY : ebuild example to reproduce the problem

Ebuild for reproducing the problem which will occur with the ${XPR_2_FILE} patch.
Please set the "experimental" and "urwlocks" use flags.
Comment 4 Eric F. GARIOUD 2012-09-29 17:04:41 UTC
Created attachment 325328 [details]
TEST-CASE : Example of patch inappropriatly patched p0

TEST-CASE-ONLY : Example of file the algo will incorrectly patch -p0
Used as ${XPR_2_FILE} in the ebuild attached.
Comment 5 Eric F. GARIOUD 2012-09-30 08:29:37 UTC
(In reply to comment #2)
> Any reproducible steps so I can see it live?

And, by the way, if you want to actually *see* something, then you are likely to add some code within the unipatch() procedure that will incidentally satisfy the enhancement request I made as part of Bug 436402, so... please... do not clean all your traces after having seen... ;-)
Comment 6 Eric F. GARIOUD 2012-11-29 14:19:39 UTC
OK, having read the eclass more... carefully, I realize that the initial value for PATCH_DEPTH can be specified as part of the UNIPATCH_LIST string.

I apologize for the noise.