Switch to winget where appropriate in Auto Setup
NOTE: Winget is not used for Firefox, LibreOffice, or Open Shell. This was done because we need more fine-tuned control of the process.
This commit is contained in:
parent
3ff61e9948
commit
cafa2c24fb
3 changed files with 19 additions and 48 deletions
|
|
@ -33,11 +33,13 @@ BASE_MENUS = {
|
|||
MenuEntry('Set Custom Power Plan', 'auto_set_custom_power_plan'),
|
||||
),
|
||||
'Install Software': (
|
||||
MenuEntry('Visual C++ Runtimes', 'auto_install_vcredists'),
|
||||
MenuEntry('Winget', 'auto_install_winget'),
|
||||
MenuEntry('Firefox', 'auto_install_firefox'),
|
||||
MenuEntry('LibreOffice', 'auto_install_libreoffice', selected=False),
|
||||
MenuEntry('Open Shell', 'auto_install_open_shell'),
|
||||
MenuEntry('Software Bundle', 'auto_install_software_bundle'),
|
||||
MenuEntry('Software Upgrades', 'auto_install_software_upgrades'),
|
||||
MenuEntry('Visual C++ Runtimes', 'auto_install_vcredists'),
|
||||
),
|
||||
'Configure System': (
|
||||
MenuEntry('Open Shell', 'auto_config_open_shell'),
|
||||
|
|
|
|||
|
|
@ -762,7 +762,7 @@ def winget_check(raise_exceptions: bool = False) -> None:
|
|||
raise GenericError('Failed to install')
|
||||
|
||||
|
||||
def winget_import(group_name: str = 'default', upgrade: bool = False) -> None:
|
||||
def winget_import(group_name: str = 'default') -> None:
|
||||
"""Use winget to import a set of applications.
|
||||
|
||||
group_name should be the name of a JSON file exported from winget.
|
||||
|
|
@ -773,7 +773,6 @@ def winget_import(group_name: str = 'default', upgrade: bool = False) -> None:
|
|||
'winget',
|
||||
'import', '--import-file',
|
||||
str(find_kit_dir('Scripts').joinpath(f'wk/cfg/winget/{group_name}.json')),
|
||||
'' if upgrade else '--no-upgrade',
|
||||
]
|
||||
tmp_file = fr'{os.environ.get("TMP")}\run_winget.cmd'
|
||||
if CONEMU:
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ from wk.exe import kill_procs, run_program, popen_program
|
|||
from wk.io import case_insensitive_path, get_path_obj
|
||||
from wk.kit.tools import (
|
||||
ARCH,
|
||||
download_tool,
|
||||
extract_archive,
|
||||
extract_tool,
|
||||
find_kit_dir,
|
||||
|
|
@ -47,6 +46,9 @@ from wk.os.win import (
|
|||
is_secure_boot_enabled,
|
||||
reg_set_value,
|
||||
reg_write_settings,
|
||||
winget_check,
|
||||
winget_import,
|
||||
winget_upgrade,
|
||||
)
|
||||
from wk.repairs.win import (
|
||||
WIDTH,
|
||||
|
|
@ -450,12 +452,22 @@ def auto_install_open_shell() -> None:
|
|||
|
||||
def auto_install_software_bundle() -> None:
|
||||
"""Install standard software bundle."""
|
||||
TRY_PRINT.run('Software Bundle...', install_software_bundle)
|
||||
TRY_PRINT.run('Software Bundle...', winget_import, group_name='default')
|
||||
|
||||
|
||||
def auto_install_software_upgrades() -> None:
|
||||
"""Upgrade all supported installed software."""
|
||||
TRY_PRINT.run('Software Upgrades...', winget_upgrade)
|
||||
|
||||
|
||||
def auto_install_vcredists() -> None:
|
||||
"""Install latest supported Visual C++ runtimes."""
|
||||
TRY_PRINT.run('Visual C++ Runtimes...', install_vcredists)
|
||||
TRY_PRINT.run('Visual C++ Runtimes...', winget_import, group_name='vcredists')
|
||||
|
||||
|
||||
def auto_install_winget() -> None:
|
||||
"""Install winget if needed."""
|
||||
TRY_PRINT.run('Winget...', winget_check, raise_exceptions=True)
|
||||
|
||||
|
||||
def auto_open_device_manager() -> None:
|
||||
|
|
@ -786,48 +798,6 @@ def install_open_shell() -> None:
|
|||
run_program(cmd)
|
||||
|
||||
|
||||
def install_software_bundle() -> None:
|
||||
"""Install standard software bundle."""
|
||||
download_tool('Ninite', 'Software Bundle')
|
||||
installer = get_tool_path('Ninite', 'Software Bundle')
|
||||
msg = 'Waiting for installations to finish...'
|
||||
warning = 'NOTE: Press CTRL+c to manually resume if it gets stuck...'
|
||||
|
||||
# Start installations and wait for them to finish
|
||||
ui.print_standard(msg)
|
||||
ui.print_warning(warning, end='', flush=True)
|
||||
proc = popen_program([installer])
|
||||
try:
|
||||
proc.wait()
|
||||
except KeyboardInterrupt:
|
||||
# Assuming user-forced continue
|
||||
pass
|
||||
|
||||
# Clear info lines
|
||||
print(
|
||||
'\r\033[0K' # Cursor to start of current line and clear to end of line
|
||||
'\033[F\033[54C' # Cursor to start of prev line and then move 54 right
|
||||
'\033[0K', # Clear from cursor to end of line
|
||||
end='', flush=True)
|
||||
|
||||
|
||||
def install_vcredists() -> None:
|
||||
"""Install latest supported Visual C++ runtimes."""
|
||||
for year in (2012, 2013, 2022):
|
||||
cmd_args = ['/install', '/passive', '/norestart']
|
||||
if year == 2012:
|
||||
cmd_args.pop(0)
|
||||
name = f'VCRedist_{year}_x32'
|
||||
download_tool('VCRedist', name)
|
||||
installer = get_tool_path('VCRedist', name)
|
||||
run_program([installer, *cmd_args])
|
||||
if ARCH == '64':
|
||||
name = f'{name[:-2]}64'
|
||||
download_tool('VCRedist', name)
|
||||
installer = get_tool_path('VCRedist', name)
|
||||
run_program([installer, *cmd_args])
|
||||
|
||||
|
||||
def uninstall_firefox() -> None:
|
||||
"""Uninstall all copies of Firefox."""
|
||||
json_file = format_log_path(log_name='Installed Programs', timestamp=True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue