Problem creating patch file

I am working on a port of screenlets and I'm having trouble with get the patch file to apply when I try and build the port.

When it comes time to apply the patches the port stops like this

Code:
Applying FreeBSD patches for screenlets-0.1.2_1
File to patch:

I created the patch like this:
Code:
 diff -ruN screenlets/src/bin/screenlets.orig screenlets/src/bin/screenlets > ../files/patch-screenlets

I'm using FreeBSD 7.1 Prerelease built Dec 13th.

this is one of the patch files, patch-screenlets
Code:
--- screenlets.orig     2008-06-04 08:31:25.000000000 -0400
+++ screenlets  2008-12-23 11:42:10.000000000 -0500
@@ -1,5 +1,5 @@
 #!/bin/sh
-PREFIX=$(cat /etc/screenlets/prefix)
+PREFIX=/usr/local
 if [ -e $PREFIX/share/screenlets-manager/screenlets-manager.py ]; then
        exec python -u $PREFIX/share/screenlets-manager/screenlets-manager.py $@
 else
 
Patches should be relative to ${PATCH_WRKSRC} which I assume is work/screenlets in your case.

Thus the correct patch would be (note path in +++ line):

Code:
% diff -u src/bin/screenlets.orig src/bin/screenlets 
--- src/bin/screenlets.orig	2008-12-24 02:36:29.000000000 +0300
+++ src/bin/screenlets	2008-12-24 02:36:37.000000000 +0300
@@ -1,5 +1,5 @@
 #!/bin/sh
-PREFIX=$(cat /etc/screenlets/prefix)
+PREFIX=/usr/local
 if [ -e $PREFIX/share/screenlets-manager/screenlets-manager.py ]; then
 	exec python -u $PREFIX/share/screenlets-manager/screenlets-manager.py $@
 else

But, actually you should not use patch in this case at all.

I'd recommend this:

Code:
post-patch:
    @${REINPLACE_CMD} -e '/^PREFIX=/ s|=.*|=${PREFIX}|' \
        ${WRKSRC}/src/bin/screenlets

Note that this is shorter, easier to handle and it respects PREFIX (it should!).
 
@roddierod:
I prefer patchtool (/usr/ports/Tools/scripts/patchtool.py and /usr/ports/Tools/scripts/README.patchtool) for creating patches when I try to fix things in ports.
To make it easier to use I have set up an alias for it:
alias patchtool='/usr/ports/Tools/scripts/patchtool.py '
(yes, I use /bins/sh as my shell.)
HTH
 
@tingo:
thank you very much this makes things so much easier, especially with the number of patches I have to make for this port.

@amdmi3@:
I tried using the post-patch code you suggested, but I could not get that to work for me.
 
Back
Top