Fink:Major New Feature Plans:Patchfile Checksums
Jump to navigation
Jump to search
Current implementation
Syntax
Automatic application via an implicit patch -p1 < %a/foo.patch
Patch: foo.patch
and/or usage in explicit scripts:
PatchScript: sed 'some script' < %a/foo.patch | patch -p1
Problems
- No detection of corrupted patchfile.
- No protection against CVS problems that cause a .info to use the wrong revision of a .patch.
- If multiple .info use a common .patch, all maintainers of the .info have to coordinate their updates.
- In the PatchScript/sed usage, package building does not abort if the patchfile is missing or not readable(!).
- Feature-requests tracker #979713.
- Bugs tracker #1204001
- Fink-devel discussion.
- Fink-devel discussion a long time ago
Solution in CVS HEAD
Goals
- Old fink will fail hard if it attempts to use an .info file with the new syntax if that would succeed but give an incorrect build) if a
BuildDepends:finkfor the relevant fink version is accidentally omitted. Rather not resort to bumping to a newInfoNlevel. - Explicitly state the patchfile filename so that fink can check that it exists, is readable, and is the maintainer-expected contents.
- Don't need strong checksumming (patchfile is stored on same server as infofile that lists the checksum).
- Quicker implementation and easier adoption than XMLish Source and Patch.
Syntax
Patchfile: foo.patch PatchFile-MD5: hash-string
- A new
%{PatchFile}would expand to the full path to the patchfile (%a/foo.patchin the old syntax). - The
%{default_script}forPatchScriptcontains thepatchcommand to apply it. The only change in fink behavior vs old fields is that if there wasPatchand an explicitPatchScript, will have to modifyPatchScriptto apply the patch instead of simply converting thePatchfield toPatchFile. - Could expand to
PatchFileNandPatchFileN-MD5if we want to continue to support multiple patchfiles.
Implementation
- At the beginning of
PatchScript, fink checksums the file on disk, and abort immediately if it does not match. By always routing through the new percent-expansion token, we force this step to occur.- Using %a, .info could access a file that has not been checked.
- Still allow %a for now so that .info would still work on older fink versions, but eventually abolish it at the same time the
Patchfield is abolished.
- Also check file readability as the user who will run the PatchScript.
- Fink always aborts when it encounters an unknown percent-expansion token, so we're protected against an old version of fink that silently mis-using a .info file with
%{PatchFile}. - Validator enforces a BuildDepends:fink that is versioned to require a fink that supports this new field. Not ideal, but if you're building a package whose .info doesn't validate, never any guarantees it'll work anyway.
"But Dan, Why Not...?"
- Can't do implicit application of the patch because that doesn't protect against mis-use by old-fink. The explicit use is easy and many packages already use explicit patch in
PatchScriptso there isn't a big learning curve here.- drm and akh feel that having validator check for BDep on a version of fink that supports this new feature is enough, so we will have implicit patching available.
- Can't just add
PatchFile-MD5for use vs the existingPatchbecause that allows leakage via %a and doesn't protect against missing patchfile when used by sed/patch. AlsoPatchcan have more than one filename listed. - Can't also have
PatchFile-MD5be used for patchfiles implemented by existingPatchScriptbecause there's no foolproof way to get the filename out of that field. Also, there could be more than one filename used by thePatchandPatchScriptfields.