Howto apply a patch/diff file

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Howto apply a patch/diff file

Post by DaleStan »

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
User avatar
snowie
Engineer
Engineer
Posts: 14
Joined: 06 Feb 2009 18:09
Location: Kraków, Poland
Contact:

Re: Howto apply a patch/diff file

Post by snowie »

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
Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Re: Howto apply a patch/diff file

Post by Conditional Zenith »

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).
User avatar
snowie
Engineer
Engineer
Posts: 14
Joined: 06 Feb 2009 18:09
Location: Kraków, Poland
Contact:

Re: Howto apply a patch/diff file

Post by snowie »

revision: 15383

svn status:
src/3rdparty/squirrel - item is unversioned, but is used by an externals definition
Attachments
config.txt
(5.47 KiB) Downloaded 75 times
Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Re: Howto apply a patch/diff file

Post by Conditional Zenith »

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?
Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Re: Howto apply a patch/diff file

Post by Conditional Zenith »

Well I'm going to assume you did get the error.

Please run this command from the trunk directory.

Code: Select all

sh -x configure 1> config.dump 2>&1
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).
User avatar
snowie
Engineer
Engineer
Posts: 14
Joined: 06 Feb 2009 18:09
Location: Kraków, Poland
Contact:

Re: Howto apply a patch/diff file

Post by snowie »

Here you are.
Attachments
config.rar
(13.98 KiB) Downloaded 72 times
Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Re: Howto apply a patch/diff file

Post by Conditional Zenith »

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.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Howto apply a patch/diff file

Post by Rubidium »

Conditional Zenith wrote:* The devs (or you as a workaround) change the sed command so that it uses a different separator.
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.

See... the dilemma?
Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Re: Howto apply a patch/diff file

Post by Conditional Zenith »

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.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Howto apply a patch/diff file

Post by Rubidium »

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.
Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Re: Howto apply a patch/diff file

Post by Conditional Zenith »

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.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Howto apply a patch/diff file

Post by Rubidium »

That'd work fine on most OSes where ~ works, but not on the OS where ~ doesn't work; e.g. C:\Progra~1\
Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Re: Howto apply a patch/diff file

Post by Conditional Zenith »

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.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Howto apply a patch/diff file

Post by Rubidium »

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.
Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Re: Howto apply a patch/diff file

Post by Conditional Zenith »

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.
MS2009
Engineer
Engineer
Posts: 8
Joined: 13 Feb 2009 19:29

Re: Howto apply a patch/diff file

Post by MS2009 »

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? :oops: ?( :?: :bow:
Attachments
screenz 2009.gif
Screen 1
(141.67 KiB) Downloaded 59 times
screenz 2009B.gif
Screen 2
(116.15 KiB) Downloaded 45 times
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Howto apply a patch/diff file

Post by planetmaker »

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.
Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Re: Howto apply a patch/diff file

Post by Conditional Zenith »

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.
flowover
Engineer
Engineer
Posts: 61
Joined: 24 Jun 2008 05:51

Re: Howto apply a patch/diff file

Post by flowover »

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.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google [Bot] and 8 guests