patch command

mciv
Posts: 70
Joined: Mon Feb 02, 2009 9:52 am
Location: Augusta, ME

patch command

Postby mciv » Fri May 29, 2009 12:52 pm

I've got a patch problem I can't figure out. I've created a diff file that works from the command line.

Code: Select all

patch -i my.diff config.inc.php
But when I include the patch command inside a script it fails in three places. My guess is some weird spacing issue but I'm stumped as to how to correct it. This is the patch part of the script.

Code: Select all

--- config.inc.php 2009-05-29 01:01:39.000000000 -0400 +++ config.inc.php.new 2009-05-29 10:30:31.000000000 -0400 @@ -26,7 +26,7 @@ * * @var global constant */ - define("DB_USERNAME", "root"); + define("DB_USERNAME", "badgerbank"); /** * Database password @@ -34,7 +34,7 @@ * @var global constant */ - define("DB_PASSWORD", ""); + define("DB_PASSWORD", "badgerbank"); /** * Database host address @@ -69,4 +69,4 @@ // Report ALL Errors error_reporting(E_ALL); -?> +?>

gmw
Posts: 104
Joined: Tue Dec 09, 2008 12:42 pm
Location: Northern California
Contact:

Re: patch command

Postby gmw » Fri May 29, 2009 1:28 pm

How exactly do you include it in the script?
I have had issues with quotes sometimes

eg. whether to use:

patch -p0 -f -E << 'EOF'
<patch content>
EOF

OR

patch -p0 -f -E << EOF
<patch content>
EOF

I am not aware of all the subtleties myself :roll:

mciv
Posts: 70
Joined: Mon Feb 02, 2009 9:52 am
Location: Augusta, ME

Re: patch command

Postby mciv » Fri May 29, 2009 1:33 pm

I've tried it multiple ways. With quotes. Without quotes.

gmw
Posts: 104
Joined: Tue Dec 09, 2008 12:42 pm
Location: Northern California
Contact:

Re: patch command

Postby gmw » Fri May 29, 2009 1:37 pm

Have you checked silly things (like being in the right directory, or that the file has the right permissions).

Note: one-click install scripts run as apache user

mciv
Posts: 70
Joined: Mon Feb 02, 2009 9:52 am
Location: Augusta, ME

Re: patch command

Postby mciv » Fri May 29, 2009 1:43 pm

At this point I'm just running a local script and all the other commands such as wget and tar work correctly. Patch appears to find the file so I think the directory is ok. It just fails at each of three hunks.

User avatar
cpg
Administrator
Posts: 2618
Joined: Wed Dec 03, 2008 7:40 am
Contact:

Re: patch command

Postby cpg » Sun Jun 21, 2009 8:59 pm

did you make any progress on this?

this part (when hunks fail), is particularly difficult. wish we could make it easier ...

a patch is really the output of

Code: Select all

diff -u
fed to the patch program, like this:

Code: Select all

patch -p0 -l <<'EOF' ... output of diff -u ... EOF
one tricky thing is that if the 'EOF' is not put with quotes around it (i.e. just EOF), then there will be extension of $variables inside the patch code.

in many cases of patching php and similar languages, that can create havoc.
My HDA: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz on MSI board, 8GB RAM, 1TBx2+3TBx1

gmw
Posts: 104
Joined: Tue Dec 09, 2008 12:42 pm
Location: Northern California
Contact:

Re: patch command

Postby gmw » Sun Jun 21, 2009 9:13 pm

The issue in this case ended up being some invisible characters (linefeeds and tabs in particular).

That said, the application itself is very buggy.

Who is online

Users browsing this forum: No registered users and 12 guests