VPatch 3.2
简介
VPatch 能够创建一个补丁文件用于升级你的程序文件。GenPat 工具能够生成补丁数据文件,VPatch 插件能够应用补丁数据文件来升级目标文件。使用补丁数据文件,你能降低你的软件的升级下载量,因为只有两个文件间不同的地方被包含在补丁数据文件中。
使用方法
生成补丁数据文件
首先确认你已经有了原始文件(旧版本)和目标文件(新版本)。例如: DATA.DTA (在当前用户系统内)和 DATA_20.DTA (该文件的 2.0 版)。现在使用命令行工具 GenPat.exe:
GENPAT data.dta data_20.dta data.pat
补丁数据文件就生成了,当然可能要花费一些时间!
使用 GenPat 工具的参数 "/B=(块大小)" (将其放在文件名后面),你可以使用不同的块大小。块大小的值越小,生成的补丁数据越小,但将花费更多的时间(默认块大小为 64)。
如果你不习惯使用这个命令行工具,你可以访问以下页面并下载 VPatch 的图形界面:
作者的网站.
安装过程中升级文件
通过使用 VPatch 插件和补丁数据文件来更新文件:
vpatch::vpatchfile "patch.pat" "oldfile.txt" "temporary_newfile.txt"
补丁操作的结果将被添加到堆栈,其内容可能是下列文本之一:
- OK
- OK, new version already installed
- An error occured while patching
- Patch data is invalid or corrupt
- No suitable patches were found
例子请参考 example.nsi。需要的话你可以检测堆栈字串是否以 "OK" 开头,并进而重命名 "temporary_newfile.txt" 为 "oldfile.txt" 文件来替换源文件。
一个补丁数据文件中包含多个补丁数据
GenPat 会追加补丁数据到你所指定的补丁数据文件。如果补丁数据文件中已经存在相同目标文件的补丁数据,原有数据将被替换。例如,如果你想升级版本 1 和 2 到版本 3,你可以将 1→3 和 2→3 补丁数据放在同一个补丁数据文件内。
你也可以在一个补丁数据文件内放置不同文件的补丁数据,如:从文件 A 版本 1 到文件 A 版本 2 的补丁数据和从 文件 B 版本 1 到文件 B 版本 2 的补丁数据。你只要多次调用插件和一个相同的补丁数据文件即可,补丁插件会自动选择匹配的补丁数据(基于源文件的 CRC)。
补丁数据生成器 (GenPat) 退出代码
在版本 3 中,GenPat 会返回如下的退出代码 (如同 DOS 时期的错误代码)。GenPat 将根据补丁生成情况返回一个退出代码,下面是可能的退出代码:
| 退出代码 |
说明 |
| 0 |
成功 |
| 1 |
变量不足 |
| 2 |
其它错误 |
| 3 |
指定的补丁文件中已有一份源文件的补丁数据(错误),使用 /R 开关可进行覆盖。 |
如果你是通过 NSIS 脚本生成补丁文件的话,这些退出代码是非常有用的。
版本历史
- 3.2
- 新增工具: ListPat,用于查看补丁数据文件的内容。
- 新增运行库: VPatchPrompt,在缺少足够的参数时会要求用户指定。
- 随 NSIS 知识库同步可移植性代码。
- GenPat 的 Windows 版本支持 - 和 / 作为开关符号。
- 新增 GenPat 选项: /Q 减少输出信息
- 开发环境升级至 Borland Developer Studio 在2006,可一次性构建所有的工具。
- 3.1
- GenPat 现编译于 POSIX 平台 (MinGW/GCC),Visual
C++ 6 和 Borland C++.
- GenPat 的功能更严格测试、验证。
- 3.0
- Final: 增加了用户图形界面,安装程序
- RC8: GenPat will now flag replacement of a patch (e.g.
the source file has the same contents as a previous patch inside
a patch file) as an error. You can specifically allow it using
the /R switch. Added license to source files.
- RC7: Fixed critical bug in GenPat with multiple patches
in a single file. Fixed serious bug in stand-alone EXE runtime:
process kept on running forever. Included case testing through
a Python script to test common usage (and prevent bugs like
the one in GenPat in the future).
- RC6: Upgraded to non-beta compiler. Added /A switch
to change block match limit and /O to deactivate the limit.
Updated GUI to support the /O switch.
- RC4a to RC5a: input block size is now checked for power
of 2 and fixed if incorrect. When patch file does not yet exist,
no longer forgets to create the header. No longer tries to allocate
memory when there are no chunks. Fixed memory leaks.
- Target file date is now preserved inside a patch and restored
on the user system.
- MD5 checksums are now used instead of CRC32 checksums, unless
existing patches in a file already are in CRC32 mode.
- The patch generator, GenPat, has been completely rewritten
in C++. It no longer needs to keep the entire files in memory,
instead memory usage is a certain percentage of the source file
size. The percentage is based on the block size, larger block
sizes will reduce memory usage.
- All runtimes now share a common codebase, perform proper error
checking and don't leave behind files if the input file was
already up to date.
- Bug Fix: The patch generator algorithm no longer reduces to
a quadratic runtime if there are many blocks with the same content
in the files to patch.
- Bug Fix: The documentation of the command-line utilities was
incorrect and no warnings would be given by the runtimes, causing
the patch not to work (this does not apply to NSIS patches).
- 2.1
- Added argument checking and error handling to GenPat. Now
returns exit codes as well to indicate success/failure (and
the reason for failure). Only GenPat has changed in this version
compared to 2.0 final.
- Bug Fix: GenPat no longer gives an Access Violation when attempting
to patch a file smaller than 64 bytes into a file larger than
64 bytes.
- 2.0 final
- Cleaned up source code for the patch generator, which is now
included (this code is written in Borland Delphi 6 and compiles
with the freely available Personal edition).
- 2.0 beta 2
- All new algorithm used in the patch generator: much faster
(up to 90%) while using smaller block sizes (higher compression)
- Created a NSIS 2 plugin
- Works with small files
- Replaces existing patch in file if original file CRC is identical
荣誉榜
开发人员 Koen van de Sande
C 插件最初作者为 Edgewize,Koen van de Sande 进行了升级开发
最新的文档及实例作者为 Joost Verburg 和 Koen van de Sande
许可协议
Copyright (C) 2001-2008 Koen van de Sande / Van de Sande Productions
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment in the
product documentation would be appreciated but is not required.
2. Altered versions must be plainly marked as such,
and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any distribution.
|