Howto apply a patch/diff file
Moderator: OpenTTD Developers
Re: Howto apply a patch/diff file
The output of "sed --version" and "which sed" may also be informative.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Re: Howto apply a patch/diff file
But I just want to apply some patch, not to build it.
I've installed Tortoise program. I make "SVN Checkout" with it, and it downloads this trunk, right? I don't know what version it is. Then I apply a patch and try to compile by Cygwin, but it won't. Even without applying a patch, same result.
PS.
GNU sed version: 4.1.5
which sed: /usr/bin/sed
I've installed Tortoise program. I make "SVN Checkout" with it, and it downloads this trunk, right? I don't know what version it is. Then I apply a patch and try to compile by Cygwin, but it won't. Even without applying a patch, same result.
PS.
GNU sed version: 4.1.5
which sed: /usr/bin/sed
-
- Chief Executive
- Posts: 697
- Joined: 10 Jun 2003 00:19
- Location: Australia
Re: Howto apply a patch/diff file
Well for the purpose of this discussion, build = compile. So yes, you do want to compile OTTD, and the error is about that, not about applying a patch.
You should always make sure you can compile an unpatched trunk before you try applying patches, if you can't compile an unpatched trunk, then you will almost certainly fail to compile one with a patch applied. So until you have sorted out building a clean trunk of OTTD, do not apply any patches.
First try typing "dos2unix config.lib" in the trunk folder. Try configure again and see if that fixes it (I suspect it wont).
Have you got subversion installed in cygwin (it looks like you haven't)? Install that and try again. If you still get the errors about sed, then type in "svn --info" into cygwin from the root of the trunk, and read off which revision you have. Also verify that "svn status" shows that you are using a clean trunk (if you need help understanding the output, read the output of "svn help status"). You can probably do all this svn stuff in TortoiseSVN too, but I don't know how cause I don't use TortoiseSVN.
If you get errors in configure, then upload "config.log" (rename it to config.txt if the forum complains about uploading .log files).
You should always make sure you can compile an unpatched trunk before you try applying patches, if you can't compile an unpatched trunk, then you will almost certainly fail to compile one with a patch applied. So until you have sorted out building a clean trunk of OTTD, do not apply any patches.
First try typing "dos2unix config.lib" in the trunk folder. Try configure again and see if that fixes it (I suspect it wont).
Have you got subversion installed in cygwin (it looks like you haven't)? Install that and try again. If you still get the errors about sed, then type in "svn --info" into cygwin from the root of the trunk, and read off which revision you have. Also verify that "svn status" shows that you are using a clean trunk (if you need help understanding the output, read the output of "svn help status"). You can probably do all this svn stuff in TortoiseSVN too, but I don't know how cause I don't use TortoiseSVN.
If you get errors in configure, then upload "config.log" (rename it to config.txt if the forum complains about uploading .log files).
Re: Howto apply a patch/diff file
revision: 15383
svn status:
src/3rdparty/squirrel - item is unversioned, but is used by an externals definition
svn status:
src/3rdparty/squirrel - item is unversioned, but is used by an externals definition
- Attachments
-
- config.txt
- (5.47 KiB) Downloaded 74 times
-
- Chief Executive
- Posts: 697
- Joined: 10 Jun 2003 00:19
- Location: Australia
Re: Howto apply a patch/diff file
If that's all svn status said, then you do indeed have a clean trunk. That logfile was less help than I hoped, did you still get that sed error?
-
- Chief Executive
- Posts: 697
- Joined: 10 Jun 2003 00:19
- Location: Australia
Re: Howto apply a patch/diff file
Well I'm going to assume you did get the error.
Please run this command from the trunk directory.
This command will trace configure as it runs and save the output into a file called config.dump (which you can change if you want). This file will be fairly big as far as text files go (mine is about 450 KB), you may wish to compress it. Please upload this file (which will probably need to be renamed if you didn't compress it).
Please run this command from the trunk directory.
Code: Select all
sh -x configure 1> config.dump 2>&1
Re: Howto apply a patch/diff file
Here you are.
- Attachments
-
- config.rar
- (13.98 KiB) Downloaded 71 times
-
- Chief Executive
- Posts: 697
- Joined: 10 Jun 2003 00:19
- Location: Australia
Re: Howto apply a patch/diff file
Ok, I found the problem.
Whoever wrote the configure script is using '~' as the separator to the 's' command of sed. Apparently the pwd command of cygwin outputs the short name of Program Files (which is progra~1) instead of the long name. This is confusing sed. What puzzles me is why it uses the short name of Program Files, but it uses svn.openttd.org in full.
I don't know enough about windows/cygwin to know if these are the only fixes, but here are some:
* The devs (or you as a workaround) change the sed command so that it uses a different separator.
* You use a different directory to store your source in. I think I have read somewhere that configure doesn't work if there is a space in the path. That may be this error or a different one.
Whoever wrote the configure script is using '~' as the separator to the 's' command of sed. Apparently the pwd command of cygwin outputs the short name of Program Files (which is progra~1) instead of the long name. This is confusing sed. What puzzles me is why it uses the short name of Program Files, but it uses svn.openttd.org in full.
I don't know enough about windows/cygwin to know if these are the only fixes, but here are some:
* The devs (or you as a workaround) change the sed command so that it uses a different separator.
* You use a different directory to store your source in. I think I have read somewhere that configure doesn't work if there is a space in the path. That may be this error or a different one.
Re: Howto apply a patch/diff file
Please come with an easily distinguishable and easily typeable character that doesn't have any side effects; / is in paths, \ too. '.' is a special character, so are []{}()*^`. '!' isn't easily distinguishable, # is for comments, @ is used as marker in some files, $ is used for parameters, % can give problems when a $ is before it. |, < and > are used for piping data.Conditional Zenith wrote:* The devs (or you as a workaround) change the sed command so that it uses a different separator.
See... the dilemma?
-
- Chief Executive
- Posts: 697
- Joined: 10 Jun 2003 00:19
- Location: Australia
Re: Howto apply a patch/diff file
I do see the dilema. Maybe I am being a bit slow at the moment, but a lot of them can be solved by quoting the sed expression with single quotes (which were already being used everywhere I looked). Single quotes stop the shell interpreting any characters except "\" and "'" IIRC, and I already see that '#' is used as a separator to some other 's' commands.
Re: Howto apply a patch/diff file
Single quotes aren't always used; there are places where we want to used $vars in the sed expression. Using # in the sed expression has proven that not all sh implementations ignore the # inside quoted text.
-
- Chief Executive
- Posts: 697
- Joined: 10 Jun 2003 00:19
- Location: Australia
Re: Howto apply a patch/diff file
Have you considered ':' (this just came to me, I wasn't holding it back or anything)? While I haven't tested all sed implementations, it seems to work for GNU sed, which is certainly the most common sed implementation.
Re: Howto apply a patch/diff file
That'd work fine on most OSes where ~ works, but not on the OS where ~ doesn't work; e.g. C:\Progra~1\
-
- Chief Executive
- Posts: 697
- Joined: 10 Jun 2003 00:19
- Location: Australia
Re: Howto apply a patch/diff file
Good point. Why can't windows just disappear? 
Ok, another suggestion: '*'. And reading through your first post again, I'm not seeing why '@' wont work. The content of the files sed works on shouldn't matter, all that should matter is if sed interprets is specially, it appears in the sed patterns, or the shell interprets it.
Once again, I have tested both of these with bash and GNU sed, not sure if it will work everywhere.

Ok, another suggestion: '*'. And reading through your first post again, I'm not seeing why '@' wont work. The content of the files sed works on shouldn't matter, all that should matter is if sed interprets is specially, it appears in the sed patterns, or the shell interprets it.
Once again, I have tested both of these with bash and GNU sed, not sure if it will work everywhere.
Re: Howto apply a patch/diff file
Have you any idea how sed works? '*' is used as wildcard for: the previous 'token' 0 or more times. As I said before we use @ as token in the *.in files to replace.
-
- Chief Executive
- Posts: 697
- Joined: 10 Jun 2003 00:19
- Location: Australia
Re: Howto apply a patch/diff file
Yes I know how regular expressions (and consequently sed) work, and near as I can tell '*' is not used in any sed expressions in the configure system currently, and the main (only?) time that '~' seems to be a problem is in paths, where I don't see '*' (or any special regexp characters) being used. It could be needed later, and on second thoughts using any special character is risky.
Regarding '@', I can't see it appearing in any sed expressions in configure and related scripts. No one says the same separator has to be used in every expression, in the few cases where @ doesn't work (by my reckoning this is only a couple of times in objs/release/Makefile) then '~' can be used. I agree that nothing will work in every single 's' command (it would be convenient if it did), but I haven't come across an 's' command in the OTTD build system where every single issue that you raise is a potential problem.
edit: And is there some reason '&' doesn't work? Yes you will need to make sure you keep quoting every sed expression, which I assume isn't too onerous.
Regarding '@', I can't see it appearing in any sed expressions in configure and related scripts. No one says the same separator has to be used in every expression, in the few cases where @ doesn't work (by my reckoning this is only a couple of times in objs/release/Makefile) then '~' can be used. I agree that nothing will work in every single 's' command (it would be convenient if it did), but I haven't come across an 's' command in the OTTD build system where every single issue that you raise is a potential problem.
edit: And is there some reason '&' doesn't work? Yes you will need to make sure you keep quoting every sed expression, which I assume isn't too onerous.
Re: Howto apply a patch/diff file
HELP!!!
Followed the instructions on page 1, but I must be doing something wrong???
Whenever I try to install the patch it does not work, as shown below.
Which folder do you install the patch into as I am getting very confused. And sorry for being thick but when it says source codes, which files are these?

Followed the instructions on page 1, but I must be doing something wrong???
Whenever I try to install the patch it does not work, as shown below.
Which folder do you install the patch into as I am getting very confused. And sorry for being thick but when it says source codes, which files are these?




- Attachments
-
- screenz 2009.gif
- Screen 1
- (141.67 KiB) Downloaded 59 times
-
- screenz 2009B.gif
- Screen 2
- (116.15 KiB) Downloaded 45 times
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Howto apply a patch/diff file
It's always very tiresome to read "I did everything exactly as I should, but it doesn't work". Obviously the statement in 99% of the cases isn't true.
It's WAY more effective, if you describe _what_ you have done (in detail!) with which software (which versions, OS), etc...
Just a hint.
It's WAY more effective, if you describe _what_ you have done (in detail!) with which software (which versions, OS), etc...
Just a hint.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
-
- Chief Executive
- Posts: 697
- Joined: 10 Jun 2003 00:19
- Location: Australia
Re: Howto apply a patch/diff file
Apart from what planetmaker said, google/wikipedia is your friend to find out what source code is.
On another note, I'm beginning to think this thread needs to be redone. It assume too much knowledge from the people who try to use it. Many people come here not knowing that they need to get the source code and be able to compile it. And still more try to compile after the patch failed to apply, probably becuase they don't realise it failed.
On another note, I'm beginning to think this thread needs to be redone. It assume too much knowledge from the people who try to use it. Many people come here not knowing that they need to get the source code and be able to compile it. And still more try to compile after the patch failed to apply, probably becuase they don't realise it failed.
Re: Howto apply a patch/diff file
Most people come here with the inclination that a patch is the same as patching any other commercial game they've bought. I don't blame them. The term is common place. I think a sticky should be made explaining this in big bold letters.
Who is online
Users browsing this forum: No registered users and 9 guests