Stuck on patching with unified diff file: Kismet on Raspberry Pi
Hi, I've been trying to get Kismet working nicely on my raspberry pi, and have come across the need to apply a patch that someone posted in the Kismet forums (link and patch are pasted below).
First off, I assume that the patch is created as a text file (GPSPatch.diff) in my case, then applied to the source code using a command like: patch -uNp1 -i GPSPatch.diff then I recompile using (sudo) ./configure make make install If that's not how to patch a program that's already compiled, if someone can put me on the right path, I'd appreciate it greatly. Assuming I'm right so far: When I invoke: patch -uNp1 --dry-run --verbose -i GPSPatch.diff I get errors. The first seems to just be related to indentation (****malformed patch at [lines not indented]) So, after I fix the indentation, that error goes away, and if I run the command again, I get this: patch: **** malformed patch at line 11: long aggregate_points; which I think I can fix with changing (line numbers added by me): Code:
4 @@ -183,7 +183,7 @@ Code:
4 @@ -183,9 +183,9 @@ Code:
4 @@ -183,7 +183,7 @@ SO, once I get the first two errors to go away, I get this: **** malformed patch at line 13: diff -Naur orig/util.cc new/util.cc which refers to this line: diff -Naur orig/util.cc new/util.cc Is this because I need to break this patch up into individual files before applying them? It seems like it, but I'd like to know if there's an easier way. From what little I know about Linux, it always seems like there's an easier way... Thanks as always to anyone who offers assistance! Kevin The Link: https://www.kismetwireless.net/Forum...1016156.530417 The patch contained in the link: This patch fixes the problem by using a bigger integer type. Verified on a raspberry pi but the problem should be present on all plattforms where 32-bit integers actually are 32-bit. The comments regarding number range is not corrected. Code:
|
|
Hmm, I'm afraid I'm going to need a bit more explanation than that.
Kevin |
Sorry. That was a bit of a drive by as I didn't have much time.
AFAIK the format of the patch file has to exactly match the format of the file being patched. All lines that do not begin with +, - or @ have to have a space in the first column. In copy/pasting from a browser you lose all of the white space formating at the beginning of lines. I don't have access to the source files but when I paste the file from the forum into an editor the line being changed in gpscore.h has a tab after the +/- sign. A tab is not a space, so if the lines above and below the change have tabs, you need a space and then a tab on those lines. Quote:
Code:
@@ -183,7 +183,7 @@ |
Try including the "-l" option on the patch command. From the manpage:
-l or --ignore-whitespaceYou may still need a proper space at the beginning of each line that does not begin with "+ " or "- ".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. |
Ha! Thank you very much for elaborating Norobro. That's very helpful. rknichols, thanks also for the tip. Unfortunately, I won't get back to this one until the evening, but I feel like I now have enough to go on so that I can apply this patch properly. I'd hate to resort to brute force when I know there is a higher path to learn.
Thanks again! Kevin |
OK, I couldn't help but give it a quick try this morning. I edited with vim, and made sure all the spaces were in their proper places, but it still fails at the second diff statement with:
Code:
patch: **** malformed patch at line 13: diff -Naur orig/util.cc new/util.cc Am I missing something on what needs to happen when the second diff line is called? Thanks, Kevin |
patch should just ignore that line 13 as "trailing garbage" after the successful first patch. I see you are using the "--verbose" option. Was anything reported besides the error?
|
1 Attachment(s)
Thanks for the -l tip @rknichols. I need to read man pages more thouroghly.
Kevin, I downloaded the kismet source and got the attached patch file to work. It is only for the first two files (gpscore.h and util.cc). Using: Code:
patch -p1 -l -i partialpatch.diff Also, in testing I found that the patch fails if you do not have a space (or tab) after the +/- sign if the original file has a space or tab. Edit 2: Never mind. I tried so many combinations I confused myself. HTH Norm Edit: Forum will not accept a file with diff as extension. |
Wow, thank you very much Norm! I just tried the partial, and it should give me the basis I need to make this thing work. Thank you again.
I'm always impressed by the helpfulness of others, on this and many other forums. Thank you LQ!! Now, off to patching; between that, and another hour of reading about patch and diff, I'll be on my way to understanding another facet of Linux administration. Thanks again, Kevin |
All times are GMT -5. The time now is 08:16 AM. |