Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Proper relative paths in user patches?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
tld
Veteran
Veteran


Joined: 09 Dec 2003
Posts: 1829

PostPosted: Sat Dec 31, 2016 4:15 pm    Post subject: Proper relative paths in user patches? Reply with quote

Wow...I hope someone can clarify this one for me. I'm completely confused as to the proper relative paths that should appear when creating a patch for epatch_user, and it's something that's screwed me up royally on many occasions. I just jumped through hoops with this with the nvidia-drivers for my legacy nvidia card. I'd forgotten that I had nvidia-drivers-304.131-r4 patched for newer kernels (to prevent unknown symbol errors for mtrr_del and mtrr_add), so the upgrade to x11-drivers/nvidia-drivers-304.134 caused a module that wouldn't load.

The patch I had in the former had this:

Code:
--- kernel/nv-linux.h
+++ kernel/nv-linux.h


The full path during the build for that is:

/var/tmp/portage/x11-drivers/nvidia-drivers-304.134/work/kernel

That patch failed with x11-drivers/nvidia-drivers-304.134 with a "nothing to patch" error, and needed to be changed to:

Code:
--- work/kernel/nv-linux.h
+++ work/kernel/nv-linux.h


The newer build uses EAPI=6 rather than EAPI=5, so I'm assuming this is related(?). I've read this:

https://wiki.gentoo.org/wiki//etc/portage/patches

I just don't get this. Frankly I've never even understood what the current directory of the build process is when applying this. Any clarification on this would be greatly appreciated...this has baffled me for quite some time.

Tom
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9731
Location: almost Mile High in the USA

PostPosted: Sat Dec 31, 2016 7:35 pm    Post subject: Reply with quote

Yeah the EAPI change makes different assumptions, I recall seeing this in another patch problem. Portage will remove levels of directories from your patch file paths, but EAPI6 will remove one more level it seems.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
asturm
Developer
Developer


Joined: 05 Apr 2007
Posts: 9014

PostPosted: Sat Dec 31, 2016 7:49 pm    Post subject: Reply with quote

Basically, with git-format you are fine. (has worked pre-EAPI-6, and is the only way now).
Back to top
View user's profile Send private message
tld
Veteran
Veteran


Joined: 09 Dec 2003
Posts: 1829

PostPosted: Sun Jan 01, 2017 2:55 pm    Post subject: Reply with quote

asturm wrote:
Basically, with git-format you are fine. (has worked pre-EAPI-6, and is the only way now).
I haven't had any problem with the format. What confuses me is in regard to the current directory being used when the patches are applied and the resulting requirements for the paths in the header. As eccerr0r mentions, I'm aware that portage will remove excess directories (I'm assuming using -p1, -p2 etc...though I'm unclear to what extent), but the minimum number of directories has me confused. It's not that it removes one more as he said, but rather that it requires one more directory. For example, patches I have for mythweb always worked with paths such as this:
Code:
--- mythweb-0.27/modules/tv/detail.php   2013-12-04 16:09:31.000000000 -0500
+++ mythweb-0.27/modules/tv/detail.php   2013-12-04 16:25:23.000000000 -0500

That is, it appears that the patch is being applied from within "work".

...but as of EAPI=6 those fail, I needed to use this:
Code:
--- work/mythweb-0.28/modules/tv/detail.php   2016-09-27 17:02:06.000000000 -0400
+++ work/mythweb-0.28/modules/tv/detail.php   2016-09-27 17:20:54.000000000 -0400

...where it appears the patches are being applied from the directory above "work". Even before EAPI 6 I recall cases where that seemed to be inconsistent, where I believe some worked without the <package>-<rev> directory, and could even be used (assuming the change was the same) across different versions of the package.

All very confusing, and I've yet to see anything explaining that one.

Tom
Back to top
View user's profile Send private message
asturm
Developer
Developer


Joined: 05 Apr 2007
Posts: 9014

PostPosted: Sun Jan 01, 2017 3:30 pm    Post subject: Reply with quote

I said git-format because it gives you exactly the -p1 paths that you need.

