Skip to content

Commit

Permalink
Rebase Brave's changes on top of c97bc28
Browse files Browse the repository at this point in the history
Tested with:

 * Visual Studio 2022
 * Windows SDK 10.0.22621.0
 * WTL 10.0.10320
 * Python 2.7
 * pywin32 224
 * SCons 1.3.1
 * Google Software Construction Toolkit 0.9.1
 * Go 1.14.6 (64 bit)
 * Google Protocol Buffers 3.17.3

The following tests fail on Windows 11. They either also fail upstream, or
already failed in our fork before this rebase.

 * TimeTest.RFC822TimeParsing
 * UserRightsTest.UserIsLoggedOnInteractively
 * UtilsTest.IsUserLoggedOn
 * OmahaCustomizationTest.IsInternalUser
 * PingTest.BuildOmahaPing
 * PingTest.SendInProcess
 * PingTest.PersistAndSendPersistedPings
 * WebServicesClientTest.Send
 * WebServicesClientTest.SendForcingHttps
 * WebServicesClientTest.SendWithCustomHeader
 * WebServicesClientTest.SendStringWithCustomHeader
 * DownloadManagerUserTest.DownloadApp_MultiplePackagesInOneApp
 * InstallManagerInstallAppMachineTest.InstallApp_MsiInstallerSucceeds
 * InstallManagerInstallAppMachineTest.InstallApp_MsiInstallerWithArgumentSucceeds
 * InstallerWrapperMachineTest.InstallApp_MsiInstallerSucceeds
 * InstallerWrapperMachineTest.InstallApp_MsiInstallerWithArgumentSucceeds
 * WorkerWithTwoAppsTest.CheckForUpdateAsync_Large
 * WorkerWithTwoAppsTest.DownloadAsyncThenDownloadAndInstallAsync_Large
 * CupEcdsaRequestTest.PostSimpleRequest
 * CupEcdsaRequestTest.PostSimpleRequestHttps
 * NetworkRequestTest.MultipleRequests
 * GoogleUpdateRecoveryTest.FixGoogleUpdate_FileReturned_Machine
 * GoogleUpdateRecoveryTest.FixGoogleUpdate_FileReturned_User
 * GoogleUpdateRecoveryTest.FixGoogleUpdate_FileCollision
 * GoogleUpdateRecoveryTest.VerifyFileSignature_SignedValid
 * GoogleUpdateRecoveryTest.ProductionServerResponseTest
 * SetupUserTest.TerminateCoreProcesses_BothTypesRunningAndSimilarArgsProcess
 * SetupMachineTest.StopGoogleUpdateAndWait_ProcessesDoNotStop
 * SetupMachineTest.StopGoogleUpdateAndWait_UserHandoffWorkerRunningAsSystem
 * SetupMachineTest.StopGoogleUpdateAndWait_UserLegacyInstallGoogleUpdateWorkerRunningAsSystem
 * SetupMachineTest.TerminateCoreProcesses_BothTypesRunningAndSimilarArgsProcess
 * IsDomainIsDMIsCloudPolicyOverridesPlatformPolicy/ConfigManagerTest.AreUpdatesSuppressedNow_MultipleValues/2, where GetParam() = (false, true, false)
 * IsDomainIsDMIsCloudPolicyOverridesPlatformPolicy/ConfigManagerTest.AreUpdatesSuppressedNow_MultipleValues/3, where GetParam() = (false, true, true)
 * IsDomainIsDMIsCloudPolicyOverridesPlatformPolicy/ConfigManagerTest.AreUpdatesSuppressedNow_MultipleValues/7, where GetParam() = (true, true, true)
 * IsForeground/WebServicesClientTest.SendUsingCup/0, where GetParam() = false
 * IsForeground/WebServicesClientTest.SendUsingCup/1, where GetParam() = true
 * IsForeground/WebServicesClientTest.SendString/0, where GetParam() = false
 * IsForeground/WebServicesClientTest.SendString/1, where GetParam() = true
  • Loading branch information
mherrmann committed Jan 29, 2024
1 parent c97bc28 commit 2c273a9
Show file tree
Hide file tree
Showing 189 changed files with 2,488 additions and 336 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
omaha/common/omaha_customization_proxy_clsid.h
omaha/proxy_clsids.txt
omaha/scons-out/
omaha/standalone/*
third_party/lzma/files/**/obj/
12 changes: 0 additions & 12 deletions .gitmodules

This file was deleted.

64 changes: 64 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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("//brave/build/config.gni")

assert(is_win)

group("omaha") {
deps = [ ":build_omaha_installer" ]
}

action("build_omaha_installer") {
script="build_omaha.py"

inputs = [ "build_omaha.py" ]

sources = [ "$root_out_dir/$brave_installer_exe" ]

_install_switch = ""
_tag_app_name = "Brave-Release"
if (brave_channel == "beta") {
_install_switch = "--chrome-beta"
_tag_app_name = "Brave-Browser-Beta"
} else if (brave_channel == "dev") {
_install_switch = "--chrome-dev"
_tag_app_name = "Brave-Browser-Dev"
} else if (brave_channel == "nightly") {
_install_switch = "--chrome-sxs"
_tag_app_name = "Brave-Browser-Nightly"
} else {
assert(brave_channel == "", "Unknown channel name")
}

out_dir = rebase_path(root_out_dir)

args = [
"--root_out_dir=$out_dir",
"--brave_installer_exe=$brave_installer_exe",
"--stub_installer_exe=$brave_stub_installer_exe",
"--stub_untagged_exe=$brave_untagged_stub_installer_exe",
"--standalone_installer_exe=$brave_standalone_installer_exe",
"--silent_installer_exe=$brave_silent_installer_exe",
"--untagged_installer_exe=$brave_untagged_installer_exe",
"--guid=$brave_app_guid",
"--install_switch=$_install_switch",
"--tag_ap=$tag_ap",
"--tag_app_name=$_tag_app_name",
"--brave_full_version=$chrome_version_major.$brave_version_major.$brave_version_minor.$brave_version_build",
"--tag_installdataindex=$tag_installdataindex",
]

outputs = [
"$root_out_dir/$brave_stub_installer_exe",
"$root_out_dir/$brave_standalone_installer_exe",
"$root_out_dir/$brave_silent_installer_exe",
"$root_out_dir/$brave_untagged_installer_exe",
]

deps = [
"//brave/build/win:create_signed_installer",
]
}

6 changes: 6 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
deps = {
"omaha/third_party/breakpad": "https://github.com/google/breakpad.git@11ec9c32888c06665b8838f709bd66c0be9789a6",
"omaha/third_party/googletest": "https://github.com/google/googletest.git@96eadf659fb75ecda943bd97413c71d4c17c4f43",
"omaha/third_party/libzip": "https://github.com/nih-at/libzip.git@5532f9baa0c44cc5435ad135686a4ea009075b9a",
"omaha/third_party/zlib": "https://github.com/madler/zlib.git@cacf7f1d4e3d44d871b605da3b647f07d718623f"
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Omaha

## This is not an official Google product.
## How to build ##
See https://github.com/brave/brave-browser/wiki/Brave-omaha

Omaha is the open-source version of Google Update, a program to install requested software and keep it up to date. The Google-branded version of Omaha is used to support software patching (both background updating, and on-demand update checks) for Google Chrome, Earth, and a variety of other Google products on Windows 7, 8, and 10.

Expand Down
224 changes: 224 additions & 0 deletions build_omaha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
# 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 argparse
import os
import os.path
import shutil
import subprocess as sp
import sys


def build(omaha_dir, standalone_installers_dir, debug):
# move to omaha/omaha and start build.
os.chdir(os.path.join(omaha_dir, 'omaha'))

# set signing environment variables
key_pfx_path = os.environ.get('KEY_PFX_PATH', '')
key_cer_path = os.environ.get('KEY_CER_PATH', '')
authenticode_password = os.environ.get('AUTHENTICODE_PASSWORD', '')
authenticode_hash = os.environ.get('AUTHENTICODE_HASH', '')

mode = 'opt-win'
if debug:
mode = 'dbg-win'
command = ['hammer.bat', 'MODE=' + mode, '--all', '--standalone_installers_dir=' + standalone_installers_dir]
if key_pfx_path:
command.append('--authenticode_file=' + key_pfx_path)
command.append('--sha2_authenticode_file=' + key_pfx_path)
if authenticode_password:
command.append('--authenticode_password=' + authenticode_password)
command.append('--sha2_authenticode_password=' + authenticode_password)
if authenticode_hash:
command.append('--authenticode_hash=' + authenticode_hash)
command.append('--sha2_authenticode_hash=' + authenticode_hash)
# Our certs identified by hash are always in the machine store:
command.append('--use_authenticode_machine_store')

# Pick signtool.exe from PATH. This in particular ensures that we use the same
# signtool as Chromium, which is 64 bit and thus has access to the same certs.
env = dict(os.environ)
signtool_path = shutil.which('signtool.exe')
assert signtool_path, 'signtool.exe is expected to be on PATH'
env['OMAHA_SIGNTOOL_SDK_DIR'] = os.path.dirname(signtool_path)

sp.check_call(command, stderr=sp.STDOUT, env=env)

def copy_untagged_installers(args, omaha_dir):
omaha_out_dir = get_omaha_out_dir(omaha_dir, args.debug)

source_untagged_installer = os.path.join(omaha_out_dir, 'Test_Installers', 'UNOFFICIAL_' + args.untagged_installer_exe[0])
target_untagged_installer_file = args.untagged_installer_exe[0]
if args.debug:
target_untagged_installer_file = 'Debug' + target_untagged_installer_file
target_untagged_installer = os.path.join(args.root_out_dir[0], target_untagged_installer_file)

shutil.copyfile(source_untagged_installer, target_untagged_installer)

source_untagged_stub_installer = os.path.join(omaha_out_dir, 'staging', 'BraveUpdateSetup.exe')
target_untagged_stub_installer_file = args.stub_untagged_exe[0]
if args.debug:
target_untagged_stub_installer_file = 'Debug' + target_untagged_stub_installer_file
target_untagged_stub_installer = os.path.join(args.root_out_dir[0], target_untagged_stub_installer_file)

shutil.copyfile(source_untagged_stub_installer, target_untagged_stub_installer)

def get_omaha_out_dir(omaha_dir, debug):
last_win_dir = 'opt-win'
if debug:
last_win_dir = 'dbg-win'
return os.path.join(omaha_dir, 'omaha', 'scons-out', last_win_dir)

def prepare_untagged_standalone(args, omaha_dir):
return prepare_untagged(
omaha_dir, 'standalone', args.root_out_dir[0], args.brave_installer_exe[0], args.guid[0],
'--do-not-launch-chrome ' + args.install_switch[0], args.brave_full_version[0],
[(args.standalone_installer_exe[0], args.brave_installer_exe[0]),
(args.untagged_installer_exe[0], args.untagged_installer_exe[0])], args.debug
)

def prepare_untagged_silent(args, omaha_dir):
return prepare_untagged(
omaha_dir, 'silent', args.root_out_dir[0], args.brave_installer_exe[0], args.guid[0],
'--do-not-launch-chrome ' + args.install_switch[0], args.brave_full_version[0],
[(args.silent_installer_exe[0], args.silent_installer_exe[0])], args.debug
)

def prepare_untagged(omaha_dir, name, root_out_dir, brave_installer_exe, app_guid, install_switch, brave_full_version, details, debug):
omaha_out_dir = get_omaha_out_dir(omaha_dir, debug)
out_dir = os.path.join(omaha_out_dir, 'Brave_Installers', name)

if not os.path.exists(out_dir):
os.makedirs(out_dir)

# prepare manifest file.
f = open(os.path.join(omaha_dir, 'manifest_template.gup'),'r')
filedata = f.read()
f.close()

newdata = filedata.replace("APP_GUID", app_guid)
newdata = newdata.replace("BRAVE_INSTALLER_EXE", brave_installer_exe)
newdata = newdata.replace("INSTALL_SWITCH", install_switch)

target_manifest_dir = os.path.join(out_dir, 'manifests')

if not os.path.exists(target_manifest_dir):
os.mkdir(target_manifest_dir)

target_manifest_file = app_guid + '.gup'
target_manifest_path = os.path.join(target_manifest_dir, target_manifest_file)
f = open(target_manifest_path, 'w')
f.write(newdata)
f.close()

target_installer_text_path = os.path.join(out_dir, 'standalone_installers.txt')

# Clear the file:
open(target_installer_text_path, 'w').close()

for file_name, installer_exe in details:
brave_installer_path = os.path.join(root_out_dir, brave_installer_exe)
brave_installer_path_fixed_name = os.path.join(out_dir, installer_exe)
shutil.copyfile(brave_installer_path, brave_installer_path_fixed_name)
add_to_standalone_installers_txt(target_installer_text_path, file_name, app_guid, brave_installer_path_fixed_name, brave_full_version)

return out_dir

def add_to_standalone_installers_txt(target_installer_text_path, file_name, app_guid, installer_exe_path, brave_version):
installer_text = "('FILE_NAME', 'FILE_NAME', [('BRAVE_VERSION', 'BRAVE_INSTALLER_EXE', 'APP_GUID')], None, None, None, False, '', '')"
installer_text = installer_text.replace("FILE_NAME", os.path.splitext(file_name)[0])
installer_text = installer_text.replace("APP_GUID", app_guid)
installer_text = installer_text.replace("BRAVE_INSTALLER_EXE", installer_exe_path.replace('\\', '/'))
installer_text = installer_text.replace("BRAVE_VERSION", brave_version)
f = open(target_installer_text_path,'a+')
f.write(installer_text + '\n')
f.close()

def tag_standalone(args, omaha_dir):
tag_admin = os.environ.get('TAG_ADMIN', 'prefers')
tag = 'appguid=APP_GUID&appname=TAG_APP_NAME&needsadmin=TAG_ADMIN&ap=TAG_AP'
tag = tag.replace("TAG_ADMIN", tag_admin)
tag = tag.replace("APP_GUID", args.guid[0])
tag = tag.replace("TAG_APP_NAME", args.tag_app_name[0])
tag = tag.replace("TAG_AP", args.tag_ap[0])

apply_tag(omaha_dir, args.debug, 'Test_Installers/UNOFFICIAL_' + args.standalone_installer_exe[0], args.standalone_installer_exe[0], tag, args.root_out_dir[0])

if args.tag_installdataindex:
# This current implementation doesn't have the install data value. But it
# exists on the update server. So we only apply the index to the online
# ("stub") installer.
tag += '&installdataindex=' + args.tag_installdataindex

apply_tag(omaha_dir, args.debug, 'staging/BraveUpdateSetup.exe', args.stub_installer_exe[0], tag, args.root_out_dir[0])

def tag_silent(args, omaha_dir):
silent_tag = 'appguid=APP_GUID&appname=TAG_APP_NAME&needsadmin=TAG_ADMIN&ap=TAG_AP&silent'
silent_tag = silent_tag.replace("TAG_ADMIN", 'False')
silent_tag = silent_tag.replace("APP_GUID", args.guid[0])
silent_tag = silent_tag.replace("TAG_APP_NAME", args.tag_app_name[0])
silent_tag = silent_tag.replace("TAG_AP", args.tag_ap[0])

apply_tag(omaha_dir, args.debug, 'Test_Installers/UNOFFICIAL_' + args.silent_installer_exe[0], args.silent_installer_exe[0], silent_tag, args.root_out_dir[0])

def apply_tag(omaha_dir, debug, source_installer, target_installer_file, tag, root_out_dir):
omaha_out_dir = get_omaha_out_dir(omaha_dir, debug)
apply_tag_exe = os.path.join(omaha_out_dir, 'obj', 'tools', 'ApplyTag', 'ApplyTag.exe')

source_installer_path = os.path.join(omaha_out_dir, *source_installer.split('/'))
if debug:
target_installer_file = 'Debug' + target_installer_file
target_installer_path = os.path.join(root_out_dir, target_installer_file)
command = [apply_tag_exe, source_installer_path, target_installer_path, tag]
sp.check_call(command, stderr=sp.STDOUT)

def parse_args():
parser = argparse.ArgumentParser(description='build omaha installer')
parser.add_argument('--root_out_dir',
nargs=1)
parser.add_argument('--brave_installer_exe',
nargs=1)
parser.add_argument('--stub_installer_exe',
nargs=1)
parser.add_argument('--stub_untagged_exe',
nargs=1)
parser.add_argument('--standalone_installer_exe',
nargs=1)
parser.add_argument('--silent_installer_exe',
nargs=1)
parser.add_argument('--untagged_installer_exe',
nargs=1)
parser.add_argument('--guid',
nargs=1)
parser.add_argument('--install_switch',
nargs=1)
parser.add_argument('--tag_ap',
nargs=1)
parser.add_argument('--tag_app_name',
nargs=1)
parser.add_argument('--brave_full_version',
nargs=1)
parser.add_argument('--tag_installdataindex')
parser.add_argument('--debug', action='store_true')
return parser.parse_args()

def main():
args = parse_args()
omaha_dir = os.path.join(args.root_out_dir[0], '..', '..', 'brave', 'vendor', 'omaha')

installer_metadata_dir = prepare_untagged_standalone(args, omaha_dir)
build(omaha_dir, installer_metadata_dir, args.debug)
tag_standalone(args, omaha_dir)

installer_metadata_dir = prepare_untagged_silent(args, omaha_dir)
build(omaha_dir, installer_metadata_dir, args.debug)
tag_silent(args, omaha_dir)

copy_untagged_installers(args, omaha_dir)

return 0


if __name__ == '__main__':
sys.exit(main())
18 changes: 18 additions & 0 deletions manifest_template.gup
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<response protocol="3.0">
<app appid="APP_GUID" status="ok">
<updatecheck status="ok">
<urls>
<url codebase="http://dl.google.com/foo/${INSTALLER_VERSION}/"/>
</urls>
<manifest version="${INSTALLER_VERSION}">
<packages>
<package name="BRAVE_INSTALLER_EXE" hash_sha256="${INSTALLER_HASH_SHA256}" size="${INSTALLER_SIZE}" required="true"/>
</packages>
<actions>
<action event="install" run="BRAVE_INSTALLER_EXE" arguments="INSTALL_SWITCH" needsadmin="true"/>
</actions>
</manifest>
</updatecheck>
</app>
</response>
4 changes: 2 additions & 2 deletions omaha/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# REMEMBER TO INCREMENT BUILD BY TWO! BUILD SHOULD ALWAYS BE ODD!
version_major = 1 # 1-65535
version_minor = 3 # 0-65535
version_build = 99 # 1-65535
version_patch = 0 # 0-65535
version_build = 361 # 1-65535
version_patch = 149 # 0-65535
12 changes: 6 additions & 6 deletions omaha/base/const_addresses.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,30 @@ const TCHAR* const kGoopdateServer = _T("tools.") COMPANY_DOMAIN;
// The channel for update checks is secured by using CUP to sign the messages.
// It does not depend solely on https security in any case.
const TCHAR* const kUrlUpdateCheck =
_T("https://update.") COMPANY_DOMAIN_BASE _T("apis.com/service/update2");
_T("https://updates.bravesoftware.com/service/update2");

// Pings.
const TCHAR* const kUrlPing =
_T("https://update.") COMPANY_DOMAIN_BASE _T("apis.com/service/update2");
_T("https://updates.bravesoftware.com/service/update2");

// The urls below never fall back to http.
//
// Crash reports.
const TCHAR* const kUrlCrashReport =
_T("https://clients2.") COMPANY_DOMAIN _T("/cr/report");
_T("https://updates.bravesoftware.com/cr/report");

// More information url.
// Must allow query parameters to be appended to it.
const TCHAR* const kUrlMoreInfo =
_T("https://www.") COMPANY_DOMAIN _T("/support/installer/?");
_T("https://updates.bravesoftware.com/support/installer/?");

// Code Red check url.
const TCHAR* const kUrlCodeRedCheck =
_T("https://clients2.") COMPANY_DOMAIN _T("/service/check2?crx3=true");
_T("https://updates.bravesoftware.com/service/check2");

// Usage stats url.
const TCHAR* const kUrlUsageStatsReport =
_T("https://clients5.") COMPANY_DOMAIN _T("/tbproxy/usagestats");
_T("https://updates.bravesoftware.com/tbproxy/usagestats");

// App logo.
const TCHAR* const kUrlAppLogo =
Expand Down
Loading

0 comments on commit 2c273a9

Please sign in to comment.