mkgmap build process: how to apply patches

Moin, I am trying to attend the mkgmap devellopment, but I have still some trouble with the build process, partly because I am also not familiar with the Linux environment. As a start I installed Suse Linux and the Eclipse IDE. First step was downloading the source package from the mkgmap download page, extracting this package into a folder, creating an ANT-project in Eclipse and finally building mkgmap. Ok, this worked. Second step was using kdesvn and retrieving the sources from svn-trunk via subversion instead of downloading the source package. On this working copy I was again able to build mkgmap via an ANT-Eclipse-Project. But I haven't figured out yet, how to integrate a patch provided via this list into my build process. Can anybody give me some advise, how to use the patches? Gruss Torsten

Hi Torsten,
I am trying to attend the mkgmap devellopment, but I have still some trouble with the build process, partly because I am also not familiar with the Linux environment.
You don't have to use Linux. I do but other people use Windows or Macs.
As a start I installed Suse Linux and the Eclipse IDE.
First step was downloading the source package from the mkgmap download page, extracting this package into a folder, creating an ANT-project in Eclipse and finally building mkgmap. Ok, this worked.
Second step was using kdesvn and retrieving the sources from svn-trunk via subversion instead of downloading the source package. On this working copy I was again able to build mkgmap via an ANT-Eclipse-Project.
But I haven't figured out yet, how to integrate a patch provided via this list into my build process. Can anybody give me some advise, how to use the patches?
Patches can be applied using the "patch utility". The trick with patches is making the filenames that are in the patch, match the files in the current working directory (and below). In the simplest case, you can say (on the Linux command line) patch < patchfile. But often, it will complain that it can't find the patch and then you have to either change into a lower subdirectory, and/or use the -p option to patch to tell it to strip prefix directories from the patch filenames. E.g. patch -p1 < patchfile. I always make a new branch before I apply a patch someone has posted because then if it all goes wrong it doesn't affect my master branch or any of my development branches. If the patch is good, I can always merge it into other branches later. I don't use svn but git which makes all this branching/merging stuff stress free. E.g. git branch test-branch (make a new branch based on current branch) git checkout test-branch (check out new branch) patch -p1 < some-patch (apply the patch) test/edit/commit/etc. (frig around with patch till satisfied it's good) git checkout master (go back to master branch) git merge test-branch (merge in the test branch to master) I don't know about svn but git makes it very easy to have any number of branches which you can switch between in an instant and merge together. Also it's (generally) trivial to maintain development branches that can be "rebased" on top of the latest master branch so that as the master gets updated with new commits, you can update your development branches to incorporated those commits without losing the branch structure. And, of course, you have the full development history available all the time. I digress. Cheers, Mark

Thanks for your hints, Mark. Ususally my development tools are dictated by the confi-management, so having the choice is a new experience for me (I hope, I don't get used to it :-) I will also take a look at git, as long as I do not have any experience with either tool, there is no overhead involved in a change. Gruss Torsten

Mark Burton schreef:
option to patch to tell it to strip prefix directories from the patch filenames. E.g.
patch -p1 < patchfile.
... and if you cut and paste patches from an e-mail, you might want to use "patch -p1 -l", which means: -l or --ignore-whitespace Match patterns loosely, in case tabs or spaces have been munged in your files. Any sequence of one or more blanks in the patch file matches any sequence in the original file, and sequences of blanks at the ends of lines are ignored. Normal characters must still match exactly. Each line of the context must still match a line in the original file. V. -- Durgerdamstraat 29, 1507 JL Zaandam; telefoon 075-7074579

Chris-Hein Lunkhusen schreef:
Does it matter if the patch is in unix (lf) or dos (cr/lf) format?
"man patch" tells me: If the entire diff is indented by a consistent amount, or if a context diff contains lines ending in CRLF or is encapsulated one or more times by prepending "- " to lines starting with "-" as specified by Internet RFC 934, this is taken into account. So I think it doesn't matter for the patch. Why anyone would want lines end in cr/lf is a wholly different discussion ;-) V. -- Durgerdamstraat 29, 1507 JL Zaandam; telefoon 075-7074579

Valentijn Sessink schrieb:
So I think it doesn't matter for the patch. Why anyone would want lines end in cr/lf is a wholly different discussion ;-)
The patch I am playing with right now (sea patch 4a) was in crlf when I stored the attachment from thunderbird (under XP). When I did the same under linux, the file was in unix mode. So, with "patch -p0" I was able to patch R1136 with the seapatch-4a and hopefully I will get a germany map with sea polygons tomorrow. Chris

Chris-Hein Lunkhusen schreef:
So, with "patch -p0" I was able to patch R1136 with the seapatch-4a and hopefully I will get a germany map with sea polygons tomorrow.
Please be aware, that patch will spit out various messages when something goes wrong. When a patch is simply a few lines further in the file, it will apply with a "fuzz detected..." message. And if it fails, patch will tell you so, too. So, generally speaking, if you know what you're doing, patch is a fine tool to let go on your source code. Oh, and if things go really wrong, you can always use patch -R, which means: reverse the working of the patch (i.e. get the original file back, if you didn't edit it in between). V. -- Durgerdamstraat 29, 1507 JL Zaandam; telefoon 075-7074579
participants (4)
-
Chris-Hein Lunkhusen
-
Mark Burton
-
Torsten Leistikow
-
Valentijn Sessink