Archive: Patching/Merging text files


Patching/Merging text files
****************************************************************
I am attempting to create an installer script that will allow me
to distribute only patches rather than completely new files.

Within *NIX and *NIX-like OS's this can be accomplished fairly
easily with a unified diff file and the patch executable.

Within MS though, I am still searching. MS VisualStudio .NET
installer has this functionality, but I would prefer not to incur
the associated overhead of requiring all of the end-users to
install the .NET Framework at 23+Mb from Microsoft.

An alternative would be to be able to open a file "handle" for
append and read in a series of sub-files to create the updated
main file, then write the handle to the needed file name.

I have searched for various topics and questions, tried adapting
some of the scripts I found on the "Archive" page, etc. all with
no luck.

Can anyone offer some advice? Or point out any resources that I
might have overlooked?

Thanks,

- Ed


Have you tried the vpatch plugin?

Vytautas


I found and tried that, but it fails to modify the file (creates
the temp file successfully, but then it skips the patch data
file and leaves the original file untouched).

I followed the readme pretty much to the letter - I also looked
within the .pat file and that was generated correctly (or at
least my changes were there).

Any ideas?

- Ed

Here is the fail output from the compiled installer:

Output folder: D:\DOCUME~1\allusers\LOCALS~1\Temp
Skipped tk_output.pat
Ok
Delete file: f:\XMLFiles\Output.xml
Rename: f:\XMLFiles\~output.tmp->f:\XMLFiles\Output.xml
Delete file: D:\DOCUME~1\allusers\LOCALS~1\Temp\~output.tmp

And here is the compile time thread from the HM NIS editor:

MakeNSIS v2.0b4 - Copyright 1999-2003 Nullsoft, Inc.

Portions Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler (zlib).
Includes portions derived from bzip2 (see documentation for details).
Contributors: nnop@newmail.ru, Ryan Geiss, Andras Varga, Drew Davidson, Peter Windridge, Dave Laundon, Robert Rainwater, Yaroslav Faybishenko, Jeff Doozan, Amir Szekely, Ximon Eighteen, et al.



Processing config:
!define: "MUI_INSERT_NSISCONF"=""
Changing directory to: "D:\Documents and Settings\allusers\My Documents\Install Scripts"

Processing plugin dlls: "E:\Program Files\NSIS\plugins\*.dll"
- advsplash::show
- Banner::destroy
- Banner::show
- BgImage::AddImage
- BgImage::AddText
- BgImage::Clear
- BgImage::Destroy
- BgImage::Redraw
- BgImage::SetBg
- BgImage::SetReturn
- BgImage::Sound
- Dialer::AttemptConnect
- Dialer::AutodialHangup
- Dialer::AutodialOnline
- Dialer::AutodialUnattended
- Dialer::GetConnectedState
- InstallOptions::dialog
- InstallOptions::initDialog
- InstallOptions::show
- LangDLL::LangDialog
- Math::Script
- nsExec::Exec
- nsExec::ExecToLog
- nsExec::ExecToStack
- nsisdl::download
- nsisdl::download_quiet
- splash::show
- StartMenu::Select
- System::Alloc
- System::Call
- System::Copy
- System::Free
- System::Get
- System::Int64Op
- System::Store
- UserInfo::GetAccountType
- UserInfo::GetName
- VPatch::vpatchfile


Processing script file: "D:\Documents and Settings\allusers\My Documents\Install Scripts\tking-output-anim01.nsi"
!define: "PRODUCT_NAME"="TKing's Output Animation"
!define: "PRODUCT_VERSION"="2.1.0"
!define: "PRODUCT_PUBLISHER"="TKing/Remelio"
!define: "PRODUCT_WEB_SITE"="http://home.comcast.net/~tomjking"
!define: "PRODUCT_DIR_REGKEY"="Software\Microsoft\Windows\CurrentVersion\App Paths\makensis.exe"
!define: "PRODUCT_UNINST_KEY"="Software\Microsoft\Windows\CurrentVersion\Uninstall\TKing's Output Animation"
!define: "PRODUCT_UNINST_ROOT_KEY"="HKLM"
!include: "MUI.nsh"
!include: "E:\Program Files\NSIS\Contrib\Modern UI\System.nsh"
NSIS Modern User Interface version 1.67 - © 2002-2003 Joost Verburg (E:\Program Files\NSIS\Contrib\Modern UI\System.nsh:11)
!include: closed: "E:\Program Files\NSIS\Contrib\Modern UI\System.nsh"
!include: closed: "E:\Program Files\NSIS\Include\MUI.nsh"
!include: "E:\Program Files\NSIS\Contrib\VPatch\patchlib.nsi"
!include: closed: "E:\Program Files\NSIS\Contrib\VPatch\patchlib.nsi"
!define: "MUI_ABORTWARNING"=""
!define: "MUI_ICON"="E:\Program Files\NSIS\Contrib\Graphics\Icons\modern-install.ico"
!define: "MUI_UNICON"="E:\Program Files\NSIS\Contrib\Graphics\Icons\modern-uninstall.ico"
!insertmacro: MUI_PAGE_WELCOME
!insertmacro: end of MUI_PAGE_WELCOME
!insertmacro: MUI_PAGE_DIRECTORY
!insertmacro: end of MUI_PAGE_DIRECTORY
!insertmacro: MUI_PAGE_INSTFILES
!insertmacro: end of MUI_PAGE_INSTFILES
!insertmacro: MUI_PAGE_FINISH
!insertmacro: end of MUI_PAGE_FINISH
!insertmacro: MUI_UNPAGE_INSTFILES
!insertmacro: end of MUI_UNPAGE_INSTFILES
!insertmacro: MUI_LANGUAGE
!insertmacro: end of MUI_LANGUAGE
Name: "TKing's Output Animation v2.1.0"
OutFile: "outputanim-setup.exe"
InstallDir: "F:\XMLFiles"
ShowInstDetails: show
ShowUnInstDetails: show
Section: "Master" ->(SEC01)
SetOutPath: "$INSTDIR"
overwrite = 3, last_overwrite = 0
SetOverwrite: ifnewer
File: "makensis.exe" [compress] 197552/416256 bytes
File: "tk_output01.tga" [compress] 133400/262188 bytes
File: "tk_output03.tga" [compress] 148866/262188 bytes
File: "tk_output02.tga" [compress] 154501/262188 bytes
File: "tk_output04.tga" [compress] 97792/262188 bytes
CopyFiles: "$INSTDIR\Output.xml" -> "$INSTDIR\Output.bak", size=0KB
!insertmacro: PatchFile
SetOutPath: "$TEMP"
File: "tk_output.pat" [compress] 639/16990 bytes
File: "VPatch.dll"->"$PLUGINSDIR\VPatch.dll" [compress] 2370/21086 bytes
Plugin Command: vpatchfile $TEMP\tk_output.pat $INSTDIR\Output.xml $INSTDIR\~output.tmp
Pop: $1
DetailPrint: "$1"
StrCpy $1 "$1" (2) ()
StrCmp "$1" "OK" equal=ok_$INSTDIR\Output.xml, nonequal=
SetErrors
IfFileExists: "$INSTDIR\~output.tmp" ? +1 : end_$INSTDIR\Output.xml
Delete: "$INSTDIR\Output.xml"
Rename: /REBOOTOK $INSTDIR\~output.tmp->$INSTDIR\Output.xml
Delete: "$TEMP\tk_output.pat"
!insertmacro: end of PatchFile
IfErrors ?in.onFailPatch:done
MessageBox: 64: "The VPatch failed miserably"
SectionEnd
Section: "-Post"
WriteUninstaller: "$INSTDIR\uninst.exe"
SectionEnd
Function: ".onVerifyInstDir"
IfFileExists: "$INSTDIR\Output.xml" ? PathGood :
CopyFiles: "$INSTDIR\..\default\Output.xml" -> "$INSTDIR", size=0KB
FunctionEnd
Function: "un.onUninstSuccess"
HideWindow
MessageBox: 64: "$(^Name) was successfully removed from your computer."
FunctionEnd
Function: "un.onInit"
MessageBox: 292: "Are you sure you want to completely remove $(^Name) and all of its components?" (on IDYES goto +2)
Abort: ""
FunctionEnd
Section: "Uninstall"
Delete: "$INSTDIR\uninst.exe"
Delete: "$INSTDIR\tk_output04.tga"
Delete: "$INSTDIR\tk_output02.tga"
Delete: "$INSTDIR\tk_output03.tga"
Delete: "$INSTDIR\tk_output01.tga"
Delete: "$INSTDIR\Output.xml"
CopyFiles: "$INSTDIR\Output.bak" -> "$INSTDIR\Output.xml", size=0KB
Delete: "$INSTDIR\makensis.exe"
SetAutoClose: false
SectionEnd

Processed 1 file, writing output:
Adding plug-ins initializing function... Done!
Processing pages... Done!
Removing unused resources... Done!
Generating language tables... Done!
Generating uninstaller... Done!

Output: "D:\Documents and Settings\allusers\My Documents\Install Scripts\outputanim-setup.exe"
Install: 5 pages (320 bytes), 2 sections (1 required) (48 bytes), 234 instructions (6552 bytes), 137 strings (2471 bytes), 1 language table (290 bytes).
Uninstall: 2 pages (128 bytes),
1 section (24 bytes), 50 instructions (1400 bytes), 67 strings (1046 bytes), 1 language table (214 bytes).
Datablock optimizer saved 7364 bytes (~0.9%).

Using zlib compression.

EXE header size: 47104 / 34816 bytes
Install code: 2668 / 10049 bytes
Install data: 744550 / 1556496 bytes
Uninstall code+data: 10641 / 14934 bytes
CRC (0x21BC080C): 4 / 4 bytes

Total size: 804967 / 1616299 bytes (49.8%)


The skipped line is not coming from VPatch, it's coming from the installer. You've used SetOverwrite ifnewer and are extracting over an existing .pat file which is not older than the on you're trying to extract. You should extract it to $PLUGINSDIR which is assured to be empty of any files you don't need. This way you won't get any skip message.

The "Ok" line is the line that VPatch is outputting, which probably means the patching succeeded.