rschupp / PAR-Packer

(perl) Generate stand-alone executables, perl scripts and PAR files https://metacpan.org/pod/PAR::Packer
Other
48 stars 13 forks source link

OSX codesign binary fix and par.pl fix for codesigned OSX binaries #14

Closed plk closed 5 years ago

plk commented 5 years ago

This pull request adds a small exe for OSX which edits in-place a pp created exe to correct the Mach-O headers so that the OSX codesign utility will work.

There is also a small patch to par.pl so that Archive::Zip can find the EOCD in codesigned binaries. codesign adds around 180K to the binary and with the default 32K ChunkSize for Archive::Zip is not enough to allow the algorithm to find the EOCD in codesigned binaries. With this small fix, it works fine.

This will become a major issue soon as Apple is planning to make codesigning mandatory.

plk commented 5 years ago

Tidied up a bit, should be ok now.

plk commented 5 years ago

@rschupp - can we bump the signature window up again and do another release? I have just build a new project that required more --link statements and this increased the codesign appended data to 271K and it's broken again ... I think it's the checksum data that increases with the file size so how about bumping the Archive::Zip ChunkSize to 1024K? Or perhaps even making it configurable ... I don't think the PAR.pm signature matters as that seems to be an exe creation time setting (and there is also a creation time setting for the ChunkSize in par.pl which does not help the extraction issue).

Or, how about not looking backwards from the end of the exe for the EOCD of the zip but looking backwards from the \nPAR.pm\n sig since that will ignore the codesign stuff completely and I suppose that the EOCD is guaranteed to be before the PAR sig? Oh, I just realised that this isn't possible as that code is in Archive::Zip itself ... perhaps a configurable ChunkSize for extractions would be best then people could codesign, see what extra is added and then rebuild with the right ChunkSize?

plk commented 5 years ago

@rschupp - I have opened a new pull request - this fix turns out not to be general enough when the binary size increases - see new pull request - this should work for any size.