Major update for installing software bundles

* Initial versions of find_current_software() and find_missing_software()
  * Only covers browsers for now
* Expanded bundles for more fine-tuned installations
* Should fix failed installations in system_setup.py
This commit is contained in:
2Shirt 2019-05-10 18:49:59 -06:00
parent 70995f5dcf
commit f5f4c79326
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
3 changed files with 103 additions and 20 deletions

View file

@ -426,6 +426,12 @@ def list_homepages(indent=8, width=32):
indent=' '*indent, width=width, name=name, page=page))
def profile_present(browser_name):
"""Checks if a profile was detected for browser, returns bool."""
browser_name = browser_name.replace(' Chromium', '')
return bool(browser_data.get(browser_name, {}).get('profiles', False))
def reset_browsers(indent=8, width=32):
"""Reset all detected browsers to safe defaults."""
browser_list = [k for k, v in sorted(browser_data.items()) if v['profiles']]

View file

@ -158,6 +158,39 @@ def write_registry_settings(settings, all_users=False):
# Installations
def find_current_software():
"""Find currently installed software, returns list."""
ninite_extras_path = r'{BaseDir}\Installers\Extras'.format(**global_vars)
installers = []
# Browsers
scan_for_browsers(skip_ie=True, silent=True)
for browser in ('Google Chrome', 'Mozilla Firefox', 'Opera Chromium'):
if is_installed(browser):
installers.append(
r'{}\Web Browsers\{}.exe'.format(ninite_extras_path, browser))
# TODO Add more sections
return installers
def find_missing_software():
"""Find missing software based on dirs/files present, returns list."""
ninite_extras_path = r'{BaseDir}\Installers\Extras'.format(**global_vars)
installers = []
# Browsers
scan_for_browsers(skip_ie=True, silent=True)
for browser in ('Google Chrome', 'Mozilla Firefox', 'Opera Chromium'):
if profile_present(browser):
installers.append(
r'{}\Web Browsers\{}.exe'.format(ninite_extras_path, browser))
# TODO Add more sections
return installers
def install_adobe_reader():
"""Install Adobe Reader."""
cmd = [
@ -260,10 +293,19 @@ def install_libreoffice(
# Install LibreOffice
run_program(cmd, check=True)
def install_ninite_bundle(browsers_only=False, mse=False, libreoffice=False):
def install_ninite_bundle(
base=True,
browsers_only=False,
current=False,
libreoffice=False,
missing=False,
mse=False,
standard=True,
):
"""Run Ninite installer(s), returns list of Popen objects."""
popen_objects = []
if browsers_only:
# This option is deprecated
installer_path = r'{BaseDir}\Installers\Extras\Web Browsers'.format(
**global_vars)
scan_for_browsers(skip_ie=True, silent=True)
@ -271,26 +313,52 @@ def install_ninite_bundle(browsers_only=False, mse=False, libreoffice=False):
if is_installed(browser):
cmd = r'{}\{}.exe'.format(installer_path, browser)
popen_objects.append(popen_program(cmd))
elif global_vars['OS']['Version'] in ('8', '8.1', '10'):
# Modern selection
popen_objects.append(
popen_program(r'{BaseDir}\Installers\Extras\Bundles\Modern.exe'.format(
**global_vars)))
else:
# Legacy selection
if mse:
cmd = r'{BaseDir}\Installers\Extras\Security'.format(**global_vars)
cmd += r'\Microsoft Security Essentials.exe'
popen_objects.append(popen_program(cmd))
popen_objects.append(
popen_program(r'{BaseDir}\Installers\Extras\Bundles\Legacy.exe'.format(
**global_vars)))
# Bail
return popen_objects
# Main bundle
selections = []
if base:
selections.append('base')
if standard and not missing:
selections.append('browsers')
if standard:
if global_vars['OS']['Version'] in ('8', '8.1', '10'):
selections.append('standard')
else:
selections.append('standard7')
cmd = r'{}\Installers\Extras\Bundles\{}.exe'.format(
global_vars['BaseDir'],
'-'.join(selections),
)
popen_objects.append(popen_program([cmd]))
# Current
if current:
for cmd in find_current_software():
popen_objects.append(popen_program([cmd]))
# Missing
if missing:
for cmd in find_missing_software():
popen_objects.append(popen_program([cmd]))
# Microsoft Security Essentials
if mse:
cmd = r'{}\Installers\Extras\Security\{}'.format(
global_vars['BaseDir'],
'Microsoft Security Essentials.exe',
)
popen_objects.append(popen_program([cmd]))
# LibreOffice
if libreoffice:
cmd = r'{BaseDir}\Installers\Extras\Office'.format(**global_vars)
cmd += r'\LibreOffice.exe'
popen_objects.append(popen_program(cmd))
cmd = r'{}\Installers\Extras\Office\{}'.format(
global_vars['BaseDir'],
'LibreOffice.exe',
)
popen_objects.append(popen_program([cmd]))
# Done
return popen_objects

View file

@ -75,8 +75,17 @@ VCREDIST_SOURCES = {
}
NINITE_SOURCES = {
'Bundles': {
'Legacy.exe': '.net4.7.2-7zip-chrome-firefox-sumatrapdf-vlc',
'Modern.exe': '.net4.7.2-7zip-chrome-classicstart-firefox-sumatrapdf-vlc',
'base-browsers-standard.exe': '.net4.7.2-7zip-chrome-classicstart-firefox-sumatrapdf-vlc',
'base-browsers-standard7.exe': '.net4.7.2-7zip-chrome-firefox-sumatrapdf-vlc',
'base-browsers.exe': '.net4.7.2-7zip-chrome-firefox-vlc',
'base-standard.exe': '.net4.7.2-7zip-classicstart-sumatrapdf-vlc',
'base-standard7.exe': '.net4.7.2-7zip-sumatrapdf-vlc',
'base.exe': '.net4.7.2-7zip-vlc',
'browsers-standard.exe': 'chrome-classicstart-firefox-sumatrapdf',
'browsers-standard7.exe': 'chrome-firefox-sumatrapdf',
'browsers.exe': 'chrome-firefox',
'standard.exe': 'classicstart-sumatrapdf',
'standard7.exe': 'sumatrapdf',
},
'Audio-Video': {
'AIMP.exe': 'aimp',