office-gobmx/external/onlineupdate
Stephan Bergmann edf4ad7d9f MAR update, too big to (not) fail
On Windows, when a MAR update generated by create-partial-info contains very
many patches (as easily happens with LibreOffice), applying it would fail with
"failed: 7" (aka WRITE_ERROR, see
workdir/UnpackedTarball/onlineupdate/onlineupdate/source/update/common/updatererror.h)
because in
workdir/UnpackedTarball/onlineupdate/onlineupdate/source/update/updater/updater.cpp
PatchFile::mPatchStream holds open one FILE instance per patch from
PatchFile::Prepare to PatchFile::Execute (and which can't easily be reworked
because of the Lock/UnlockFile done on the underlying HANDLE "so it can't be
messed with [in] between"), so calling NS_tfopen in PatchFile::Prepare will
eventually start to fail with EMFILE.

To avoid that, try to raise the limit to its maximum (but don't fail immediately
if that fails, in case the given MAR update wouldn't run into the issue of too
many patches, anyway), and keep fingers crossed.  (See
<https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio?view=msvc-170>
"_setmaxstdio" for details:  "By default, up to 512 files can be open
simultaneously at the stream I/O level.  This level includes files opened and
accessed using the fopen, fgetc, and fputc family of functions.  The limit of
512 open files at the stream I/O level can be increased to a maximum of 8,192 by
use of the _setmaxstdio function.")

Change-Id: I6b3499f0f6c2060628418a15f5e36021bfe7dd18
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162442
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-01-23 17:33:38 +01:00
..
qa
workben
CustomTarget_generated.mk
cygpath.patch
Executable_mar.mk
Executable_mbsdiff.mk
Executable_test_updater_dialog.mk
Executable_update_service.mk
Executable_updater.mk
generate-sources.sh
generate.py
gtk3deprecated.patch
install_updateservice.cxx
install_updateservice.def
Library_install_updateservice.mk
lo.patch
Makefile
Module_onlineupdate.mk
monitor-sources.sh
Package_update-settings_ini.mk
Package_updater_ini.mk
README.md
StaticLibrary_libmar.mk
StaticLibrary_libmarverify.mk
StaticLibrary_updatehelper.mk
UnpackedTarball_onlineupdate.mk
unsigned-hack.patch
update-settings.ini
updater.ini
WinResTarget_updater.mk

Online Update

Online update implementation based on Mozilla's MAR format + update mechanism

The source code has been extracted from https://github.com/mozilla/gecko-dev with external/onlineupdate/generate-sources.sh.

The source/service directory contains the code for the silent windows updater that avoids the repeated administrator check for an update.

Note

The updater executable should not depend on any other dynamic library in the LibreOffice installation as we would need to copy that one also to a temporary directory during update. We can't update any library or executable that is currently in use. For the updater executable we solve this problem by copying the updater before using it to a temporary directory.

On Windows we use the system to provide us with a crypto library whereas on Linux we use NSS.

Update Procedure

The updater executable is run two times. In a first run, the current installation is copied to an update directory and the update is applied in this update directory. During the next run, a replacement request is executed. The replacement request removes the old installation directory and replaces it with the content of the update directory.

User Profile in the Installation Directory

The archive based installations have the user profile by default inside of the installation directory. During the update process this causes some problems that need special handling in the updater.

  • The update directory is inside of the user profile resulting in recursive copying.
  • During the replacement request the updater log is in the user profile, which changes location from the actual location to a backup location.

Executable_test_updater_dialog

To run that manual test, do

$ cp instdir/program/updater.ini workdir/LinkTarget/Executable/test_updater_dialog.ini
$ workdir/LinkTarget/Executable/test_updater_dialog
$ rm workdir/LinkTarget/Executable/test_updater_dialog.ini