Installing patch aka diff installer

1,142 views
Skip to first unread message

Asesh Shrestha

unread,
Dec 14, 2016, 12:00:51 PM12/14/16
to Chromium-dev
I have finally managed to create  a patch aka diff installer for our Chromium fork but double clicking it won't install that patch. I have gone through C++ source code and it only takes these command line arguments:
  1. --chrome-sxs
  2. --chrome
  3. --chrome-frame
  4. --system-level
  5. --cleanup
and none of these flags will install that patch. The executable file contains a setup_patch.diff file just like a regular Chrome patch does and it's not corrupted. So can someone tell me how to do it? I must be missing something. Thanks

Asesh Shrestha

unread,
Dec 15, 2016, 5:27:44 AM12/15/16
to Chromium-dev
By digging through the source code I have managed to find some additional parameters that is used for patching: --update-setup-exe and --new-setup-exe. I have used them too, despite that it's still not working. I must be missing something. Can anyone please tell me how to use that diff installer?

Thanks

Greg Thompson

unread,
Dec 15, 2016, 6:30:00 AM12/15/16
to asesh.s...@cloudfactory.com, Chromium-dev
Hi. mini_installer.exe expects to extract the following resources from itself when updating from version N to version N+1:
  • B7 setup_patch.packed.7z -- a 7z-compressed patch generated by version N's courgette on N's setup.exe to N+1's setup.exe.
  • B7 chrome_patch.packed.7z -- a 7z-compressed patch generated by version N+1's courgette on N's (uncompressed) chrome.7z archive to N+1's chrome.7z archive.
It will then find and launch N's setup.exe to generate N+1's setup.exe with setup_patch.packed.7z, and then launch that generated setup.exe with chrome_patch.packed.7z. I suggest you step through mini_installer::WMain in a debugger to see how it works.


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

Asesh Shrestha

unread,
Dec 15, 2016, 6:37:02 AM12/15/16
to Chromium-dev, asesh.s...@cloudfactory.com
Thanks for replying. I have already generated diff installer for our fork and it's around 3.5 MB for release version. I have noticed that inside that mini_installer.exe there's a file chrome_patch.diff. That's what Google do too when patching their files. So, in this instance should I use my diff installer mini_installer.exe to patch? I have tried almost every argument to make it patch my files and it still won't do anything. I can't find any documentation either.

Thanks

Greg Thompson

unread,
Dec 15, 2016, 3:47:19 PM12/15/16
to asesh.s...@cloudfactory.com, Chromium-dev
On Thu, Dec 15, 2016 at 12:37 PM Asesh Shrestha <asesh.s...@cloudfactory.com> wrote:
Thanks for replying. I have already generated diff installer for our fork

How did you do this?

and it's around 3.5 MB for release version. I have noticed that inside that mini_installer.exe there's a file chrome_patch.diff. That's what Google do too when patching their files.

Where do you see this? As I mentioned, the Google-produced diff updaters contain two B7 resources as below. There is no tooling within a Chromium checkout to produce these, but there is nothing too difficult in doing so (courgette.exe -gen original_file new_file patch_file).

So, in this instance should I use my diff installer mini_installer.exe to patch? I have tried almost every argument to make it patch my files and it still won't do anything. I can't find any documentation either.

There are no special arguments to mini_installer to make it process a diff update. If it finds a B7 resource named setup*, it will launch the previous setup.exe to uncompress and apply the patch.

Again, I suggest stepping through mini_installer.exe in a debugger to see how it works. UnpackBinaryResources has the logic to delegate to the previous setup.exe to patch itself. The newly generated setup.exe is responsible for handling chrome_patch.packed.7z.

I hope this helps.

Greg Thompson

unread,
Dec 16, 2016, 5:25:28 AM12/16/16
to Asesh Shrestha, chromium-dev
Please keep this discussion on chromium-dev so that the whole community can benefit from it.

