Find the answer to your Linux question:
Results 1 to 5 of 5
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,273

    [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!"
    www.hrussman.entadsl.com

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    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.

  3. #3
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,273
    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!"
    www.hrussman.entadsl.com

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    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

  6. #5
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,273
    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!"
    www.hrussman.entadsl.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •