View previous topic :: View next topic |
Author |
Message |
drescherjm Advocate

Joined: 05 Jun 2004 Posts: 2792 Location: Pittsburgh, PA, USA
|
Posted: Mon Sep 07, 2009 5:01 am Post subject: Documentation of epatch_user and /etc/portage/patches |
|
|
Besides reading the eutils.eclass file is there any documentation for this? I tried to use man but found nothing. Goggle searches also lead to nothing. _________________ John
My gentoo overlay
Instructons for overlay |
|
Back to top |
|
 |
Mike Hunt Watchman


Joined: 19 Jul 2009 Posts: 5287
|
Posted: Tue Sep 08, 2009 2:00 am Post subject: |
|
|
Have you seen this thread? It's just slightly more entertaining than reading the eutils.eclass file. |
|
Back to top |
|
 |
drescherjm Advocate

Joined: 05 Jun 2004 Posts: 2792 Location: Pittsburgh, PA, USA
|
Posted: Tue Sep 08, 2009 2:08 am Post subject: |
|
|
I did see that in my searches. It was several years old and talked about more than one method of user patching. I also found a few bug reports that use the epatch_user but no real documentation. I wanted this so I can point to the documentation to show other users how to do this so that I can drop patching wine from my overlay since this feature eliminates the need for a patched wine ebuild. _________________ John
My gentoo overlay
Instructons for overlay |
|
Back to top |
|
 |
Mike Hunt Watchman


Joined: 19 Jul 2009 Posts: 5287
|
Posted: Wed Sep 09, 2009 6:21 am Post subject: |
|
|
Can you put a short HOWTO an how to use /etc/portage/patches on your homepage? It would be much appreciated for sure.  |
|
Back to top |
|
 |
drescherjm Advocate

Joined: 05 Jun 2004 Posts: 2792 Location: Pittsburgh, PA, USA
|
|
Back to top |
|
 |
Mike Hunt Watchman


Joined: 19 Jul 2009 Posts: 5287
|
Posted: Wed Sep 09, 2009 1:15 pm Post subject: |
|
|
I think it already is there.
...since patches can be placed in /etc/portage/patches/category/package instead of specifying the patch in the ebuild directly.
Cool  |
|
Back to top |
|
 |
kernelOfTruth Watchman


Joined: 20 Dec 2005 Posts: 6111 Location: Vienna, Austria; Germany; hello world :)
|
|
Back to top |
|
 |
lkraav Tux's lil' helper


Joined: 13 Oct 2004 Posts: 130 Location: Estonia
|
Posted: Thu May 05, 2011 3:00 pm Post subject: |
|
|
is there a way to make epatch_user system-wide, so i don't need to make custom epatch_user-enabled ebuilds? |
|
Back to top |
|
 |
lkraav Tux's lil' helper


Joined: 13 Oct 2004 Posts: 130 Location: Estonia
|
Posted: Mon May 16, 2011 6:02 pm Post subject: |
|
|
lkraav wrote: | is there a way to make epatch_user system-wide, so i don't need to make custom epatch_user-enabled ebuilds? |
looks like
Code: | PATCHES=/any_patches_dir/ emerge atom |
is The Way. right? |
|
Back to top |
|
 |
ermo n00b

Joined: 01 May 2007 Posts: 4
|
Posted: Sat Jul 23, 2011 1:00 am Post subject: Example using epatch_user / localpatch feature |
|
|
For future reference, I'm going to document how I used epatch_user to add a patch to gentoo-sources today.
Reviewing the gentoo-sources ebuilds reveals that they inherit the kernel-2.eclass. Looking at /usr/portage/eclass/kernel-2.eclass, I noticed that it included a reference to epatch_user in the function kernel-2_src_unpack().
Code: | /usr/portage/eclass # grep epatch_user * |
The above grep invocation revealed that the epatch_user bash function is currently defined as follows in /usr/portage/eclass/eutils.eclass:
Code: |
epatch_user() {
[[ $# -ne 0 ]] && die "epatch_user takes no options"
# don't clobber any EPATCH vars that the parent might want
local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches
for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}}; do
EPATCH_SOURCE=${base}/${CTARGET}/${check}
[[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check}
[[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check}
if [[ -d ${EPATCH_SOURCE} ]] ; then
EPATCH_SOURCE=${EPATCH_SOURCE} \
EPATCH_SUFFIX="patch" \
EPATCH_FORCE="yes" \
EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." \
epatch
return 0
fi
done
return 1
}
|
From the Gentoo Development Guide we can deduce that the following paths are valid (using sys-kernel/gentoo-sources-2.6.39-r3 as an example):
Code: |
/etc/portage/patches/sys-kernel/gentoo-sources-2.6.39-r3 # ${CATEGORY}/${PF}
/etc/portage/patches/sys-kernel/gentoo-sources-2.6.39 # ${CATEGORY}/${P}
/etc/portage/patches/sys-kernel/gentoo-sources # ${CATEGORY}/${PN}
|
For my particular use case, I added the radeon kms patch titled [PATCH] drm/radeon: fix oops in ttm reserve when pageflipping (v2):
Code: | /etc/portage/sys-kernel/gentoo-sources-2.6.39-r3/linux-2.6.git-498c555f56a02ec1059bc150cde84411ba0ac010.patch |
Let's test that it works as expected:
Code: |
# cd /usr/portage/sys-kernel/gentoo-sources/
# ebuild gentoo-sources-2.6.39-r3.ebuild clean
# ebuild gentoo-sources-2.6.39-r3.ebuild prepare
* linux-2.6.39.tar.bz2 RMD160 SHA1 SHA256 size ;-) ... [ ok ]
* genpatches-2.6.39-5.base.tar.bz2 RMD160 SHA1 SHA256 size ;-) ... [ ok ]
* genpatches-2.6.39-5.extras.tar.bz2 RMD160 SHA1 SHA256 size ;-) ... [ ok ]
* checking ebuild checksums ;-) ... [ ok ]
* checking auxfile checksums ;-) ... [ ok ]
* checking miscfile checksums ;-) ... [ ok ]
* checking linux-2.6.39.tar.bz2 ;-) ... [ ok ]
* checking genpatches-2.6.39-5.base.tar.bz2 ;-) ... [ ok ]
* checking genpatches-2.6.39-5.extras.tar.bz2 ;-) ... [ ok ]
* Package: sys-kernel/gentoo-sources-2.6.39-r3
* Repository: gentoo
* Maintainer: kernel@gentoo.org
* USE: amd64 elibc_glibc kernel_linux multilib userland_GNU
* FEATURES: fakeroot installsources preserve-libs sandbox splitdebug userpriv usersandbox
>>> Preparing to unpack ...
>>> Unpacking source...
>>> Unpacking linux-2.6.39.tar.bz2 to /home/portage/tmp/portage/sys-kernel/gentoo-sources-2.6.39-r3/work
>>> Unpacking genpatches-2.6.39-5.base.tar.bz2 to /home/portage/tmp/portage/sys-kernel/gentoo-sources-2.6.39-r3/work/patches
>>> Unpacking genpatches-2.6.39-5.extras.tar.bz2 to /home/portage/tmp/portage/sys-kernel/gentoo-sources-2.6.39-r3/work/patches
* Applying 1000_linux-2.6.39.1.patch (-p0+) ... [ ok ]
* Applying 1001_linux-2.6.39.2.patch (-p0+) ... [ ok ]
* Applying 1002_linux-2.6.39.3.patch (-p0+) ... [ ok ]
* Applying 2900_disable-wunused-but-set-var-gcc-4-6-0.patch (-p0+) ... [ ok ]
* Applying 2910_gnu-make-3.80-compat-fix.patch (-p0+) ... [ ok ]
* Applying 4200_fbcondecor-0.9.6.patch (-p0+) ... [ ok ]
* Applying user patches from /etc/portage/patches/sys-kernel/gentoo-sources-2.6.39-r3 ...
* linux-2.6.git-498c555f56a02ec1059bc150cde84411ba0ac010.patch ... [ ok ]
* Done with patching
>>> Source unpacked in /home/portage/tmp/portage/sys-kernel/gentoo-sources-2.6.39-r3/work
>>> Preparing source in /home/portage/tmp/portage/sys-kernel/gentoo-sources-2.6.39-r3/work/linux-2.6.39-gentoo-r3 ...
>>> Source prepared.
#
|
Et voilà -- a cleanly patched kernel.
Simples  |
|
Back to top |
|
 |
