Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Adding a patch to portage
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
pcameron
n00b
n00b


Joined: 04 Aug 2011
Posts: 43

PostPosted: Tue Mar 26, 2013 2:17 am    Post subject: [Solved] Adding a patch to portage Reply with quote

Hi All,

I am having trouble using the patching feature on my gentoo system. The bug im trying to patch is https://bugs.gentoo.org/show_bug.cgi?id=456238

I have placed it in the directory.

Code:
bluehills numactl-2.0.8 # ls -la
total 24
drwxr-xr-x. 2 root portage 4096 Mar 26 11:58 .
drwxr-xr-x. 3 root portage 4096 Mar 26 13:09 ..
-rwxr-xr-x. 1 root portage  612 Mar 26 13:09 numactl-2.0.8-cpuid-pic.patch
bluehills numactl-2.0.8 # pwd
/etc/portage/patches/sys-process/numactl-2.0.8


But when I emerge numactl it doesnt pickup the patch.

Code:
>>>Emerging (1 of 1) sys-process/numactl-2.0.8
 * numactl-2.0.8.tar.gz SHA256 SHA512 WHIRLPOOL size ;-) ...                                                            [ ok ]
>>> Unpacking source...
>>> Unpacking numactl-2.0.8.tar.gz to /var/tmp/portage/sys-process/numactl-2.0.8/work
>>> Source unpacked in /var/tmp/portage/sys-process/numactl-2.0.8/work
>>> Preparing source in /var/tmp/portage/sys-process/numactl-2.0.8/work/numactl-2.0.8 ...
 * Applying numactl-2.0.8-static_libs.patch ...                                                                         [ ok ]
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/sys-process/numactl-2.0.8/work/numactl-2.0.8 ...
>>> Source configured.


I should add that im running selinux with a hardened source this used to work before I migrated to this setup :)

Any ideas?

Thanks


Last edited by pcameron on Fri Apr 05, 2013 3:23 am; edited 1 time in total
Back to top
View user's profile Send private message
BillWho
Veteran
Veteran


Joined: 03 Mar 2012
Posts: 1600
Location: US

PostPosted: Tue Mar 26, 2013 3:05 am    Post subject: Reply with quote

pcameron,

This is how I patch virtualbox-modules for 3.9.0-rc4

In /etc/portage/env/app-emulation I have vbox.patch and virtualbox-modules

Contents of virtualbox-modules:
Code:
echo " ---> ${EBUILD_PHASE}"
if [ "${EBUILD_PHASE}" == "prepare" ]
then
   echo ">>>> In bashrc hack prepare phase <<<<"
   patch /var/tmp/portage/app-emulation/virtualbox-modules-4.2.8/work/vboxdrv/r0drv/linux/the-linux-kernel.h  /etc/portage/env/app-emulation/vbox.patch
fi


Make sure your bashrc is executable.

To test it you can use ebuild $(equery w sys-process/numactl) configure :wink:
_________________
Good luck :wink:

Since installing gentoo, my life has become one long emerge :)
Back to top
View user's profile Send private message
alkan
Guru
Guru


Joined: 06 Aug 2004
Posts: 385
Location: kasimlar yaylasi

PostPosted: Tue Mar 26, 2013 11:12 am    Post subject: Reply with quote

try
Code:
/etc/portage/patches/sys-process/numactl/numactl-2.0.8-cpuid-pic.patch
Back to top
View user's profile Send private message
Hu
Watchman
Watchman


Joined: 06 Mar 2007
Posts: 8617

PostPosted: Tue Mar 26, 2013 9:09 pm    Post subject: Reply with quote

Patches in /etc/portage/patches are only used if the ebuild calls epatch_user. The ebuild does not appear to call epatch_user, so unless one of the eclasses is doing that automatically, it will not be done.
Back to top
View user's profile Send private message
pcameron
n00b
n00b


Joined: 04 Aug 2011
Posts: 43

PostPosted: Tue Mar 26, 2013 10:15 pm    Post subject: Reply with quote

Hi all,

Thanks for all the feedback.

I have never looked into bashrc before, is there a good document to get me started as a newbie for patching? Seams like this will be the way to go for this patch

I will google in a bit but any suggested guides would be great.
Back to top
View user's profile Send private message
BillWho
Veteran
Veteran


Joined: 03 Mar 2012
Posts: 1600
Location: US

PostPosted: Tue Mar 26, 2013 11:59 pm    Post subject: Reply with quote

pcameron wrote:
Hi all,

Thanks for all the feedback.

I have never looked into bashrc before, is there a good document to get me started as a newbie for patching? Seams like this will be the way to go for this patch

I will google in a bit but any suggested guides would be great.

That specific information is located here http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=3&chap=6

The main page is http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=3
_________________
Good luck :wink:

Since installing gentoo, my life has become one long emerge :)
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 7417
Location: Somewhere over Atlanta, Georgia

PostPosted: Wed Mar 27, 2013 1:15 am    Post subject: Reply with quote

See also Good generalized method for making minor code changes.

- John
_________________
This space intentionally left blank.
Back to top
View user's profile Send private message
pcameron
n00b
n00b


Joined: 04 Aug 2011
Posts: 43

PostPosted: Fri Apr 05, 2013 2:28 am    Post subject: Reply with quote

Hi again :D

So I have been looking around at bits and pieces since all your reply, which have been great. I have found some code for the bashrc which I think looks good :)

Code:
# <solar@gentoo> 2005
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# /etc/portage/bashrc.autopatch
# echo '((0${BASH_VERSION:0:1} > 2)) && . /etc/portage/bashrc.autopatch' >> /etc/portage/bashrc
# echo 'PATCH_OVERLAY=/usr/portage/local/patches/' >> /etc/make.conf
# mkdir -p /usr/portage/local/patches/

autopatch() {
        local diff level p patches patched

        [[ ! -d "$PATCH_OVERLAY" ]] && return 0

        patches=$(ls -1 ${PATCH_OVERLAY}/${CATEGORY}/${PN}/${PN}-*.{patch,diff} 2>/dev/null)
        [[ $patches == "" ]] && return 0

        if ! cd ${S}; then
                echo ">>> FAILED TO cd $S"
                return 1
        fi

        for p in ${patches}; do
                p=$(basename $p)
                diff=${PATCH_OVERLAY}/${CATEGORY}/${PN}/${p}
                if [[ -e $diff ]] && [ ! -e ${S}/.${p} ]; then
                        patched=0
                        for level in 0 1 2 3 4; do
                                if [[ $patched == 0 ]]; then
                                        patch -g0 --dry -p${level} >/dev/null < $diff
                                        if [ $? = 0 ]; then
                                                echo -e ' \e[0;36m*\e[0m '"auto patching (-p${level}) ${p}"
                                                patch -g0 -p${level} < $diff > /dev/null && patched=1
                                                touch ${S}/.${p}
                                        fi
                                fi
                        done
                        [[ $patched != 1 ]] && echo "!!! FAILED auto patching $p"
                else
                        [[ ! -e $diff ]] && echo "!!! $diff does not exist, unable to auto patch"
                fi
        done
        cd $OLDPWD
}

if [[ $EBUILD_PHASE == compile ]]; then
        PATH=$PATH:/usr/sbin:/usr/bin:/bin:/sbin
        autopatch
fi


My bash skills are basic at best, but from what I can understand and following the instructions in the comments I have run the commands in the comments, but im unsure what this does
Code:
${PN}/${PN}-*


I have put the patch into

Code:
bluehills numactl-2.0.8 # ls -la
total 24
drwxr-xr-x. 2 root root 4096 Mar 27 09:43 .
drwxr-xr-x. 3 root root 4096 Mar 27 09:43 ..
-rwxr-xr-x. 1 root root  612 Mar 27 09:43 numactl-2.0.8-cpuid-pic.patch
bluehills numactl-2.0.8 # pwd
/usr/portage/local/patches/sys-process/numactl-2.0.8


But it doesnt pick up the patch :(

Could someone with a little more knowledge help me on what the directory should be?

Also the file is called bashrc.autopatch and its in the following.

Code:
bluehills numactl-2.0.8 # ls /etc/portage/
1q         bashrc            bin  make.conf.catalyst  package.keywords  package.unmask  package.use.old  postsync.d
autopatch  bashrc.autopatch  env  make.profile        package.mask      package.use     patches          savedconfig
Back to top
View user's profile Send private message
Hu
Watchman
Watchman


Joined: 06 Mar 2007
Posts: 8617

PostPosted: Fri Apr 05, 2013 2:49 am    Post subject: Reply with quote

Since the target ebuild already inherits eutils, it might be simpler if you use bashrc to add a call to epatch_user at the appropriate phase instead of trying to reinvent the functionality of epatch_user.
Back to top
View user's profile Send private message
pcameron
n00b
n00b


Joined: 04 Aug 2011
Posts: 43

PostPosted: Fri Apr 05, 2013 3:20 am    Post subject: Reply with quote

HAHAHA!

Success mate, after a little googling for someone who has done this in the past.

/etc/portage/bashrc

Code:

if [ "${EBUILD_PHASE}" == "prepare" ]; then
    echo ":: Calling epatch_user";
    pushd "${S}"
    epatch_user
    popd
fi


Now I just plonked the patch into the correct dir in patches like on the first post and voala!

Will this cause issues (is this good acceptable practice?) having this code in my /etc/portage/bashrc?

Thanks.
Back to top
View user's profile Send private message
Hu
Watchman
Watchman


Joined: 06 Mar 2007
Posts: 8617

PostPosted: Fri Apr 05, 2013 9:36 pm    Post subject: Reply with quote

There is one minor issue with using such a simplistic version. Not every ebuild will have a function named epatch_user, so for those that do not, you will run a non-existent command. You should add a check that epatch_user is a function before you call it.
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