Re: Patching PHP


Subject: Re: Patching PHP
From: James Gibson (twistedhammer@subdimension.com)
Date: Wed Jul 24 2002 - 13:28:58 AKDT


On Wed, 24 Jul 2002, Jon Reynolds wrote:
> How exactly do you patch an application on your machine? I want to apply the
> patch to php-4.2.1 for the security update but am finding it hard to locate
> an example of the command to type. So far this is what I am trying to
> execute 'patch -p0 --check < /path/to/patch'. When I enter this i get the
> text that this looks like a 'unified diff' and then it ask me which file(s)
> do I want to patch. At this point I don't know which files need to be
> patched. I have put the patch which is named 'php-4.2.1-to-4.2.2.patch' in
> the directory where I gunzipped and tarred it. Do I just need to make it an
> executable and run it?

All a patch is is a unified diff of a source-code tree. Generally speaking
in linux you don't patch binaries (executables), you patch the source-code
and then re-compile. On an rpm based system, you might want to look into
installing an srpm, and then using to .spec file to generate an rpm from
your patched source-tree.

if I'm comletely missing the point an you are having problems applying the
diff to a source tree, you might need to tke a look at the patch and
modify the -pn option to suit.. many patches need -p1

The -p option strips slashes (and the directories to the left of them)
from the _left_ side of th pathnames in the diff. if you have the -p
option wrong it can't autodetect which file a given portion of the patch
needs to be applied to. (e.g. php-foo-version/src/main.c remains the same
with -p0; with -p1 it becomes src/main.c; with -p2 it becomes main.c)

--James

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Wed Jul 24 2002 - 13:35:18 AKDT