lkraav Tux's lil' helper


Joined: 13 Oct 2004 Posts: 130 Location: Estonia
|
Posted: Thu Jul 28, 2011 12:26 pm Post subject: |
|
|
yes thats cool n all. i still havent figured out how to get patches going for ebuilds without epatch_user.
it might actually make sense to patch eclass to always run epatch_user. |
|
Back to top |
|
 |
Genone Retired Dev


Joined: 14 Mar 2003 Posts: 9631 Location: beyond the rim
|
Posted: Fri Jul 29, 2011 1:07 pm Post subject: |
|
|
Better use a local callback via /etc/portage/bashrc (e.g. post_src_prepare to run after the ebuilds src_prepare IIRC). |
|
Back to top |
|
 |
lkraav Tux's lil' helper


Joined: 13 Oct 2004 Posts: 130 Location: Estonia
|
Posted: Fri Jul 29, 2011 1:13 pm Post subject: |
|
|
Genone wrote: | Better use a local callback via /etc/portage/bashrc (e.g. post_src_prepare to run after the ebuilds src_prepare IIRC). |
if i had only known of such magic. will check it out later tonight thanks! |
|
Back to top |
|
 |
codestation Tux's lil' helper


Joined: 09 Nov 2008 Posts: 126 Location: /dev/negi
|
Posted: Fri Jul 29, 2011 5:02 pm Post subject: |
|
|
I use this simple bashrc to manage my patches:
Code: |
_PATCHDIR="/etc/portage/epatches/"
if [[ -d ${_PATCHDIR}/${CATEGORY}/${PN} ]]; then
if [[ -z "`type -t epatch`" ]]; then
epatch() {
patch -p0 < $1
}
fi
post_src_unpack() {
cd "${S}"
for i in `ls ${_PATCHDIR}/${CATEGORY}/${PN}/*.patch 2> /dev/null`; do
epatch "${i}" || die "epatch failed"
done
}
fi
|
Doesn't offer the features of epatch_user and can be improved but at least it works for all my ebuilds so i am happy with it. _________________ Just feel the code... |
|
Back to top |
|
 |
lkraav Tux's lil' helper


Joined: 13 Oct 2004 Posts: 130 Location: Estonia
|
Posted: Fri Jul 29, 2011 5:17 pm Post subject: |
|
|
codestation wrote: | I use this simple bashrc to manage my patches:
Doesn't offer the features of epatch_user and can be improved but at least it works for all my ebuilds so i am happy with it. |
thanks for sharing. but wouldn't sourcing the eclass (do you even need to, or is eapi available from bashrc?) and just using epatch_user work or what am i missing? |
|
Back to top |
|
 |
lkraav Tux's lil' helper


Joined: 13 Oct 2004 Posts: 130 Location: Estonia
|
Posted: Fri Aug 19, 2011 4:29 am Post subject: |
|
|
yup, afaics this is all i need:
Code: | post_src_prepare() {
epatch_user
} |
|
|
Back to top |
|
 |
fbcyborg Advocate


Joined: 16 Oct 2005 Posts: 3056 Location: ROMA
|
|
Back to top |
|
 |
ppurka Advocate

Joined: 26 Dec 2004 Posts: 3256
|
Posted: Thu May 10, 2012 12:41 am Post subject: |
|
|
fbcyborg wrote: | Hello,
could somebody explain me why if I place a patch in /etc/portage/patches/kde-base/plasma-apps/ directory, and I run emerge, the patch is being applied, whereas if I put a patch in /etc/portage/patches/app-pda/gtkpod/, it is not being applied?
What am I doing wrong? | Not all ebuilds support epatch_user. My guess is that gtkpod is using an old EAPI (EAPI=2) whereas plasma-app is using EAPI=4 and that is why the latter works. _________________ emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/ |
|
Back to top |
|
 |
