-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate omaha to brave_core #10
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "third_party/googletest"] | ||
path = third_party/googletest | ||
url = https://github.com/google/googletest.git | ||
[submodule "third_party/breakpad"] | ||
path = third_party/breakpad | ||
url = https://chromium.googlesource.com/breakpad/breakpad |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# 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", | ||
"--standalone_installer_exe=$brave_standalone_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", | ||
] | ||
|
||
outputs = [ | ||
"$root_out_dir/$brave_stub_installer_exe", | ||
"$root_out_dir/$brave_standalone_installer_exe", | ||
] | ||
|
||
deps = [ | ||
"//brave/build/win:create_signed_installer", | ||
] | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# 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 | ||
|
||
# https://stackoverflow.com/a/33856172 | ||
import ctypes | ||
|
||
def run_as_admin(argv=None, debug=False): | ||
shell32 = ctypes.windll.shell32 | ||
if argv is None and shell32.IsUserAnAdmin(): | ||
return True | ||
|
||
if argv is None: | ||
argv = sys.argv | ||
if hasattr(sys, '_MEIPASS'): | ||
# Support pyinstaller wrapped program. | ||
arguments = map(unicode, argv[1:]) | ||
else: | ||
arguments = map(unicode, argv) | ||
argument_line = u' '.join(arguments) | ||
executable = unicode(sys.executable) | ||
if debug: | ||
print 'Command line: ', executable, argument_line | ||
ret = shell32.ShellExecuteW(None, u"runas", executable, argument_line, None, 1) | ||
if int(ret) <= 32: | ||
return False | ||
return None | ||
|
||
def Build(args, omaha_dir): | ||
os.chdir(omaha_dir) | ||
|
||
command = ['git', 'submodule', 'update', '--init'] | ||
sp.check_call(command, stderr=sp.STDOUT) | ||
|
||
# move to omaha/omaha and start build. | ||
os.chdir(os.path.join(omaha_dir, 'omaha')) | ||
command = ['hammer-brave.bat', 'MODE=all', '--all'] | ||
sp.check_call(command, stderr=sp.STDOUT) | ||
|
||
def PrepareStandalone(args, omaha_dir): | ||
# copy brave installer to staing folder to create standalond installer. | ||
installer_file = os.path.join(args.root_out_dir[0], args.brave_installer_exe[0]) | ||
shutil.copyfile(installer_file, os.path.join(omaha_dir, 'omaha', 'scons-out', 'opt-win', 'staging', args.brave_installer_exe[0])) | ||
shutil.copyfile(installer_file, os.path.join(omaha_dir, 'omaha', 'scons-out', 'dbg-win', 'staging', args.brave_installer_exe[0])) | ||
|
||
# prepare manifset file. | ||
f = open(os.path.join(omaha_dir, 'manifest_template.gup'),'r') | ||
filedata = f.read() | ||
f.close() | ||
|
||
newdata = filedata.replace("APP_GUID", args.guid[0]) | ||
newdata = newdata.replace("BRAVE_INSTALLER_EXE", args.brave_installer_exe[0]) | ||
newdata = newdata.replace("INSTALL_SWITCH", args.install_switch[0]) | ||
|
||
target_manifest_file = args.guid[0] + '.gup' | ||
target_manifest_path = os.path.join(omaha_dir, 'omaha', 'standalone', 'manifests', target_manifest_file) | ||
f = open(target_manifest_path,'w') | ||
f.write(newdata) | ||
f.close() | ||
|
||
# update standalone_installers.txt. | ||
installer_text = "('STANDALONE_FILE_NAME', 'STANDALONE_FILE_NAME', [('BRAVE_VERSION', '$STAGING_DIR/BRAVE_INSTALLER_EXE', 'APP_GUID')], None, None, None, False, '', '')" | ||
installer_text = installer_text.replace("APP_GUID", args.guid[0]) | ||
installer_text = installer_text.replace("STANDALONE_FILE_NAME", os.path.splitext(args.standalone_installer_exe[0])[0]) | ||
installer_text = installer_text.replace("BRAVE_INSTALLER_EXE", args.brave_installer_exe[0]) | ||
installer_text = installer_text.replace("BRAVE_VERSION", args.brave_full_version[0]) | ||
|
||
target_installer_text_path = os.path.join(omaha_dir, 'omaha', 'standalone', 'standalone_installers.txt') | ||
f = open(target_installer_text_path,'w') | ||
f.write(installer_text) | ||
f.close() | ||
|
||
def Tagging(args, omaha_dir, debug): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I made some changes after reviewing.
|
||
last_win_dir = 'opt-win' | ||
if debug: | ||
last_win_dir = 'dbg-win' | ||
omaha_out_dir = os.path.join(omaha_dir, 'omaha', 'scons-out', last_win_dir) | ||
apply_tag_exe = os.path.join(omaha_out_dir, 'obj', 'tools', 'ApplyTag', 'ApplyTag.exe') | ||
|
||
tag = 'appguid=APP_GUID&appname=TAG_APP_NAME&needsadmin=prefers&lang=en&ap=TAG_AP' | ||
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]) | ||
|
||
source_standalone_installer = os.path.join(omaha_out_dir, 'Test_Installers', 'UNOFFICIAL_' + args.standalone_installer_exe[0]) | ||
target_standalone_installer_file = args.standalone_installer_exe[0] | ||
if debug: | ||
target_standalone_installer_file = 'Debug' + target_standalone_installer_file | ||
target_standalone_installer = os.path.join(args.root_out_dir[0], target_standalone_installer_file) | ||
command = [apply_tag_exe, source_standalone_installer, target_standalone_installer, tag] | ||
sp.check_call(command, stderr=sp.STDOUT) | ||
|
||
source_stub_installer = os.path.join(omaha_out_dir, 'staging', 'BraveUpdateSetup.exe') | ||
target_stub_installer_file = args.stub_installer_exe[0] | ||
if debug: | ||
target_stub_installer_file = 'Debug' + target_stub_installer_file | ||
target_stub_installer = os.path.join(args.root_out_dir[0], target_stub_installer_file) | ||
command = [apply_tag_exe, source_stub_installer, target_stub_installer, tag] | ||
sp.check_call(command, stderr=sp.STDOUT) | ||
return | ||
|
||
def ParseArgs(): | ||
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('--standalone_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) | ||
return parser.parse_args() | ||
|
||
# Wait to see ths compile logs. If not, elevated python program will quit w/o | ||
# any notice. | ||
def WaitFromUser(): | ||
raw_input('\nPress ENTER to exit.') | ||
|
||
def Main(args): | ||
ret = run_as_admin() | ||
if ret is True: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code runs in a separate admin process. |
||
print 'I have admin privilege.' | ||
args = ParseArgs() | ||
omaha_dir = os.path.join(args.root_out_dir[0], '..', '..', 'brave', 'vendor', 'omaha') | ||
|
||
# To build standalone installer, brave_installer should be copied into | ||
# scons-out/. However, this folder is created during the build. | ||
# Because of this scons-out folder isn't existed at first. | ||
# So, Build all except brave stub/standalone installer first, then copy | ||
# them. And build again finally to make standalone installer. | ||
# Second build only makes standalone. So, this isn't same build with first | ||
# build. | ||
Build(args, omaha_dir) | ||
PrepareStandalone(args, omaha_dir) | ||
Build(args, omaha_dir) | ||
# Create both(debug/release) executables | ||
Tagging(args, omaha_dir, True) | ||
Tagging(args, omaha_dir, False) | ||
|
||
WaitFromUser() | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(Main(sys.argv)) |
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}/"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wasn't sure if the "foo" here was intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found that this When standalone installer is used, installer exe file is already located in local machine's folder. So, this |
||
</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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
certificate related commands should be added here. @mbacchi