PDA

View Full Version : Problem creating patch file


roddierod
December 23rd, 2008, 18:43
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


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


I created the patch like this:

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

--- 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

amdmi3@
December 24th, 2008, 00:43
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):


% 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:

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!).

tingo
December 25th, 2008, 17:30
@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

roddierod
December 26th, 2008, 17:23
@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.

tingo
December 31st, 2008, 20:15
Also check out porttools (ports-mgmt/porttools), the 'port test' command is very helpful when creating a port. I just learned about porttools myself yesterday.

crsd
January 1st, 2009, 02:15
there's also 'makepatch' target, which checks ${WRKSRC} for *.orig files and creates diffs in /files/ accordingly