Hu Administrator

Joined: 06 Mar 2007 Posts: 23355
|
Posted: Thu May 10, 2012 1:41 am Post subject: |
|
|
The choice of EAPI is not the deciding factor. The ebuild must call epatch_user. If it does not, then /etc/portage/patches will be ignored. If the ebuild inherits eutils.eclass, then you can use /etc/portage/bashrc to force a call to epatch_user. |
|
Back to top |
|
 |
fbcyborg Advocate


Joined: 16 Oct 2005 Posts: 3056 Location: ROMA
|
|
Back to top |
|
 |
Yamakuzure Advocate


Joined: 21 Jun 2006 Posts: 2312 Location: Adendorf, Germany
|
Posted: Mon Dec 03, 2012 1:19 pm Post subject: |
|
|
Hu wrote: | The choice of EAPI is not the deciding factor. The ebuild must call epatch_user. If it does not, then /etc/portage/patches will be ignored. If the ebuild inherits eutils.eclass, then you can use /etc/portage/bashrc to force a call to epatch_user. | I'd like to know what I am doing wrong. I always get: Code: | >>> Source prepared.
/etc/portage/bashrc: Zeile 3: epatch_user: Command not found | And yes, the ebuild does inherit eutils.
I get a "command not found", too, if I try to use epatch directly in /etc/portage/env/<category>/<package>, no matter for what category/package.  _________________ Edited 220,176 times by Yamakuzure |
|
Back to top |
|
 |
Hu Administrator

Joined: 06 Mar 2007 Posts: 23355
|
Posted: Mon Dec 03, 2012 11:30 pm Post subject: |
|
|
Please post the full failed ebuild and the relevant section of your bashrc. |
|
Back to top |
|
 |
Yamakuzure Advocate


Joined: 21 Jun 2006 Posts: 2312 Location: Adendorf, Germany
|
Posted: Tue Dec 04, 2012 12:42 pm Post subject: |
|
|
Hu wrote: | Please post the full failed ebuild and the relevant section of your bashrc. | Never mind. Before I tried it out, I synced. And the relevant ebuild (from an overlay) got its own eclass, which does not inherit eutils. *sigh* I'll post in the thread of the ebuild maintainer here in the forums. _________________ Edited 220,176 times by Yamakuzure |
|
Back to top |
|
 |
raygun n00b

Joined: 03 Sep 2011 Posts: 24
|
Posted: Wed May 22, 2013 3:42 am Post subject: |
|
|
lkraav wrote: | yup, afaics this is all i need:
Code: | post_src_prepare() {
epatch_user
} |
|
I created an /etc/portage/bashrc with the above code in it several months ago, and it solves the problem, but it has the undesirable (though minor) side effect of emitting this for emerges of many packages:
Code: | QA: install
QA Notice: command not found:
/etc/portage/bashrc: line 2: epatch_user: command not found |
It seems like one way around this (I have not tested this yet) would be to change the definition of post_src_prepare to read:
Code: | post_src_prepare() {
[[ `type -t epatch_user` = "function" ]] && epatch_user
} |
There's probably a more elegant way to test for the existence of a shell function, but I can't find it in the bash man page. |
|
Back to top |
|
 |
raygun n00b

Joined: 03 Sep 2011 Posts: 24
|
Posted: Fri Nov 07, 2014 12:46 pm Post subject: |
|
|
raygun wrote: | It seems like one way around this (I have not tested this yet) would be to change the definition of post_src_prepare to read:
Code: | post_src_prepare() {
[[ `type -t epatch_user` = "function" ]] && epatch_user
} |
|
I've now tested it: it's been on my system for over a year with no ill side effects observed. Thanks, everyone! |
|
Back to top |
|
 |
|