From 31217b5b29a7d13b195cb218cb19030420727ff0 Mon Sep 17 00:00:00 2001 From: Matt Bacchi Date: Tue, 27 Nov 2018 16:29:02 -0700 Subject: [PATCH] Create silent/untagged stub and standalone installers This is part of the work for issue: https://github.com/brave/brave-browser/issues/2210 --- BUILD.gn | 6 ++++ build_omaha.py | 77 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index db5283a0..6ddbe3c0 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -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", @@ -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 = [ diff --git a/build_omaha.py b/build_omaha.py index 4de0666c..f8d8cb17 100644 --- a/build_omaha.py +++ b/build_omaha.py @@ -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') @@ -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): @@ -74,8 +114,6 @@ 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) @@ -83,6 +121,12 @@ def Tagging(args, omaha_dir, debug): 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: @@ -91,6 +135,14 @@ 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: @@ -98,6 +150,14 @@ def Tagging(args, omaha_dir, debug): 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(): @@ -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', @@ -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