On Fri, Dec 16, 2016 at 4:20 AM Asesh Shrestha <asesh.s...@cloudfactory.com> wrote:
How did you do this?
if you open that file with WinRAR then you will see that chrome_patch.diff file inside that diff installer.

When Google patches Chrome, it will download a small patch file too which contains a chrome_patch.diff file

I invite you to open a Google-produced diff installer in Visual Studio to look at the resources contained therein. I believe that you'll find it contains the two B7 resources I mentioned in my first response.

We don't have to explicitly use Courgette to generate diff file. When generating diff installer we have to modify Build.gn and uncomment out this line which generates a diff installer as opposed to creating a full installer:

      "--last_chrome_installer=D:/Temp/release",
      "--setup_exe_format=DIFF",
      "--diff_algorithm=COURGETTE",

courgette.exe, old version of Chrome.7z and setup.exe should be placed inside D:/Temp/release. I also had to make some modifications to create_installer_archive.py because of path. That's it. Then it will start creating a diff aka patch installer.

I can't say for certain that this works, but it has a fighting chance to. Full disclosure: I work for Google. The tooling we use to produce diff installers is a bit different from create_installer_archive.py, but the spirit is the same.

Now back to my problem. I have tried everything else and I still can't find out how to install that diff installer. I am still going through source code but it's gonna take some time. So if someone can give me a pointer on how to install diff installers then I would be really thankful cause I have been stuck trying to accomplish for more than two days.

Here is how Google Chrome diff installers are installed:
  1. Install the base version of Chrome:
    mini_installer.exe --verbose-logging [--system-level] --do-not-launch-chrome
  2. Update it using a diff updater generated from the base version and some new version:
    mini_installer.exe --verbose-logging [--system-level] --do-not-launch-chrome
As you can see, there is no difference in the way the installer is run. The difference, as I said in my first and second responses, is that mini_installer.exe contains logic to detect that it has a type B7 resource named setup* and, if found, automatically generates the new setup.exe given the previous setup.exe and the patch. The function named UnpackBinaryResources in mini_installer.cc contains this logic. If you are following these steps and find that your diff updater isn't working, you will have to invoke the power of tools such as a debugger and/or Process Monitor to understand what is going on.

I believe that I have explained the same thing repeatedly. If this still isn't helping you, then I suppose either I am misunderstanding the question you are asking, or you are misunderstanding my answers. Please take the time to re-read my responses, understand them, and formulate a clear message explaining what you have tried, what you expect to happen, and what you have observed happening before you ask again.

As well, please send your responses to chromium-dev rather than solely to me individually. Thank you.

Respectfully,

Greg

 

Thanks

Asesh Shrestha

unread,
Dec 17, 2016, 9:25:02 AM12/17/16
to Chromium-dev, asesh.s...@cloudfactory.com
Thanks a lot for replying. I just opened Chrome diff installer and my diff installer which I made using the procedure mentioned above in Visual Studio and here's the result:

55.0.2883.87_55.0.2883.75_chrome_updater.exe (Google Chrome updater): 
B7 folder:
  • CHROME_PATCH.PACKED.7Z
  • SETUP_PATCH.PACKED.7Z
My diff installer (54.0.2785.101_53.0.2785.101_workstream_updater renamed it from mini_installer.exe);
B7 folder:
  • CHROME_PATCH_2785.101_FROM_2785.101.PACKED.7Z
  • SETUP_PATCH_2785.101_FROM_2785.101.PACKED.7Z
Looks like it's appending build and patch number but the one Google distributed doesn't contain anything like that, they just include the name like you mentioned. Anyways, I had already tried that method for installing patch but nothing happens. So maybe it's not installing because of appended build number? And does the path of diff installer matter? As far as debugging goes, I have tried generating debug version of diff installer but even after 18 hours, it was still working on it so I cancelled it but however It takes less than 2.5 hour to generate release version of diff installer and debugging release version won't be that easy though I do know reverse engineering and assembly language but doing so would take so much time and I need to finish this ASAP that's why I am working on it even on weekend. Maybe I should change/modify the method of generating diff installer? The build tools are responsible for creating diff installer so do you have any recommendation for modifying or using different build tools to generate diff installer

Here's the spec of my machine:

Intel Core i7 6700HQ
16 GB DDR4 RAM
Windows 10 Home
1 TB Hard disk

Looking forward to your reponse

Thanks
Message has been deleted

Asesh Shrestha

unread,
Dec 17, 2016, 10:21:28 AM12/17/16
to Chromium-dev, asesh.s...@cloudfactory.com
Should have added more info. I had just bumped version number from 53.0.2785.101 to 54.0.2785.101 by changing the icon and some small modifications. Besides that build and patch number being appended, I also don't see RCDATA folder when opening my file in VS but however the one from Google do. After going through that file (1 under RCDDATA) looks like it contains the old version number that our diff installer is targeting. 

Thanks

Asesh Shrestha

unread,
Dec 18, 2016, 11:24:53 AM12/18/16
to Chromium-dev, asesh.s...@cloudfactory.com
I tried to debug our release version of diff installer but as soon I do it, it will exit. Generating debug version of diff installer will take ages. But however, I found a very useful information: The program '[8812] 54.0.2785.101_53.0.2785.101_workstream_updater.exe' has exited with code 110 (0x6e).

110 is equivalent to UNABLE_TO_FIND_REGISTRY_KEY

So, it looks like it's looking for a specific registry key. Can't debug it as it immediately exits. Do you have any idea? We have named our browser WorkStream.

PhistucK

unread,
Dec 18, 2016, 12:47:37 PM12/18/16
to Asesh Shrestha, Chromium-dev


PhistucK

You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.

Asesh Shrestha

unread,
Dec 18, 2016, 10:39:01 PM12/18/16
to Chromium-dev, asesh.s...@cloudfactory.com
Yes, I found it yesterday but now am trying to debug this release version and find out what key it is looking for. 

Thanks for replying


PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

PhistucK

unread,
Dec 19, 2016, 1:51:44 AM12/19/16
to Asesh Shrestha, Chromium-dev
You can always add some logging.


PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.

Greg Thompson

unread,
Dec 19, 2016, 3:06:55 AM12/19/16
to asesh.s...@cloudfactory.com, Chromium-dev
mini_installer's current handling of diff updates is specific to Google Chrome's integration with Google Update. I'm not certain that it will work for Chromium-branded builds. If not, patches are welcome to make it work.

If you read the code and/or inspect a Process Monitor log, I hope you will find that the registry key that cannot be found is ...\Software\Chromium. If you discover otherwise, perhaps you could share your discovery. Does your installer write an "UninstallString" value into that registry key?

Have you tried running your release build of mini_installer in a debugger?

Asesh Shrestha

unread,
Dec 19, 2016, 3:55:56 AM12/19/16
to Chromium-dev, asesh.s...@cloudfactory.com
Thanks a lot for replying guys. I have managed to debug that release version and found out that it was trying to open this key: "HKEY_LOCAL_MACHINE\\Software\\WorkStream{8A69D345-D564-463C-AFF1-A69D9E530F96}" (WOW64 node) which doesn't exist. And that's Chrome GUID. So I have made some changes to appid.h by replacing that GUID with ours and replaced the value of kClientStateKeyBase in mini_installer_constants.cc with relevant value. Yes our installer does write that value and that's what our diff installer was searching for :) . 

We have already configured Omaha server and client, though there's an issue after posting updates but we will see that later. 

I am building diff installer right now, it's going to take some time. Looks like am getting a lot closer :). Will let you know the result.

Thanks again :)

PhistucK

unread,
Dec 19, 2016, 4:27:25 AM12/19/16
to Asesh Shrestha, Chromium-dev
When you are done, if you could write the instructions of the things that are needed to be changed in order to make the whole thing work and the process, I am sure it will be valuable to other Chromium based applications. Perhaps it can be included in the chromium.org documentation. Just saying. :)


PhistucK

Asesh Shrestha

