View Full Version : Which Diff/Merge/Patch/Updater tool?


pdurrant
12-17-2008, 09:30 AM
OK, I now have a new patch for MobiDeDRM, to cope with some (all?) of the very small number of books that don't work with 0.04.

After my previous patch instructions, there were several messages suggesting that using a diff program would be a good idea, rather than manual instructions.

I have looked. I have not found any diff/merge/patch/updater tool that meet the all requirements.

1. At least Mac OS X 10.4/10.5 and Windows XP/Vista support
2. Handles files with CRLF line endings correctly
3. Free

The tool(s) must take File A and File B and produce a File C, and then be able to take File A and File C and produce File B.

Suggestions welcome. Please try to ensure your suggestion meets all three requirements.

TS-Rick
12-17-2008, 12:11 PM
We used Kdiff3 with the Mercurial DSCM (Distributed Source Control Management) system aka hg. This is free, works on Mac OS X and Windows (XP for user - don't use Vista)

Requirements:

1. not sure about vista or 10.4
2. Not sure
3. Free

Home page: http://kdiff3.sourceforge.net/

sorry about lack of information. We use Xcode with Mercurial now.

Cheers,

Rick

llasram
12-17-2008, 12:44 PM
Suggestions welcome. Please try to ensure your suggestion meets all three requirements.

How about standard GNU diff and patch? Native for Linux and OS X, via MSYS or Cygwin for Windows.

Gudy
12-17-2008, 02:44 PM
How about standard GNU diff and patch? Native for Linux and OS X, via MSYS or Cygwin for Windows.

Seconded. Have it produce a size-optimized, unified diff (Options -ud) and post the results. The unified diff file works both with GNU patch on any of the platforms where it is available/can be compiled, and is also the most easily human-readable of the various diff formats, IMO, so it also works well as instructions for applying the patch manually.

pdurrant
12-17-2008, 03:10 PM
Because I haven't been able to get diff and patch to work, and checking around this seems to be because it doesn't work with CRLF files. Here's what I get in terminal (Mac OS X 10.5.6). Tell me what I'm doing wrong.

paul:Mobipocket Manipulation pdurrant$ diff -ud MobiDeDRM002.py MObiDeDRM005.py > patch2to5.txt
paul:Mobipocket Manipulation pdurrant$ patch -i patch2to5.txt -out MobiDeDRM005new.py MobiDeDRM002.py
patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input.
paul:Mobipocket Manipulation pdurrant$ cat patch2to5.txt
--- MobiDeDRM002.py 2008-03-12 20:01:44.000000000 +0000
+++ MObiDeDRM005.py 2008-12-16 21:23:03.000000000 +0000
@@ -4,6 +4,9 @@
# Changelog
# 0.01 - Initial version
# 0.02 - Huffdic compressed books were not properly decrypted
+# 0.03 - Wasn't checking MOBI header length
+# 0.04 - Wasn't sanity checking size of data record
+# 0.05 - It seems that the extra data flags take two bytes not four

import sys,struct,binascii

@@ -60,6 +63,8 @@
def getSizeOfTrailingDataEntries(ptr, size, flags):
def getSizeOfTrailingDataEntry(ptr, size):
bitpos, result = 0, 0
+ if size <= 0:
+ return result
while True:
v = ord(ptr[size-1])
result |= (v & 0x7F) << bitpos
@@ -133,7 +138,11 @@

sect = self.loadSection(0)
records, = struct.unpack('>H', sect[0x8:0x8+2])
- extra_data_flags, = struct.unpack('>L', sect[0xF0:0xF4])
+ mobi_length, = struct.unpack('>L',sect[0x14:0x18])
+ extra_data_flags = 0
+ if mobi_length >= 0xE4:
+ extra_data_flags, = struct.unpack('>H', sect[0xF2:0xF4])
+

crypto_type, = struct.unpack('>H', sect[0xC:0xC+2])
if crypto_type != 2:
@@ -162,7 +171,7 @@
def getResult(self):
return self.data_file

-print "MobiDeDrm v0.02. Copyright (c) 2008 The Dark Reverser"
+print "MobiDeDrm v0.05. Copyright (c) 2008 The Dark Reverser"
if len(sys.argv)<4:
print "Removes protection from Mobipocket books"
print "Usage:"
paul:Mobipocket Manipulation pdurrant$

Seconded. Have it produce a size-optimized, unified diff (Options -ud) and post the results. The unified diff file works both with GNU patch on any of the platforms where it is available/can be compiled, and is also the most easily human-readable of the various diff formats, IMO, so it also works well as instructions for applying the patch manually.

pdurrant
12-17-2008, 03:15 PM
Oh - found it. wrong parameter in the patch command.

I'll look at kdiff3 too. Thanks.

Paul

tell me what I'm doing wrong.

pilotbob
12-17-2008, 04:33 PM
Oh - found it. wrong parameter in the patch command.

I'll look at kdiff3 too. Thanks.

Paul

It would probably just be easier to put the patched file "somewhere" that it can be got from. The file it self isn't that big. Yes, I know you are not doing a patch to save space.

On my Mac I actually had to convert the file endings to get it to run properly with a shebang. I used [Mac]Vim.

BOb

pdurrant
12-17-2008, 05:31 PM
Apart from the legality of MobiDeDRM in the USA and possible elsewhere, I'm unhappy about redistributing someone else's code.

I have now come up with a solution I'm happy with - an easy AppleScript for Mac users, and instructions or a diff file for everyone else. :-)

See http://www.mobileread.com/forums/showthread.php?p=309292

Paul

It would probably just be easier to put the patched file "somewhere" that it can be got from. The file it self isn't that big. Yes, I know you are not doing a patch to save space.

On my Mac I actually had to convert the file endings to get it to run properly with a shebang. I used [Mac]Vim.

BOb

bwaldron
12-17-2008, 05:59 PM
It would probably just be easier to put the patched file "somewhere" that it can be got from.

I wouldn't presume to ask someone to put themself at risk by distributing DRM removal software. :)

pilotbob
12-17-2008, 06:26 PM
I wouldn't presume to ask someone to put themself at risk by distributing DRM removal software. :)

This is the problem. However there is alot of copyrighted stuff out on the net so no one would really be distributing it.

ConvertLit even has it's own web site. Maybe it if was called ConvertMobi and the description was "allows you to convert Mobipocket Reader format eBooks into open format for use with software or devices which are not directly compatible with Mobipocket Reader"... :smack:

BOb

llasram
12-17-2008, 08:38 PM
ConvertLit even has it's own web site. Maybe it if was called ConvertMobi and the description was "allows you to convert Mobipocket Reader format eBooks into open format for use with software or devices which are not directly compatible with Mobipocket Reader"...

Possibly... ConvertLIT.com appears to be hosted in Poland, and on its "legal" page notes that Poland doesn't "currently" have anything like the US DMCA or the EU Copyright Directive. Except that Poland became a full member of the EU in May of 2004. Doh! I'm guessing just no one cares enough to go after it. Heck, it probably boosts sales of MS LIT books -- I know ConvertLIT is why I buy them.