Split --with-update-config=... into many --with-online-update-mar-...=...

...and allow each of them to be left off, for debug purposes, even if that may
render the resulting --enable-online-update-mar feature non-functional.

This change tracked each item that was potentially read from the
--with-update-config ini file, and turned each of them into a new
--with-online-update-mar-... option.  The only exception and remaining TODO is
bin/update/upload_build_config.py (called from Makefile.gbuild).

distro-configs/Jenkins/LibreOfficeLinuxUpdater.conf (which might well be dead)
set --with-update-config=~/updater.ini with an ini file of unknown content.  So
that no items are silently missing if we ever resurrect that distro-config, I
set all of the new options to =TODO there for now.

Change-Id: I17a13e0d190a868436bac10c1b0a6675d8c704c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160622
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
(cherry picked from commit e88bb8f6be937aeb951f1a64b4ff4e8c7e1280cc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160636
diff --git a/Makefile.gbuild b/Makefile.gbuild
index 88279b1..77100c07 100644
--- a/Makefile.gbuild
+++ b/Makefile.gbuild
@@ -41,9 +41,9 @@ create-update-info:
	rm -rf $(MAR_DIR) || true
	rm -rf $(UPDATE_DIR) || true
	mkdir -p $(MAR_DIR)/language
	MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_full_mar.py "$(PRODUCTNAME)" "$(WORKDIR)" "$(MAR_NAME_PREFIX)" "$(UPDATE_CONFIG)"
	MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_full_mar.py "$(PRODUCTNAME)" "$(WORKDIR)" "$(MAR_NAME_PREFIX)" "$(ONLINEUPDATE_MAR_CERTIFICATEPATH)" "$(ONLINEUPDATE_MAR_CERTIFICATENAME)" "$(ONLINEUPDATE_MAR_BASEURL)"
	$(if $(filter WNT,$(OS)),, \
		MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_full_mar_for_languages.py "$(PRODUCTNAME)" "$(WORKDIR)" "$(MAR_NAME_PREFIX)" "$(UPDATE_CONFIG)" \
		MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_full_mar_for_languages.py "$(PRODUCTNAME)" "$(WORKDIR)" "$(MAR_NAME_PREFIX)" "$(ONLINEUPDATE_MAR_CERTIFICATEPATH)" "$(ONLINEUPDATE_MAR_CERTIFICATENAME)" "$(ONLINEUPDATE_MAR_BASEURL)" \
	)

upload-update-info:
@@ -51,16 +51,16 @@ upload-update-info:
	$(eval PLATFORM := $(RTL_OS)_$(RTL_ARCH))
	$(eval UPDATE_DIR := $(WORKDIR)/update-info)
	$(eval VERSION := $(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR).$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)$(LIBO_VERSION_SUFFIX)$(LIBO_VERSION_SUFFIX_SUFFIX))
	MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_build_config.py "$(PRODUCTNAME)" "$(VERSION)" "$(BUILDID)" "$(PLATFORM)" "$(UPDATE_DIR)" "$(UPDATE_CONFIG)"
	MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/upload_builds.py "$(PRODUCTNAME)" "$(BUILDID)" "$(PLATFORM)" "$(UPDATE_DIR)" "$(UPDATE_CONFIG)"
	MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/upload_build_config.py "$(UPDATE_DIR)" "$(UPDATE_CONFIG)"
	MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_build_config.py "$(PRODUCTNAME)" "$(VERSION)" "$(BUILDID)" "$(PLATFORM)" "$(UPDATE_DIR)" "$(ONLINEUPDATE_MAR_CHANNEL)"
	MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/upload_builds.py "$(PRODUCTNAME)" "$(BUILDID)" "$(PLATFORM)" "$(UPDATE_DIR)" "$(ONLINEUPDATE_MAR_UPLOADURL)" "$(ONLINEUPDATE_MAR_CHANNEL)"
	MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/upload_build_config.py "$(UPDATE_DIR)" TODO

create-partial-info:
	$(eval BUILDID := $(shell git -C $(SRCDIR) log -1 --format=%H))
	$(eval VERSION := $(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR).$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)$(LIBO_VERSION_SUFFIX)$(LIBO_VERSION_SUFFIX_SUFFIX))
	$(eval PLATFORM := $(RTL_OS)_$(RTL_ARCH))
	$(eval MAR_NAME_PREFIX := $(PRODUCTNAME)_$(VERSION)_$(PLATFORM)_$(BUILDID))
	MBSDIFF=$(WORKDIR)/LinkTarget/Executable/mbsdiff MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_partial_update.py "$(WORKDIR)" "$(MAR_NAME_PREFIX)" "$(UPDATE_CONFIG)" "$(PLATFORM)" "$(BUILDID)"
	MBSDIFF=$(WORKDIR)/LinkTarget/Executable/mbsdiff MAR=$(INSTDIR)/program/mar $(SRCDIR)/bin/update/create_partial_update.py "$(WORKDIR)" "$(MAR_NAME_PREFIX)" "$(ONLINEUPDATE_MAR_SERVERURL)" "$(ONLINEUPDATE_MAR_CHANNEL)" "$(ONLINEUPDATE_MAR_CERTIFICATEPATH)" "$(ONLINEUPDATE_MAR_CERTIFICATENAME)" "$(ONLINEUPDATE_MAR_BASEURL)" "$(PLATFORM)" "$(BUILDID)"

# also possible to bypass the dependencies/the gbuild processing by just running
# LD_LIBRARY_PATH=instdir/program make cmd cmd='ALL_LANGS="$(ALL_LANGS)" workdir/LinkTarget/Executable/pocheck'
diff --git a/bin/update/config.py b/bin/update/config.py
deleted file mode 100644
index 25857bd..0000000
--- a/bin/update/config.py
+++ /dev/null
@@ -1,29 +0,0 @@
import configparser
import os


class Config(object):

    def __init__(self):
        self.certificate_path = None
        self.certificate_name = None
        self.channel = None
        self.base_url = None
        self.upload_url = None
        self.server_url = None


def parse_config(config_file):
    config = configparser.ConfigParser()
    config.read(os.path.expanduser(config_file))

    data = Config()
    updater_data = config['Updater']
    data.base_url = updater_data['base-url']
    data.certificate_name = updater_data['certificate-name']
    data.certificate_path = updater_data['certificate-path']
    data.channel = updater_data['channel']
    data.upload_url = updater_data['upload-url']
    data.server_url = updater_data["ServerURL"]

    return data
diff --git a/bin/update/create_build_config.py b/bin/update/create_build_config.py
index a8eb605..de39b64 100755
--- a/bin/update/create_build_config.py
+++ b/bin/update/create_build_config.py
@@ -4,8 +4,6 @@ import json
import sys
import os

from config import parse_config

from tools import replace_variables_in_string


@@ -29,15 +27,13 @@ def update_all_url_entries(data, **kwargs):

def main(argv):
    if len(argv) < 7:
        print("Usage: create_build_config.py $PRODUCTNAME $VERSION $BUILDID $PLATFORM $TARGETDIR $UPDATE_CONFIG")
        print("Usage: create_build_config.py $PRODUCTNAME $VERSION $BUILDID $PLATFORM $TARGETDIR $CHANNEL")
        sys.exit(1)

    config = parse_config(argv[6])

    data = {'productName': argv[1],
            'version': argv[2],
            'buildNumber': argv[3],
            'updateChannel': config.channel,
            'updateChannel': argv[6],
            'platform': argv[4]
            }

@@ -53,7 +49,7 @@ def main(argv):
            extra_data = json.load(f)
            data.update(extra_data)

    update_all_url_entries(data, channel=config.channel, platform=argv[4], buildid=argv[3], version=argv[2])
    update_all_url_entries(data, channel=argv[6], platform=argv[4], buildid=argv[3], version=argv[2])

    with open(os.path.join(argv[5], "build_config.json"), "w") as f:
        json.dump(data, f, indent=4)
diff --git a/bin/update/create_full_mar.py b/bin/update/create_full_mar.py
index 58fd7fb..c0d31592 100755
--- a/bin/update/create_full_mar.py
+++ b/bin/update/create_full_mar.py
@@ -7,7 +7,6 @@ import json
import argparse

from tools import uncompress_file_to_dir, get_file_info, make_complete_mar_name
from config import parse_config
from signing import sign_mar_file
from path import UpdaterPath, convert_to_unix, convert_to_native

@@ -19,26 +18,24 @@ def main():
    parser.add_argument('product_name')
    parser.add_argument('workdir')
    parser.add_argument('filename_prefix')
    parser.add_argument('update_config')
    parser.add_argument('certificate_path')
    parser.add_argument('certificate_name')
    parser.add_argument('base_url')
    args = parser.parse_args()

    update_config = args.update_config
    certificate_path = args.certificate_path
    certificate_name = args.certificate_name
    base_url = args.base_url
    filename_prefix = args.filename_prefix
    workdir = args.workdir
    product_name = args.product_name

    if len(update_config) == 0:
        print("missing update config")
        sys.exit(1)

    update_path = UpdaterPath(workdir)
    update_path.ensure_dir_exist()

    target_dir = update_path.get_update_dir()
    temp_dir = update_path.get_current_build_dir()

    config = parse_config(update_config)

    tar_dir = os.path.join(update_path.get_workdir(), "installation", product_name, "archive", "install", "en-US")
    tar_file = os.path.join(tar_dir, os.listdir(tar_dir)[0])

@@ -48,9 +45,9 @@ def main():
    path = os.path.join(current_dir_path, 'make_full_update.sh')
    subprocess.call([path, convert_to_native(mar_file), convert_to_native(uncompress_dir)])

    sign_mar_file(target_dir, config, mar_file, filename_prefix)
    sign_mar_file(target_dir, certificate_path, certificate_name, mar_file, filename_prefix)

    file_info = {'complete': get_file_info(mar_file, config.base_url)}
    file_info = {'complete': get_file_info(mar_file, base_url)}

    with open(os.path.join(target_dir, 'complete_info.json'), "w") as complete_info_file:
        json.dump(file_info, complete_info_file, indent=4)
diff --git a/bin/update/create_full_mar_for_languages.py b/bin/update/create_full_mar_for_languages.py
index 610bbc0..37d52e7 100755
--- a/bin/update/create_full_mar_for_languages.py
+++ b/bin/update/create_full_mar_for_languages.py
@@ -7,7 +7,6 @@ import json

from tools import uncompress_file_to_dir, get_file_info

from config import parse_config
from path import UpdaterPath
from signing import sign_mar_file

@@ -27,12 +26,14 @@ def create_lang_infos(mar_file_name, language, url):


def main():
    if len(sys.argv) < 5:
    if len(sys.argv) < 7:
        print(
            "Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $UPDATE_CONFIG")
            "Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $CERTIFICATEPATH $CERTIFICATENAME $BASEURL")
        sys.exit(1)

    update_config = sys.argv[4]
    certificate_path = sys.argv[4]
    certificate_name = sys.argv[5]
    base_url = sys.argv[6]
    filename_prefix = sys.argv[3]
    workdir = sys.argv[2]
    product_name = sys.argv[1]
@@ -41,8 +42,6 @@ def main():
    target_dir = updater_path.get_update_dir()
    temp_dir = updater_path.get_language_dir()

    config = parse_config(update_config)

    language_pack_dir = os.path.join(workdir, "installation", product_name + "_languagepack", "archive", "install")
    language_packs = os.listdir(language_pack_dir)
    lang_infos = []
@@ -59,9 +58,9 @@ def main():

        subprocess.call([os.path.join(current_dir_path, 'make_full_update.sh'), mar_file_name, directory])

        sign_mar_file(target_dir, config, mar_file_name, filename_prefix)
        sign_mar_file(target_dir, certificate_path, certificate_name, mar_file_name, filename_prefix)

        lang_infos.append(create_lang_infos(mar_file_name, language, config.base_url))
        lang_infos.append(create_lang_infos(mar_file_name, language, base_url))

    with open(os.path.join(target_dir, "complete_lang_info.json"), "w") as language_info_file:
        json.dump({'languages': lang_infos}, language_info_file, indent=4)
diff --git a/bin/update/create_partial_update.py b/bin/update/create_partial_update.py
index 83ac3a3..2730c47 100755
--- a/bin/update/create_partial_update.py
+++ b/bin/update/create_partial_update.py
@@ -6,7 +6,6 @@ import sys

import requests

from config import parse_config
from path import UpdaterPath, mkdir_p, convert_to_unix, convert_to_native
from signing import sign_mar_file
from tools import get_file_info, get_hash
@@ -54,9 +53,9 @@ def handle_language(lang_entries, filedir):
    return langs


def download_mar_for_update_channel_and_platform(config, platform, temp_dir):
    base_url = config.server_url + "update/partial-targets/1/"
    url = base_url + platform + "/" + config.channel
def download_mar_for_update_channel_and_platform(server_url, channel, platform, temp_dir):
    base_url = server_url + "update/partial-targets/1/"
    url = base_url + platform + "/" + channel
    r = requests.get(url)
    if r.status_code != 200:
        print(r.content)
@@ -110,9 +109,13 @@ def main():
    updater_path.ensure_dir_exist()

    mar_name_prefix = sys.argv[2]
    update_config = sys.argv[3]
    platform = sys.argv[4]
    build_id = sys.argv[5]
    server_url = sys.argv[3]
    channel = sys.argv[4]
    certificate_path = sys.argv[5]
    certificate_name = sys.argv[6]
    base_url = sys.argv[7]
    platform = sys.argv[8]
    build_id = sys.argv[9]

    current_build_path = updater_path.get_current_build_dir()
    mar_dir = updater_path.get_mar_dir()
@@ -123,9 +126,7 @@ def main():
    if sys.platform == "cygwin":
        current_build_path = add_single_dir(current_build_path)

    config = parse_config(update_config)

    updates = download_mar_for_update_channel_and_platform(config, platform, temp_dir)
    updates = download_mar_for_update_channel_and_platform(server_url, channel, platform, temp_dir)

    data = {"partials": []}

@@ -134,9 +135,9 @@ def main():
        mar_file = os.path.join(update_dir, file_name)
        subprocess.call([os.path.join(current_dir_path, 'make_incremental_update.sh'), convert_to_native(mar_file),
                         convert_to_native(update["complete"]), convert_to_native(current_build_path)])
        sign_mar_file(update_dir, config, mar_file, mar_name_prefix)
        sign_mar_file(update_dir, certificate_path, certificate_name, mar_file, mar_name_prefix)

        partial_info = {"file": get_file_info(mar_file, config.base_url), "from": build, "to": build_id,
        partial_info = {"file": get_file_info(mar_file, base_url), "from": build, "to": build_id,
                        "languages": {}}

        # on Windows we don't use language packs
@@ -153,10 +154,10 @@ def main():
                subprocess.call(
                    [os.path.join(current_dir_path, 'make_incremental_update.sh'), convert_to_native(lang_mar_file),
                     convert_to_native(lang_info), convert_to_native(language_dir)])
                sign_mar_file(update_dir, config, lang_mar_file, mar_name_prefix)
                sign_mar_file(update_dir, certificate_path, certificate_name, lang_mar_file, mar_name_prefix)

                # add the partial language info
                partial_info["languages"][lang] = get_file_info(lang_mar_file, config.base_url)
                partial_info["languages"][lang] = get_file_info(lang_mar_file, base_url)

        data["partials"].append(partial_info)

diff --git a/bin/update/get_update_channel.py b/bin/update/get_update_channel.py
deleted file mode 100755
index 4215f80..0000000
--- a/bin/update/get_update_channel.py
+++ /dev/null
@@ -1,25 +0,0 @@
#!/usr/bin/python3
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

import sys
from config import parse_config


def main():
    if len(sys.argv) < 2:
        sys.exit(1)

    update_config = sys.argv[1]
    config = parse_config(update_config)
    print(config.channel)


if __name__ == "__main__":
    main()

# vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/bin/update/signing.py b/bin/update/signing.py
index 65b482f..e8546dc 100644
--- a/bin/update/signing.py
+++ b/bin/update/signing.py
@@ -5,11 +5,11 @@ import subprocess
import path


def sign_mar_file(target_dir, config, mar_file, filename_prefix):
def sign_mar_file(target_dir, certificate_path, certificate_name, mar_file, filename_prefix):
    signed_mar_file = make_complete_mar_name(target_dir, filename_prefix + '_signed')
    mar_executable = os.environ.get('MAR', 'mar')
    subprocess.check_call([mar_executable, '-C', path.convert_to_native(target_dir), '-d',
                           path.convert_to_native(config.certificate_path), '-n', config.certificate_name, '-s',
                           path.convert_to_native(certificate_path), '-n', certificate_name, '-s',
                           path.convert_to_native(mar_file), path.convert_to_native(signed_mar_file)])

    os.rename(signed_mar_file, mar_file)
diff --git a/bin/update/upload_builds.py b/bin/update/upload_builds.py
index 1be1b2f..97a2f28 100755
--- a/bin/update/upload_builds.py
+++ b/bin/update/upload_builds.py
@@ -4,7 +4,6 @@ import sys
import os
import subprocess

from config import parse_config
from path import convert_to_unix

from tools import replace_variables_in_string
@@ -15,10 +14,10 @@ def main():
    buildid = sys.argv[2]
    platform = sys.argv[3]
    update_dir = sys.argv[4]
    update_config = sys.argv[5]
    upload_url_arg = sys.argv[5]
    channel = sys.argv[6]

    config = parse_config(update_config)
    upload_url = replace_variables_in_string(config.upload_url, channel=config.channel, buildid=buildid,
    upload_url = replace_variables_in_string(upload_url_arg, channel=channel, buildid=buildid,
                                             platform=platform)

    target_url, target_dir = upload_url.split(':')
diff --git a/config_host.mk.in b/config_host.mk.in
index cc8f550..97a2b0b 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -510,6 +510,13 @@ export ODFGEN_LIBS=$(gb_SPACE)@ODFGEN_LIBS@
export ODFVALIDATOR=@ODFVALIDATOR@
export OFFICEOTRON=@OFFICEOTRON@
export BFFVALIDATOR=@BFFVALIDATOR@
export ONLINEUPDATE_MAR_BASEURL=@ONLINEUPDATE_MAR_BASEURL@
export ONLINEUPDATE_MAR_CERTIFICATEDER=@ONLINEUPDATE_MAR_CERTIFICATEDER@
export ONLINEUPDATE_MAR_CERTIFICATENAME=@ONLINEUPDATE_MAR_CERTIFICATENAME@
export ONLINEUPDATE_MAR_CERTIFICATEPATH=@ONLINEUPDATE_MAR_CERTIFICATEPATH@
export ONLINEUPDATE_MAR_CHANNEL=@ONLINEUPDATE_MAR_CHANNEL@
export ONLINEUPDATE_MAR_SERVERURL=@ONLINEUPDATE_MAR_SERVERURL@
export ONLINEUPDATE_MAR_UPLOADURL=@ONLINEUPDATE_MAR_UPLOADURL@
export OOO_JUNIT_JAR=@OOO_JUNIT_JAR@
export OOO_VENDOR=@OOO_VENDOR@
export OPENSSL_CFLAGS=$(gb_SPACE)@OPENSSL_CFLAGS@
@@ -717,7 +724,6 @@ export UNIX_DLAPI_LIBS=@UNIX_DLAPI_LIBS@
export USE_HEADLESS_CODE=@USE_HEADLESS_CODE@
export USE_LD=@USE_LD@
export USE_LIBRARY_BIN_TAR=@USE_LIBRARY_BIN_TAR@
export UPDATE_CONFIG=@UPDATE_CONFIG@
export UUIDGEN=@UUIDGEN@
export VALGRIND_CFLAGS=$(gb_SPACE)@VALGRIND_CFLAGS@
export VCL_PLUGIN_INFO=@VCL_PLUGIN_INFO@
diff --git a/configure.ac b/configure.ac
index ddc3ef9..eb21856 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1862,13 +1862,57 @@ libo_FUZZ_ARG_ENABLE(online-update,
libo_FUZZ_ARG_ENABLE(online-update-mar,
    AS_HELP_STRING([--enable-online-update-mar],
        [Enable the experimental Mozilla-like online update service that will
         check for new versions of LibreOffice. Disabled by default. Requires
         --with-update-config to be set.]),
         check for new versions of LibreOffice. Disabled by default.]),
,)

AC_ARG_WITH(update-config,
    AS_HELP_STRING([--with-update-config=/tmp/update.ini],
                   [Path to the update config ini file]))
libo_FUZZ_ARG_WITH(online-update-mar-baseurl,
    AS_HELP_STRING([--with-online-update-mar-baseurl=...],
        [Set the base URL value for --enable-online-update-mar.
         (Can be left off for debug purposes, even if that may render the feature
         non-functional.)]),
,)

libo_FUZZ_ARG_WITH(online-update-mar-certificateder,
    AS_HELP_STRING([--with-online-update-mar-certificateder=...],
        [Set the certificate DER value for --enable-online-update-mar.
         (Can be left off for debug purposes, even if that may render the feature
         non-functional.)]),
,)

libo_FUZZ_ARG_WITH(online-update-mar-certificatename,
    AS_HELP_STRING([--with-online-update-mar-certificatename=...],
        [Set the certificate name value for --enable-online-update-mar.
         (Can be left off for debug purposes, even if that may render the feature
         non-functional.)]),
,)

libo_FUZZ_ARG_WITH(online-update-mar-certificatepath,
    AS_HELP_STRING([--with-online-update-mar-certificatepath=...],
        [Set the certificate path value for --enable-online-update-mar.
         (Can be left off for debug purposes, even if that may render the feature
         non-functional.)]),
,)

libo_FUZZ_ARG_WITH(online-update-mar-channel,
    AS_HELP_STRING([--with-online-update-mar-channel=...],
        [Set the channel value for --enable-online-update-mar.
         (Can be left off for debug purposes, even if that may render the feature
         non-functional.)]),
,)

libo_FUZZ_ARG_WITH(online-update-mar-serverurl,
    AS_HELP_STRING([--with-online-update-mar-serverurl=...],
        [Set the server URL value for --enable-online-update-mar.
         (Can be left off for debug purposes, even if that may render the feature
         non-functional.)]),
,)

libo_FUZZ_ARG_WITH(online-update-mar-uploadurl,
    AS_HELP_STRING([--with-online-update-mar-uploadurl=...],
        [Set the upload URL value for --enable-online-update-mar.
         (Can be left off for debug purposes, even if that may render the feature
         non-functional.)]),
,)

libo_FUZZ_ARG_ENABLE(extension-update,
    AS_HELP_STRING([--disable-extension-update],
@@ -13598,20 +13642,77 @@ dnl Test whether to enable mar online update service
dnl ===================================================================
AC_MSG_CHECKING([whether to enable mar online update])
ENABLE_ONLINE_UPDATE_MAR=
UPDATE_CONFIG=
if test "$enable_online_update_mar" = yes; then
    AC_MSG_RESULT([yes])
    ENABLE_ONLINE_UPDATE_MAR="TRUE"
    if test "$with_update_config" = ""; then
        AC_MSG_ERROR([mar based online updater needs an update config specified with "with-update-config])
    fi
    UPDATE_CONFIG="$with_update_config"
    AC_DEFINE(HAVE_FEATURE_UPDATE_MAR)
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_ONLINE_UPDATE_MAR)
AC_SUBST(UPDATE_CONFIG)

AC_MSG_CHECKING([for mar online update baseurl])
ONLINEUPDATE_MAR_BASEURL=$with_online_update_mar_baseurl
if test -n "$ONLINEUPDATE_MAR_BASEURL"; then
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(ONLINEUPDATE_MAR_BASEURL)

AC_MSG_CHECKING([for mar online update certificateder])
ONLINEUPDATE_MAR_CERTIFICATEDER=$with_online_update_mar_certificateder
if test -n "$ONLINEUPDATE_MAR_CERTIFICATEDER"; then
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(ONLINEUPDATE_MAR_CERTIFICATEDER)

AC_MSG_CHECKING([for mar online update certificatename])
ONLINEUPDATE_MAR_CERTIFICATENAME=$with_online_update_mar_certificatename
if test -n "$ONLINEUPDATE_MAR_CERTIFICATENAME"; then
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(ONLINEUPDATE_MAR_CERTIFICATENAME)

AC_MSG_CHECKING([for mar online update certificatepath])
ONLINEUPDATE_MAR_CERTIFICATEPATH=$with_online_update_mar_certificatepath
if test -n "$ONLINEUPDATE_MAR_CERTIFICATEPATH"; then
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(ONLINEUPDATE_MAR_CERTIFICATEPATH)

AC_MSG_CHECKING([for mar online update channel])
ONLINEUPDATE_MAR_CHANNEL=$with_online_update_mar_channel
if test -n "$ONLINEUPDATE_MAR_CHANNEL"; then
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(ONLINEUPDATE_MAR_CHANNEL)

AC_MSG_CHECKING([for mar online update serverurl])
ONLINEUPDATE_MAR_SERVERURL=$with_online_update_mar_serverurl
if test -n "$ONLINEUPDATE_MAR_SERVERURL"; then
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(ONLINEUPDATE_MAR_SERVERURL)

AC_MSG_CHECKING([for mar online update uploadurl])
ONLINEUPDATE_MAR_UPLOADURL=$with_online_update_mar_uploadurl
if test -n "$ONLINEUPDATE_MAR_UPLOADURL"; then
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi
AC_SUBST(ONLINEUPDATE_MAR_UPLOADURL)


PRIVACY_POLICY_URL="$with_privacy_policy_url"
diff --git a/distro-configs/Jenkins/LibreOfficeLinuxUpdater.conf b/distro-configs/Jenkins/LibreOfficeLinuxUpdater.conf
index e2c510f..d198cdb 100644
--- a/distro-configs/Jenkins/LibreOfficeLinuxUpdater.conf
+++ b/distro-configs/Jenkins/LibreOfficeLinuxUpdater.conf
@@ -32,6 +32,12 @@
--disable-dconf
--with-lang=de es fr ar zh-CN
--with-package-format=archive
--with-update-config=~/updater.ini
--with-online-update-mar-baseurl=TODO
--with-online-update-mar-certificateder=TODO
--with-online-update-mar-certificatename=TODO
--with-online-update-mar-certificatepath=TODO
--with-online-update-mar-channel=TODO
--with-online-update-mar-serverurl=TODO
--with-online-update-mar-uploadurl=TODO
--with-jdk-home=/etc/alternatives/java_sdk_17
--enable-odk
diff --git a/instsetoo_native/CustomTarget_setup.mk b/instsetoo_native/CustomTarget_setup.mk
index 92fb00b..2861155 100644
--- a/instsetoo_native/CustomTarget_setup.mk
+++ b/instsetoo_native/CustomTarget_setup.mk
@@ -182,7 +182,7 @@ define instsetoo_native_genversionini
AllLanguages=$(if $(gb_WITH_LANG),$(gb_WITH_LANG),en-US)
buildid=$(shell cd $(SRCDIR) && git log -1 --format=%H)
ExtensionUpdateURL=https://updateexte.libreoffice.org/ExtensionUpdateService/check.Update
UpdateChannel=$(if $(ENABLE_ONLINE_UPDATE_MAR),$(shell cd $(SRCDIR) && bin/update/get_update_channel.py $(UPDATE_CONFIG)))
UpdateChannel=$(if $(ENABLE_ONLINE_UPDATE_MAR),$(ONLINEUPDATE_MAR_CHANNEL))
ReferenceOOoMajorMinor=4.1
UpdateID=$(PRODUCTNAME)_$(LIBO_VERSION_MAJOR)_en-US
UpdateURL=$(if $(ENABLE_ONLINE_UPDATE),https://update.libreoffice.org/check.php$(if $(filter-out WNT,$(OS)),?pkgfmt=$(PKGFORMAT)))
diff --git a/onlineupdate/CustomTarget_generated.mk b/onlineupdate/CustomTarget_generated.mk
index 266b2db9..0673bfb 100644
--- a/onlineupdate/CustomTarget_generated.mk
+++ b/onlineupdate/CustomTarget_generated.mk
@@ -11,19 +11,29 @@ $(eval $(call gb_CustomTarget_CustomTarget,onlineupdate/generated))

onlineupdate_INC := $(call gb_CustomTarget_get_workdir,onlineupdate/generated)/onlineupdate

# For debug purposes, ONLINEUPDATE_MAR_CERTIFICATEDER can be empty, but gen_cert_header.py always
# expects an existing certificate-der=... pathname, so as a hack fall back to the generated
# update.ini itself as the pathanme of the certfiicate DER file (though that will cause
# gen_cert_header.py to generate nonsense data, of course):
$(call gb_CustomTarget_get_workdir,onlineupdate/generated)/update.ini: | \
        $(call gb_CustomTarget_get_workdir,onlineupdate/generated)/.dir
	printf '[Updater]\ncertificate-der=%s\n' '$(or $(ONLINEUPDATE_MAR_CERTIFICATEDER),$@)' > $@

$(onlineupdate_INC)/primaryCert.h : \
		$(SRCDIR)/onlineupdate/source/update/updater/gen_cert_header.py \
		$(call gb_ExternalExecutable_get_dependencies,python)
		$(call gb_ExternalExecutable_get_dependencies,python) \
		$(call gb_CustomTarget_get_workdir,onlineupdate/generated)/update.ini
	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,,1)
	mkdir -p $(dir $@)
	$(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/onlineupdate/source/update/updater/gen_cert_header.py "primaryCertData" $(UPDATE_CONFIG) > $(onlineupdate_INC)/primaryCert.h #"$(UPDATE_CONFIG)"
	$(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/onlineupdate/source/update/updater/gen_cert_header.py "primaryCertData" $(call gb_CustomTarget_get_workdir,onlineupdate/generated)/update.ini > $(onlineupdate_INC)/primaryCert.h

$(onlineupdate_INC)/secondaryCert.h : \
		$(SRCDIR)/onlineupdate/source/update/updater/gen_cert_header.py \
		$(call gb_ExternalExecutable_get_dependencies,python)
		$(call gb_ExternalExecutable_get_dependencies,python) \
		$(call gb_CustomTarget_get_workdir,onlineupdate/generated)/update.ini
	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,,1)
	mkdir -p $(dir $@)
	$(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/onlineupdate/source/update/updater/gen_cert_header.py "secondaryCertData" $(UPDATE_CONFIG) > $(onlineupdate_INC)/secondaryCert.h #"$(UPDATE_CONFIG)"
	$(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/onlineupdate/source/update/updater/gen_cert_header.py "secondaryCertData" $(call gb_CustomTarget_get_workdir,onlineupdate/generated)/update.ini > $(onlineupdate_INC)/secondaryCert.h

$(call gb_CustomTarget_get_target,onlineupdate/generated) : \
	$(onlineupdate_INC)/primaryCert.h \
diff --git a/solenv/bin/modules/installer/scriptitems.pm b/solenv/bin/modules/installer/scriptitems.pm
index 54f3618..df76cb6 100644
--- a/solenv/bin/modules/installer/scriptitems.pm
+++ b/solenv/bin/modules/installer/scriptitems.pm
@@ -655,25 +655,7 @@ sub replace_setup_variables
    my $updateid = $productname . "_" . $libo_version_major . "_" . $$languagestringref;
    $updateid =~ s/ /_/g;

    my $updatechannel = "";
    if ( $ENV{'UPDATE_CONFIG'} && $ENV{'UPDATE_CONFIG'} ne "")
    {
        open(CONFIG, glob($ENV{'UPDATE_CONFIG'}));
        while (<CONFIG>)
        {
            chomp;
            if (/^s*(\S+)=(\S+)$/)
            {
                my $key = $1;
                my $val = $2;
                if ($key eq "channel")
                {
                    $updatechannel = $val;
                }
            }
        }
        close(CONFIG);
    }
    my $updatechannel = $ENV{'ONLINEUPDATE_MAR_CHANNEL'};

    for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
    {