unread,
Dec 19, 2016, 5:09:15 AM12/19/16
to Chromium-dev, asesh.s...@cloudfactory.com
I am getting an error message (found via Chromium_installer.log) right now when patching files after executing my diff installer:

[1219/150716:VERBOSE1:setup_main.cc(1738)] Command Line: "C:\Program" --update-setup-exe="C:\Users\user\AppData\Local\Temp\CR_BFEE3.tmp\SETUP_PATCH_2785.101_FROM_2785.101.PACKED.7Z" --new-setup-exe="C:\Users\user\AppData\Local\Temp\CR_BFEE3.tmp\setup.exe" --verbose-logging --system-level -do-not-launch-chrome Files "(x86)\CloudFactory\WorkStream\Application\53.0.2785.101\Installer\setup.exe"
[1219/150716:VERBOSE1:setup_main.cc(1740)] multi install is 0
[1219/150716:VERBOSE1:setup_main.cc(1743)] system install is 1
[1219/150716:VERBOSE1:installer_state.cc(121)] Install distribution: WorkStream
[1219/150716:VERBOSE1:install_util.cc(276)] Windows NT 10.0.14393
[1219/150716:VERBOSE1:setup_main.cc(1122)] Opening archive C:\Users\user\AppData\Local\Temp\CR_BFEE3.tmp\SETUP_PATCH_2785.101_FROM_2785.101.PACKED.7Z
[1219/150716:VERBOSE1:lzma_util.cc(86)] Opening archive C:\Users\user\AppData\Local\Temp\CR_BFEE3.tmp\SETUP_PATCH_2785.101_FROM_2785.101.PACKED.7Z
[1219/150716:VERBOSE1:lzma_util.cc(93)] Uncompressing archive to path C:\Users\user\AppData\Local\Temp\scoped_dir9508_23083
[1219/150716:ERROR:archive_patch_helper.cc(70)] Failed to apply patch C:\Users\user\AppData\Local\Temp\scoped_dir9508_23083\setup_patch.diff to file C:\Program Files (x86)\CloudFactory\WorkStream\Application\53.0.2785.101\Installer\setup.exe and generating file C:\Users\user\AppData\Local\Temp\CR_BFEE3.tmp\setup.exe using courgette. err=8
[1219/150716:ERROR:archive_patch_helper.cc(94)] Failed to apply patch C:\Users\user\AppData\Local\Temp\scoped_dir9508_23083\setup_patch.diff to file C:\Program Files (x86)\CloudFactory\WorkStream\Application\53.0.2785.101\Installer\setup.exe and generating file C:\Users\user\AppData\Local\Temp\CR_BFEE3.tmp\setup.exe using bsdiff. err=8
[1219/150716:WARNING:setup_main.cc(1141)] setup.exe patching failed.
[1219/150716:VERBOSE1:work_item_list.cc(34)] Beginning execution of work item list Write Installer Result
[1219/150716:VERBOSE1:create_reg_key_work_item.cc(78)] created Software\CloudFactory\Update\ClientState\{F797A2A7-ABEE-4B88-B9A9-FB230284BEEF}
[1219/150716:VERBOSE1:work_item_list.cc(55)] Successful execution of work item list Write Installer Result

Looking at this issue right now...

When I am done finishing this patching stuff then I will definitely write all the steps that I had done so that it will help others too.

Thanks

Greg Thompson

unread,
Dec 19, 2016, 6:29:23 AM12/19/16
to asesh.s...@cloudfactory.com, Chromium-dev
Here's where error 8 is defined. Are you able to apply the patch manually using courgette.exe?

--

Asesh Shrestha

unread,
Dec 20, 2016, 6:45:47 AM12/20/16
to Chromium-dev, asesh.s...@cloudfactory.com
That was because of version mismatch. The one I had installed was debug version but the patch that I had generated was for release version so had to rebuild release version of installer and generate diff installer against that release version again. 

FINALLY, I have managed to patch files via diff installer successfully :). 

I will write instructions on how I did it on weekend. Was busy working on this for so many days and still got so many things to do :)

Thank you guys, thanks a lot :)

Suman Awal

unread,
Dec 20, 2016, 2:43:58 PM12/20/16
to asesh.s...@cloudfactory.com, Chromium-dev
Great Asesh

Asesh Shrestha

unread,
Dec 31, 2016, 11:54:32 AM12/31/16
to Chromium-dev
Here's how I managed to get diff installer to work properly

1: Modify BUILD.gn (just uncomment as specified below) so that when building mini_installer, it will create a diff installer as opposed to creating a full installer. 

      # Optional arguments to generate diff installer.
      "--last_chrome_installer=D:/DiffInstallerTemp/release",
      "--setup_exe_format=DIFF",
      "--diff_algorithm=COURGETTE",

      # Optional argument for verbose archiving output.
      "--verbose"

2: After debugging, I found out that it searches the registry to find the path of setup.exe. So I had to modify src/chrome/installer/mini_installer/chrome_appid.cc and replace the value of kAppGuid with ours. By default it's value will be 8A69D345-D564-463c-AFF1-A69D9E530F96 which is the GUID of Chrome. I also had to modify: src/chrome/installer/mini_installer/mini_installer_constants.cc as show below (diff):

-const wchar_t kClientStateKeyBase[] = L"Software\\WorkStream";
+const wchar_t kClientStateKeyBase[] = L"Software\\CloudFactory\\Update\\ClientState\\";
// The path to the key in which kCleanupRegistryValue is found.
-const wchar_t kCleanupRegistryKey[] = L"Software\\WorkStream";
+const wchar_t kCleanupRegistryKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\WorkStream";
#endif

The diff installer will try to find the path of setup.exe from the registry so it will use those values to find it :)

Now inside this folder: D:\DiffInstallerTemp\release (from BUILD.gn), you should place old version of Chrome.7z, setup.exe and courgette.exe. If you are building x64 version then courgette will named as courgette64.exe so I had to rename it to courgette.exe. 

3: I had to make some changes to create_installer_archive.py (src\chrome\tools\build\win):

in GetPrevVersion, I had to modify the command line options give to 7-zip as it was showing an error as specified below:

  cmd = [lzma_exec,
         'x',
         '-y', # Added this to overwrite existing files as it will cause this command to stop executing if not added
         '-o' + os.path.abspath(temp_dir),
         prev_archive_file,
         'Chrome-bin/*/chrome.dll',]

in GenerateDiffPatch I had to tell Python to use absolute path instead as specified below:

cmd = [exe_file, '-gen', os.path.abspath(orig_file), os.path.abspath(new_file), os.path.abspath(patch_file)] # Use absolute path

That's it. Now if you execute ninja -C out\YourBuildFolder mini_installer then it will create a diff installer (mini_installer.exe) inside that folder. Generating diff installer for debug version will take lots of time so I would recommend only doing so for release version. It takes around 2.5 hour to create diff installer on my machine (Intel Core i7 6700HQ, 16 GB DDR4 RAM, 1 TB hard disk (bottle neck)). 

I would like to thank Ivan for this thread: https://groups.google.com/a/chromium.org/forum/#!topic/chromium-discuss/O9uuZGYcWNY which was the starting point for me. Though they don't use GYP files any more as specified in that thread as they have already switched to GN build tools. 

Thanks to you guys too for helping me out :)

PhistucK

unread,
Dec 31, 2016, 11:59:13 AM12/31/16
to Asesh Shrestha, Chromium-dev
Thank you for the walkthrough! :)


PhistucK

--

Bardan Rana

unread,
Jan 1, 2017, 9:09:35 AM1/1/17
to Chromium-dev, asesh.s...@cloudfactory.com
Great Asesh. Looking forward to detail instructions to achieve it.

PhistucK

unread,
Jan 1, 2017, 9:35:37 AM1/1/17
to barda...@gmail.com, Chromium-dev, Asesh Shrestha


PhistucK

Reply all
Reply to author
Forward
0 new messages