LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Applying patches to programs (https://www.linuxquestions.org/questions/linux-newbie-8/applying-patches-to-programs-551672/)

Grife 05-06-2007 05:36 AM

Applying patches to programs
 
Okay, I'm done reading documentation so I know how to compile a program (Window Maker) from sources (yes, I'm n00b but thought learning something else than apt-get, yum or netpkg might come handy). Source package had folder with several patches, one which I want to apply (single_click.diff which enables using dock with single clicks). After brief googling on how to apply that patch I found out about patch command and read the man pages of it, but I just don't get it!
Code:

SYNOPSIS
      patch [options] [originalfile [patchfile]]

      but usually just

      patch -pnum <patchfile

I'm such a n00b, that I don't know which file I'm supposed to patch, am I supposed to patch it before or after compilation and that whole -pnum (-p0, -p1) thing was plain gibberish*. Couldn't really comprehend it. Man page didn't really have any step-by-step examples.. Could someone help me out with this one?

Thanks!


*
Code:

If the header is that of a context diff, patch takes the old and new
          file names in the header.  A name is ignored if  it  does  not  have
          enough slashes to satisfy the -pnum or --strip=num option.  The name
          /dev/null is also ignored.

:confused: :confused: :confused:

titopoquito 05-06-2007 06:32 AM

The patchfile knows which file to patch. Go to the source folder (WindowMaker-0.92.0 probably) and take a look at the patch file (less contrib/single_click.diff). At the top you see which file will get patched (maybe there are more if you scroll down, didn't look that far myself).
You will notice for example the line starting "+++ WPrefs.app/Expert.c". If you look in the source folder you will find a directory called "WPrefs.app" so that the path is correct if you are in the "root" of the source folder -- -p0 is right here.
If the line mentioned started for example "+++ WindowMaker-0.92.0/WPrefs.app/Expert.c" from that point you needed to strip the first part to apply the patch right (so that the relative path from where you are points to the right file, Expert.c in this case), so -p1 would be the right option.

EDIT: Fixed some maybe unclear explanation.

Grife 05-06-2007 07:11 AM

So I should move single_click.diff to directory WindowMaker-0.92.0, and from there run command
Code:

patch -p0 <single_click.diff
Right? Then it checks that absolute path from there to WPrefs.app/Expert.c matches? And as it should match then, it will patch rest of the patchable files as well? Ok, I think I understood. Back to runlevel 3 and try it then. :) Thanks!

titopoquito 05-06-2007 07:17 AM

Leave the patch where it is and do
Code:

patch -p0 < contrib/single_click.diff
from within the Windows Maker source folder. Then patch looks if it finds the file ./WPrefs.app/Expert.c (relative path) and will apply the patch file.

Grife 05-06-2007 07:58 AM

Possibly that would have worked too, but I managed to patch it that way too (at least it told it's success). However, wmaker doesn't start. It tells "wmaker fatal error: could not open display "" ". Tried as root as well. Then wmaker --help, then checked manpage and tried to specify to use wmaker -display 0:0 (and 0:1, 0:2) but same thing. Uhh... How could I get more info than just that error or do you have any idea why it's doing that?

titopoquito 05-06-2007 08:05 AM

About the patch: The way you did it was totally ok, I just wanted to tell you that you can spare one step (copying the patch file).

I'm not sure on which system you want to start it. If you are doing this in Zenwalk it should be similar to the way it works in Slackware: Create a /etc/X11/xinit/xinitrc.wmaker file like this:
Code:

#!/bin/sh
# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f $userresources ]; then
    xrdb -merge $userresources
fi

if [ -f $usermodmap ]; then
    xmodmap $usermodmap
fi

# If the user lacks $HOME/GNUstep, install it:
if [ ! -f $HOME/GNUstep/Defaults/WindowMaker ]; then
    wmaker.inst
fi

# Test for cpp, which wmaker uses to process config files:
if [ ! -x /usr/bin/cpp ]; then
  NOCPP="--no-cpp"
fi

# Start the window manager:
exec /usr/bin/wmaker $NOCPP

Does Zenwalk have "xwmconfig" to choose the window manager? Else copy the file to your user's home directory as ".xinitrc". This way "startx" should fire up Window Maker as your gui IMHO

Grife 05-06-2007 09:00 AM

Hey it worked! After some head scratching I just changed path in your file to /usr/bin/local/wmaker

But this install of window maker is by far glitchiest I've ever seen! :D Window Maker preferences doesn't have pictures and text is missing from minimized apps. :D I'll check those xinitrc's again for some fails and such.


All times are GMT -5. The time now is 03:25 AM.