Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > Your Distro > Gentoo Linux Help > [SOLVED] Advice needed about patching a source package

Forgot Password?
 Gentoo Linux Help   For help and discussion related to Gentoo Linux

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Closed Thread
 
Thread Tools Display Modes
Old 04-23-2009   #1 (permalink)
Linux User
 
hazel's Avatar
 
Join Date: May 2004
Location: Harrow, UK
Posts: 493
[SOLVED] Advice needed about patching a source package

I have installed tk but it fails to run and says it hasn't been properly installed. This is a known bug caused by an incompatibility with xproto; there is a patch for it which I have copied into a file called tkpatch. But I have never patched source code before so I need a bit of reassurance from the younger and wiser before actually doing the job.

I have copied the source tarball from /usr/portage/distfiles and unpacked it in my home directory. The problem is in the file generic/tkBind.c. Is the solution really as simple as going into the generic directory and running
Code:
patch <~/tkpatchfile
, then retarring the whole thing and copying it back to distfiles? And then re-emerging it? I don't want to screw up.
__________________
"I'm just a little old lady; don't try to dazzle me with jargon!"
hazel is offline  


Old 04-23-2009   #2 (permalink)
Linux Engineer
 
Join Date: Nov 2007
Location: Córdoba (Spain)
Posts: 1,495
Quote:
Originally Posted by hazel View Post
I have installed tk but it fails to run and says it hasn't been properly installed. This is a known bug caused by an incompatibility with xproto; there is a patch for it which I have copied into a file called tkpatch. But I have never patched source code before so I need a bit of reassurance from the younger and wiser before actually doing the job.

I have copied the source tarball from /usr/portage/distfiles and unpacked it in my home directory. The problem is in the file generic/tkBind.c. Is the solution really as simple as going into the generic directory and running
Code:
patch <~/tkpatchfile
, then retarring the whole thing and copying it back to distfiles? And then re-emerging it? I don't want to screw up.
That will give you an error because the checksums will not match, hence the modified package will be wiped from distfiles, and then re-downloaded again.

The "proper" way to do it is to use a modified ebuild in your local overlay. To create a local overlay you need a line like this in your /etc/make.conf file:

Code:
PORTDIR_OVERLAY="/usr/local/portage"
You may skip this if you already have a local overlay.

Or whatever location you prefer for it. Then you must make sure that the directory exist. From that moment, you can put ebuilds there and they will be recognized by portage. So, if you want to modify the tk ebuild, you can copy it to use it as a base. The ebiulds in this dir must preserve the tipical portage structure, for example, if you need to modify the qt ebuild, you would do this:

Code:
cd /usr/local/portage
mkdir -p x11-libs/qt
Then you need to copy the ebuild that you want to modify inside your new directory.


Once you have done that, we need to add the patch into the ebuild, for that, you usually put the patch inside the files subdir, then we edit the ebuild. So the whole process would be:

Code:
cd /usr/local/portage
mkdir -p x11-libs/qt
cd x11-libs/qt
mkdir files
cp $HOME/mypatch.diff files/
The patch can be also compressed if it's big. Portage can handle many formats without any hassle.

Now, to the ebuild: open it in any editor of your choice. Then locate the function called "src_unpack". You need to add a line like this in that section:

Code:
epatch "${FILESDIR}/mypatch.diff"
You might need to create that function if the ebuild doesn't define one. Just ask here if that's the case, telling me the exact ebuild that you want to edit so I can give more concrete instructions.

Once everything is set, you need to do the manifest as usual:

Code:
ebuild whatever-x.y.z.ebuild manifest
And that's the basic procedure. This assumes that the patch works of course. Please, ask for clarifications if you don't understand any step or something.
i92guboj is offline  
Old 04-23-2009   #3 (permalink)
Linux User
 
hazel's Avatar
 
Join Date: May 2004
Location: Harrow, UK
Posts: 493
Thanks very much for your nice clear instructions. This is new territory for me. I didn't even know about the overlay tree; I must say I'm very impressed that such a thing exists.

At the moment, it doesn't quite work. You see, there are other patches in /usr/portage/dev-lang/tk/files but now it seems emerge can't find them because it's looking in /usr/local/portage instead of /usr/portage. Here are the errors I get:

Cannot find $EPATCH_SOURCE! Value for $EPATCH_SOURCE is:
*
* /usr/local/portage/dev-lang/tk/files/remove-control-v-8.4.9.diff
* ( remove-control-v-8.4.9.diff )

*
* ERROR: dev-lang/tk-8.4.18 failed.
* Call stack:
* ebuild.sh, line 49: Called src_unpack
* environment, line 2622: Called epatch
'/usr/local/portage/dev-lang/tk/files/remove-control-v-8.4.9.diff'
* environment, line 1481: Called die
* The specific snippet of code:
* die "Cannot find $EPATCH_SOURCE!";
* The die message:
* Cannot find $EPATCH_SOURCE!

There's obviously some extra little thing I have to do to correct this.
__________________
"I'm just a little old lady; don't try to dazzle me with jargon!"
hazel is offline  
Old 04-23-2009   #4 (permalink)
Linux Engineer
 
Join Date: Nov 2007
Location: Córdoba (Spain)
Posts: 1,495
Quote:
Originally Posted by hazel View Post
There's obviously some extra little thing I have to do to correct this.
Yes. sorry. I didn't think of that. You need to copy all these patches into the files/ subdir of the overlay as well. After that you need to repeat the manifest step. Then it should work.

When you start emerging the new ebuild you should see some lines telling you how the patches are applied. If all went well, yours should show there as well
i92guboj is offline  
Old 04-24-2009   #5 (permalink)
Linux User
 
hazel's Avatar
 
Join Date: May 2004
Location: Harrow, UK
Posts: 493
Quote:
Originally Posted by i92guboj View Post
When you start emerging the new ebuild you should see some lines telling you how the patches are applied. If all went well, yours should show there as well
Yeahh! Patch applied successfully and tkman now works. Interestingly there is a later release of tk that incorporates this patch, but it's marked ~x86, which is why I didn't get it. Thanks for all your help, guboj.
__________________
"I'm just a little old lady; don't try to dazzle me with jargon!"
hazel is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 05:17 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2