Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
canonical way to emerge a package with private patch?
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
robert99
n00b
n00b


Joined: 12 Jan 2006
Posts: 5
Location: Munich/Germany

PostPosted: Thu Sep 25, 2008 12:49 pm    Post subject: canonical way to emerge a package with private patch? Reply with quote

Hi,

What is the suggested way to apply a private/self-made/not-official patch, if I want to emerge some application with this patch?

In my case, I use noteedit, which has an error, which I corrected for myself, but this correction did not make it until now to some official release (who wonders, the correction is now 2 hours old ;-) ).

I did:
create the patch (diff -Naur etc)
copied the patch to /usr/portage/media-sound/noteedit/files/
edited noteedit-2.8.1.ebuild, added my patch to the line "PaATCHES = ( ....)"
did an "ebuild noteedit-2.8.1.ebuild manifest"
emerge noteedit

But, of course: after the next "emerge --sync", my patch will be gone.

Regards, Robert
Back to top
View user's profile Send private message
DtZ
Tux's lil' helper
Tux's lil' helper


Joined: 09 Sep 2005
Posts: 124

PostPosted: Thu Sep 25, 2008 1:50 pm    Post subject: Reply with quote

You could move your modified ebuild to local overlay. This way it'll be preserved after next portage sync. That's how I deal with my custom ebuilds.
Back to top
View user's profile Send private message
zyko
l33t
l33t


Joined: 01 Jun 2008
Posts: 620
Location: Munich, Germany

PostPosted: Thu Sep 25, 2008 3:07 pm    Post subject: Reply with quote

The fabulous developer manual says: http://devmanual.gentoo.org/ebuild-writing/functions/src_unpack/epatch/index.html
Back to top
View user's profile Send private message
robert99
n00b
n00b


Joined: 12 Jan 2006
Posts: 5
Location: Munich/Germany

PostPosted: Sat Sep 27, 2008 1:33 pm    Post subject: Reply with quote

zyko wrote:
The fabulous developer manual says: http://devmanual.gentoo.org/ebuild-writing/functions/src_unpack/epatch/index.html


Hm, that describes only, how to patch within an ebuild file. I thought more of a method, where I would not need to patch the ebuild :wink:
something like "ebuld <ebuild-file> unpack --additional-patch mypatch" or something like that. But this seems not to be intended?
So I think, the overlay portage tree is the best way to handle with private patches.

Thank you, Robert
Back to top
View user's profile Send private message
zyko
l33t
l33t


Joined: 01 Jun 2008
Posts: 620
Location: Munich, Germany

PostPosted: Sat Sep 27, 2008 2:52 pm    Post subject: Reply with quote

You could issue ebuild <package> unpack, patch the source manually and then continue with ebuild <package> compile, ebuild <package> install, etc.

This change will however not be remembered by Portage if you reinstall the package, so you'd have to do it again (in case). Putting a modified ebuild in you local overlay allows consistent behaviour, even if you forget about your patch or if you do unattended emerging.
Back to top
View user's profile Send private message
yngwin
Retired Dev
Retired Dev


Joined: 19 Dec 2002
Posts: 4572
Location: Suzhou, China

PostPosted: Sat Sep 27, 2008 8:40 pm    Post subject: Reply with quote

zyko wrote:
Putting a modified ebuild in you local overlay allows consistent behaviour

++

That is the "canonical" way.
_________________
"Those who deny freedom to others deserve it not for themselves." - Abraham Lincoln
Free Culture | Defective by Design | EFF
Back to top
View user's profile Send private message
robert99
n00b
n00b


Joined: 12 Jan 2006
Posts: 5
Location: Munich/Germany

PostPosted: Sun Sep 28, 2008 12:17 pm    Post subject: Reply with quote

yngwin wrote:
zyko wrote:
Putting a modified ebuild in you local overlay allows consistent behaviour

++

That is the "canonical" way.


8) Ok, understood. This is, what I have done now.

Many thanks, Robert
Back to top
View user's profile Send private message
tarpman
Veteran
Veteran


Joined: 04 Nov 2004
Posts: 1083
Location: Victoria, BC, Canada

PostPosted: Mon Sep 29, 2008 1:32 am    Post subject: Reply with quote

While it's not the "correct" way, I use this code in /etc/portage/bashrc:
Code:
#!/bin/sh

PATCHDIR_BASE="/usr/local/portage/patches"
PATCHDIRS=" \
    ${PATCHDIR_BASE}/${P}
    ${PATCHDIR_BASE}/${CATEGORY}/${PN}
    ${PATCHDIR_BASE}/${CATEGORY}/${PN}:${SLOT}"
PATCHED="${PORTAGE_BUILDDIR}/.patched"
UNPACKED="${PORTAGE_BUILDDIR}/.unpacked"

case "$EBUILD_PHASE" in

    compile)

    # apply local patches if any exist
    if has_local_patches && needs_local_patches; then
        apply_local_patches
    fi
    ;;

    postinst)
    # run localepurge after install into live fs
    [ -x /usr/bin/localepurge ] && /usr/bin/localepurge
    ;;

esac

has_local_patches() {
    for patchdir in $PATCHDIRS ; do
        if [ -d "$patchdir" ] ; then
            return 0
        fi
    done
    return 1
}

needs_local_patches() {
    if [ -f "$PATCHED" -a "$PATCHED" -nt "$UNPACKED" ] ; then
        return 1
    else
        return 0
    fi
}

apply_local_patches() {
    einfo "Applying local patches to $P..."

    # pull in eutils and shut up QA messages
    if ! hasq "eutils" $INHERITED ; then
        INHERITED="$INHERITED eutils multilib portability toolchain-funcs"
        inherit eutils
    fi

    # apply all patches
    cd "$S"
    for patchdir in $PATCHDIRS ; do
        if [ -d "$patchdir" ] ; then
            EPATCH_SOURCE="$patchdir" EPATCH_SUFFIX="patch" epatch
        fi
    done

    # mark as done patching
    /bin/touch "$PATCHED"
}


Then I put my patches in one of the PATCHDIRs following the epatch naming convention. If you search the forums a bit you'll find other code that does more than this does, such as regenerating autotools build systems if autotools scripts are changed.
_________________
Saving the world, one kilobyte at a time.
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