mythweb is just a very bad example. It's doing `cd "${S}"/../` within src_prepare and then calling eapply_user. That's why it appears to you as if it needs another directory level above. Similarly, nvidia-drivers has S=${WORKDIR}.
Back to top
View user's profile Send private message
tld
Veteran
Veteran


Joined: 09 Dec 2003
Posts: 1829

PostPosted: Mon Jan 02, 2017 3:35 pm    Post subject: Reply with quote

asturm wrote:
mythweb is just a very bad example. It's doing `cd "${S}"/../` within src_prepare and then calling eapply_user. That's why it appears to you as if it needs another directory level above. Similarly, nvidia-drivers has S=${WORKDIR}.
Ahh...thanks. That certainly explains a lot. I actually just noticed that a patch I use on MythTV itself in fact works with the same paths in EAPI 6 as it did in EAPI 5.
Back to top
View user's profile Send private message
tld
Veteran
Veteran


Joined: 09 Dec 2003
Posts: 1829

PostPosted: Tue Apr 23, 2019 12:40 am    Post subject: Reply with quote

Wow...wow...wow. I'm resurrecting this old post because this one continues to be the biggest mystery to me when it comes to gentoo. I just do NOT get the rules as far as a proper relative path to use in user patches for ebuilds. It seems I never get it correct. My understanding was that in general, the path you'd get with git diff would be correct. Here's another example where this wasn't correct...with the EAPI 6 mythtv-29.1-r1.ebuild here:

https://packages.gentoo.org/packages/media-tv/mythtv

Maybe in this case it's doing something screwy I'm not seeing. In any case, if I actually check that same version out from the mythtv git, a code change followed by a git diff ends up with paths like this:
Code:
--- a/mythtv/libs/libmythtv/osd.cpp
+++ b/mythtv/libs/libmythtv/osd.cpp

This fails as it has one too many directories. If I remove that a/ and b/ (or presumably change a/mythtv and b/mythtv to any single name) it applies correctly. I take it that a -p1 is being used here, but again, the current directory / relative path here just burns my brain out.

Maybe this is a special case(?) as the mythtv code itself is in the mythtv directory below the extracted source, but I'm not seeing anything out of the ordinary in the ebuild(?). Any clarification would be greatly appreciated. Like I said, I almost never get this right without trial an error.

Tom
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22148

PostPosted: Tue Apr 23, 2019 1:49 am    Post subject: Reply with quote

Patches applied by eapply are done in src_prepare. They must be relative, after stripping, to the current working directory when eapply is called. In the default src_prepare, this is $S. $S is usually, but not necessarily, "${WORKDIR}/${P}", the top level directory containing unpacked source files from upstream. The MythTV ebuild overrides $S, so its src_prepare runs from an unusual directory, which gives you unusual rules.
Back to top
View user's profile Send private message
tld
Veteran
Veteran


Joined: 09 Dec 2003
Posts: 1829

PostPosted: Tue Apr 23, 2019 3:26 pm    Post subject: Reply with quote

OK. Than makes sense. The $S assignment was what I was missing. I assume all the same is true for the apply_user that's being called implicitly in src_prepare (as of EAPI 6). I just happen to have run into a lot of oddball examples.

Thanks!
Tom
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22148

PostPosted: Wed Apr 24, 2019 2:15 am    Post subject: Reply with quote

Correct, eapply_user is bound by the same rules. One other quirk that may have worked against you is that the older epatch family would probe a range of -p values, so you could get away with putting too many levels of path context in your patch. The newer eapply family always guesses -p1, so you must use the proper depth now. I think the feature of guessing various -p levels was abandoned because it could theoretically do the wrong thing in certain odd scenarios.
Back to top
View user's profile Send private message
tld
Veteran
Veteran


Joined: 09 Dec 2003
Posts: 1829

PostPosted: Wed Apr 24, 2019 5:03 pm    Post subject: Reply with quote

Thanks! Yea, I was aware of that change to force -p1. I'm sure you're correct and I assumed the same. That is that in theory, attempting various -p levels could attempt to patch an incorrect file by the same name in another directory. Makes total sense.

Tom
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum