Skip to content
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

Create silent/untagged stub and standalone installers #16

Merged
merged 1 commit into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ action("build_omaha_installer") {
"--root_out_dir=$out_dir",
"--brave_installer_exe=$brave_installer_exe",
"--stub_installer_exe=$brave_stub_installer_exe",
"--stub_silent_exe=$brave_silent_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",
Expand All @@ -49,6 +53,8 @@ action("build_omaha_installer") {
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 = [
Expand Down
77 changes: 73 additions & 4 deletions build_omaha.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,34 @@ def Build(args, omaha_dir, build_all):

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

def Copy_Untagged_Installers(args, omaha_dir, debug):
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)

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 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 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 PrepareStandalone(args, omaha_dir):
# copy brave installer to create standalond installer.
# copy brave installer to create standalone 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', 'standalone', args.brave_installer_exe[0]))
shutil.copyfile(installer_file, os.path.join(omaha_dir, 'omaha', 'standalone', args.untagged_installer_exe[0]))
shutil.copyfile(installer_file, os.path.join(omaha_dir, 'omaha', 'standalone', args.silent_installer_exe[0]))

# prepare manifset file.
f = open(os.path.join(omaha_dir, 'manifest_template.gup'),'r')
Expand All @@ -62,9 +86,25 @@ def PrepareStandalone(args, omaha_dir):
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])

# add untagged installer info to standalone_installers.txt.
untagged_installer_text = "('UNTAGGED_FILE_NAME', 'UNTAGGED_FILE_NAME', [('BRAVE_VERSION', '$MAIN_DIR/standalone/UNTAGGED_INSTALLER_EXE', 'APP_GUID')], None, None, None, False, '', '')"
untagged_installer_text = untagged_installer_text.replace("APP_GUID", args.guid[0])
untagged_installer_text = untagged_installer_text.replace("UNTAGGED_FILE_NAME", os.path.splitext(args.untagged_installer_exe[0])[0])
untagged_installer_text = untagged_installer_text.replace("UNTAGGED_INSTALLER_EXE", args.untagged_installer_exe[0])
untagged_installer_text = untagged_installer_text.replace("BRAVE_VERSION", args.brave_full_version[0])

# add silent installer info to standalone_installers.txt.
silent_installer_text = "('SILENT_FILE_NAME', 'SILENT_FILE_NAME', [('BRAVE_VERSION', '$MAIN_DIR/standalone/SILENT_INSTALLER_EXE', 'APP_GUID')], None, None, None, False, '', '')"
silent_installer_text = silent_installer_text.replace("APP_GUID", args.guid[0])
silent_installer_text = silent_installer_text.replace("SILENT_FILE_NAME", os.path.splitext(args.silent_installer_exe[0])[0])
silent_installer_text = silent_installer_text.replace("SILENT_INSTALLER_EXE", args.silent_installer_exe[0])
silent_installer_text = silent_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.write(installer_text + '\n')
f.write(untagged_installer_text + '\n')
f.write(silent_installer_text)
f.close()

def Tagging(args, omaha_dir, debug):
Expand All @@ -74,15 +114,19 @@ def Tagging(args, omaha_dir, debug):
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')

# the needsadmin flag defaults to 'prefers', which should be used for normal installers,
# only the migration installer for browser-laptop to brave-core should use 'False'
tag_admin = os.environ.get('TAG_ADMIN', 'prefers')
tag = 'appguid=APP_GUID&appname=TAG_APP_NAME&needsadmin=TAG_ADMIN&lang=en&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])

silent_tag = 'appguid=APP_GUID&appname=TAG_APP_NAME&needsadmin=TAG_ADMIN&lang=en&ap=TAG_AP'
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])

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:
Expand All @@ -91,13 +135,29 @@ def Tagging(args, omaha_dir, debug):
command = [apply_tag_exe, source_standalone_installer, target_standalone_installer, tag]
sp.check_call(command, stderr=sp.STDOUT)

source_silent_installer = os.path.join(omaha_out_dir, 'Test_Installers', 'UNOFFICIAL_' + args.silent_installer_exe[0])
target_silent_installer_file = args.silent_installer_exe[0]
if debug:
target_silent_installer_file = 'Debug' + target_silent_installer_file
target_silent_installer = os.path.join(args.root_out_dir[0], target_silent_installer_file)
command = [apply_tag_exe, source_silent_installer, target_silent_installer, silent_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)

source_silent_stub_installer = os.path.join(omaha_out_dir, 'staging', 'BraveUpdateSetup.exe')
target_silent_stub_installer_file = args.stub_silent_exe[0]
if debug:
target_silent_stub_installer_file = 'Debug' + target_silent_stub_installer_file
target_silent_stub_installer = os.path.join(args.root_out_dir[0], target_silent_stub_installer_file)
command = [apply_tag_exe, source_silent_stub_installer, target_silent_stub_installer, silent_tag]
sp.check_call(command, stderr=sp.STDOUT)
return

def ParseArgs():
Expand All @@ -108,8 +168,16 @@ def ParseArgs():
nargs=1)
parser.add_argument('--stub_installer_exe',
nargs=1)
parser.add_argument('--stub_untagged_exe',
nargs=1)
parser.add_argument('--stub_silent_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',
Expand All @@ -130,6 +198,7 @@ def Main(args):
PrepareStandalone(args, omaha_dir)
Build(args, omaha_dir, False)
Tagging(args, omaha_dir, False)
Copy_Untagged_Installers(args, omaha_dir, False)

return 0

Expand Down