Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Documentation of epatch_user and /etc/portage/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
drescherjm
Advocate
Advocate


Joined: 05 Jun 2004
Posts: 2790
Location: Pittsburgh, PA, USA

PostPosted: Mon Sep 07, 2009 5:01 am    Post subject: Documentation of epatch_user and /etc/portage/patches Reply with quote

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
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Tue Sep 08, 2009 2:00 am    Post subject: Reply with quote

Have you seen this thread? It's just slightly more entertaining than reading the eutils.eclass file.
Back to top
View user's profile Send private message
drescherjm
Advocate
Advocate


Joined: 05 Jun 2004
Posts: 2790
Location: Pittsburgh, PA, USA

PostPosted: Tue Sep 08, 2009 2:08 am    Post subject: Reply with quote

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
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Wed Sep 09, 2009 6:21 am    Post subject: Reply with quote

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
View user's profile Send private message
drescherjm
Advocate
Advocate


Joined: 05 Jun 2004
Posts: 2790
Location: Pittsburgh, PA, USA

PostPosted: Wed Sep 09, 2009 1:12 pm    Post subject: Reply with quote

I may do that.
_________________
John

My gentoo overlay
Instructons for overlay
Back to top
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Wed Sep 09, 2009 1:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
kernelOfTruth
Watchman
Watchman


Joined: 20 Dec 2005
Posts: 6111
Location: Vienna, Austria; Germany; hello world :)

PostPosted: Fri Feb 18, 2011 2:19 am    Post subject: Reply with quote

Mike Hunt wrote:
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 :)


*subscribes*

Woah !

exactly what I was looking for & rsync :D
_________________
https://github.com/kernelOfTruth/ZFS-for-SystemRescueCD/tree/ZFS-for-SysRescCD-4.9.0
https://github.com/kernelOfTruth/pulseaudio-equalizer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Back to top
View user's profile Send private message
lkraav
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2004
Posts: 129
Location: Estonia

PostPosted: Thu May 05, 2011 3:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
lkraav
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2004
Posts: 129
Location: Estonia

PostPosted: Mon May 16, 2011 6:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
ermo
n00b
n00b


Joined: 01 May 2007
Posts: 4

PostPosted: Sat Jul 23, 2011 1:00 am    Post subject: Example using epatch_user / localpatch feature Reply with quote

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 8)
Back to top
View user's profile Send private message
lkraav
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2004
Posts: 129
Location: Estonia

PostPosted: Thu Jul 28, 2011 12:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9507
Location: beyond the rim

PostPosted: Fri Jul 29, 2011 1:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
lkraav
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2004
Posts: 129
Location: Estonia

PostPosted: Fri Jul 29, 2011 1:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
codestation
Tux's lil' helper
Tux's lil' helper


Joined: 09 Nov 2008
Posts: 126
Location: /dev/negi

PostPosted: Fri Jul 29, 2011 5:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
lkraav
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2004
Posts: 129
Location: Estonia

PostPosted: Fri Jul 29, 2011 5:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
lkraav
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2004
Posts: 129
Location: Estonia

PostPosted: Fri Aug 19, 2011 4:29 am    Post subject: Reply with quote

yup, afaics this is all i need:

Code:
post_src_prepare() {
    epatch_user
}
Back to top
View user's profile Send private message
fbcyborg
Advocate
Advocate


Joined: 16 Oct 2005
Posts: 3056
Location: ROMA

PostPosted: Wed May 09, 2012 9:30 pm    Post subject: Reply with quote

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? :roll:

What am I doing wrong?
_________________
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3256

PostPosted: Thu May 10, 2012 12:41 am    Post subject: Reply with quote

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? :roll:

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
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21489

PostPosted: Thu May 10, 2012 1:41 am    Post subject: Reply with quote

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
View user's profile Send private message
fbcyborg
Advocate
Advocate


Joined: 16 Oct 2005
Posts: 3056
Location: ROMA

PostPosted: Thu May 10, 2012 10:04 am    Post subject: Reply with quote

Thanks I did understand.
_________________
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Back to top
View user's profile Send private message
Yamakuzure
Advocate
Advocate


Joined: 21 Jun 2006
Posts: 2280
Location: Adendorf, Germany

PostPosted: Mon Dec 03, 2012 1:19 pm    Post subject: Reply with quote

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. :(
_________________
Important German:
  1. "Aha" - German reaction to pretend that you are really interested while giving no f*ck.
  2. "Tja" - German reaction to the apocalypse, nuclear war, an alien invasion or no bread in the house.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21489

PostPosted: Mon Dec 03, 2012 11:30 pm    Post subject: Reply with quote

Please post the full failed ebuild and the relevant section of your bashrc.
Back to top
View user's profile Send private message
Yamakuzure
Advocate
Advocate


Joined: 21 Jun 2006
Posts: 2280
Location: Adendorf, Germany

PostPosted: Tue Dec 04, 2012 12:42 pm    Post subject: Reply with quote

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.
_________________
Important German:
  1. "Aha" - German reaction to pretend that you are really interested while giving no f*ck.
  2. "Tja" - German reaction to the apocalypse, nuclear war, an alien invasion or no bread in the house.
Back to top
View user's profile Send private message
raygun
n00b
n00b


Joined: 03 Sep 2011
Posts: 24

PostPosted: Wed May 22, 2013 3:42 am    Post subject: Reply with quote

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
View user's profile Send private message
raygun
n00b
n00b


Joined: 03 Sep 2011
Posts: 24

PostPosted: Fri Nov 07, 2014 12:46 pm    Post subject: Reply with quote

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
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