parsePatch($file ) -> %patch{filename}
This routine will read in a patch file and parse it into separate patches.
Each patch file can patch one or more files. Each file can have one or more separate patches matching different versions of the file.
Builds a hash describing the patch file.
- {identifier} = The patch file name without the patch extension. ItemNNNN-001
- {summary} = The descriptive text from the head of the patch file.
- {path/to/target/file}
- {md5_of_target} = Will match the file version that can accept this patch.
- {patched} = Expected MD5 of the patched file.
- {version} = Comment from PATCH record describing the target. Parenthesis removed.
- {patch} = The patch in unified diff format.
- {status} = Set by checkPatch to one 3 possible values:
- "N/A" - neither the old nor the new MD5 matches the file.
- "PATCHED" - The patch has been applied and the patched MD5 matches.
- "NOT APPLIED" - The initial MD5 matches, so the patch will be applied
Supports two differnt patch file record layouts:
# target file MD5 relative path file comment
#~~~PATCH fdeeb7f236608b7792ad0845bf2279f9 lib/Foswiki/Configure/Dependency.pm (Foswiki 1.1.5)
#
# target file MD5 patched file MD5 relative file path comment
#~~~PATCH fdeeb7f236608b7792ad0845bf2279f9:fdeeb7f236608b7792ad0845bf2279f9 lib/Foswiki/Configure/Dependency.pm (Foswiki 1.1.5)
_getMD5($filename ) -> $digest
This routine will read calculate MD5 of the passed filename.
_fixupFile($filename ) -> $filename
This routine will determine the fosiki filname from a patch filename.
updateFile($file, $patch, $reverse )
This routine will update the filea and rewrite it into its original
location, preserving permissions. If $reverse is true, the reverse of the diff is calculated, and the patch is removed.
checkPatch($file ) -> $messages
This routine will read in a patch hash, determine which patches are applicable for the system, or have already been applied.
It will update the {status} field for each patch version, assigning one of 3 possible status.
(Note that for old style patch records, the "PATCHED" status can not be determined. Patched files will be reported as "N/A").
Each patch file can patch one or more files. Each file can have one or more separate patches matching different versions of the file.
Builds a hash describing the patch file.
- {identifier} = The patch file name without the patch extension. ItemNNNN-001
- {summary} = The descriptive text from the head of the patch file.
- {path/to/target/file}
- {md5_of_target} = Will match the file version that can accept this patch.
- {patched} = Expected MD5 of the patched file.
- {version} = Comment from PATCH record describing the target. Parenthesis removed.
- {patch} = The patch in unified diff format.
- {status} = Set by checkPatch to one 3 possible values:
- "N/A" - neither the old nor the new MD5 matches the file.
- "PATCHED" - The patch has been applied and the patched MD5 matches.
- "NOT APPLIED" - The initial MD5 matches, so the patch will be applied
The returned patch summary report:
_fixRoot -> $filepath
This routine will determine the root of the foswiki installation by
working backwards from the
DataDir setting.
This is copied from
Foswiki::Configure::Package.
applyPatch($root, \%patchref, $reverse ) -> $messages
This routine will process the patch hash, and apply every applicable patch in the hash.
If the $reverse flag is passed, then the patches will be rmoved from the system.
reverseDiff($diff ) -> $diff
Uses the algorithm discussed in
http://stackoverflow.com/questions/3902388/permanently-reversing-a-patch-file
to reverse the patch to "undo" a previous patch.
backupTargets($root, \%patchref, $reverse ) -> $messages
Examine the patch and create a backup of all files that will be modified by the patch.
If a file doesn't match, or has already been previously patched, it will not be backed up. The
file needs to be in status "NOT APPLIED"
If the $reverse flag is set, then "PATCHED" files will be backed up rather that "NOT APPLIED" files.
The backup is written to the
working/configure/backup
directory.
-
working/configure/backup/
-
ItemNNNN-NNN-yyyymmdd-hhmmss/
- full path to each file being backed up
The backup directory will be archived to either
.tgz
or
.zip
format, depending upon the tools avaliable on the system. If no archive tool is found the directory will be left as is.