- NSIS Discussion
- vpatch->how to generate new files in dest dir
Archive: vpatch->how to generate new files in dest dir
DarkUniverse
15th March 2006 08:38 UTC
vpatch->how to generate new files in dest dir
Hi@all,
I need a patch that generates new files in the dest dir. Background: I have to patch several files from old to new version and I also have to add some new files. One member of the forum did it in 2005 but did not post the solution. So, how is it possible? I have tried to do it since hours and days and also had a look in this forum and google...
Thanx,
Christian
kichik
16th March 2006 17:21 UTC
I'd create a macro that first checks if the file exists and only then patches. If it doesn't exist, it'll just extract the newest version.
If you want to have in a patch file, try creating a patch from an empty file to the file you want.
DarkUniverse
16th March 2006 18:30 UTC
Hi kichik!
Thanx for your suggestion which is pretty cool.
At the moment I only update the files in the dest dir (so there is no need to check if the file exists). Next step is to create the new (empty) files and update them. But this means that I have to know the new files which should be in the dest dir. Since I don't know the name of the new file, I have to create a list and send the list with the patch and a macro to the user and compare the list with the files. Is it possible to get the information solely from the patch file without comparison?
kichik
17th March 2006 11:28 UTC
Don't you have to know the name of the files you want to patch anyway? The VPatch plug-in needs to know the name of the file it should patch. It takes its path as the second argument.
By the way, I've tested a patch from an empty file to another file and the VPatch plug-in wouldn't apply the patch unless the file already exists. This made me think of a simpler way than checking for the existence of the file. You can simply open the file using append mode. This way, if the file doesn't exist, it'll be created. If it does exist, nothing will happen.
FileOpen $0 "$INSTDIR\file" "a"
FileClose $0
DarkUniverse
19th March 2006 10:31 UTC
I only take the files in the destdir. If there is a patch in patchfile, then it will be patched. It will do nothing on the file if there is no patch. Thus, I have patched all files, that exists in the dest dir without problems. But now, the files that I have to create new...
The procedure should then be something like this:
1. create the patch file with all patches (also the new files)
2. create a list of all patched/new files
3. send the installer along with the list of files and the patch to the user
4. The user starts the intsaller/patch
5. the installer does:
- patch all existing files
- compares the list with files in dest dir and creates the new files with:
FileOpen $0 "$INSTDIR\file" "a"
FileClose $0
and patch these files.
- and maybe deletes files not used anymore
6. done :-)
Does this looks like a good solution?
kichik
21st March 2006 18:00 UTC
But in order to patch the file, you must know the patched file name. The VPatch plug-in requires the output file path. You can not patch without the file name. There's no need for a list in this case. Before you patch the file, check if it exists.
DarkUniverse
22nd March 2006 09:08 UTC
Originally posted by DarkUniverse
I only take the files in the destdir. If there is a patch in patchfile, then it will be patched. It will do nothing on the file if there is no patch. Thus, I have patched all files, that exists in the dest dir without problems. But now, the files that I have to create new...
Ok. I guess you mean this part.
I generate the patch file as usual: I take the files of a directory recursive and write the patches into the patch file. This is done by the developer.
Result is a patch file which includes all patches of the files.
I recursive take the files of the client, where I know the basedir. The I use vpatch on every file. If there is one patch available, it will be executed. If not, nothing is done on the file.
So far, I do not need any list. A list is only used on new or deleted files.
DarkUniverse
22nd March 2006 09:13 UTC
I'll check the solution by implementing it today. Hope it works! :-)
DarkUniverse
22nd March 2006 10:59 UTC
Another possibility is to compress the whole dir in a zip or jar file and then doing the patch just on one file. Then, uncompress it on the client. The patch file will be bigger, but this solution is maybe more stable and easier.
Hm, I am not sure... has someone tried this?
DarkUniverse
22nd March 2006 12:34 UTC
Hm, I had a second thought on it. I think that it is not possible, because he MD5/CRC of the copmpressed file on the client(which consists of the whole files in the dest dir) is not the same. Thus, the patch vcan not find the file with the right checksum.
DarkUniverse
28th March 2006 12:07 UTC
I had not much time since I wrote the last messages... but I'm still on this topic.
Regards,
Christian