Add winget import support

This commit is contained in:
2Shirt 2023-06-25 02:22:04 -07:00
parent 9980dab27b
commit 3ff61e9948
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
4 changed files with 85 additions and 8 deletions

View file

@ -25,14 +25,6 @@ SOURCES = {
'Software Bundle': 'https://ninite.com/.net4.8-7zip-chrome-edge-vlc/ninite.exe',
'TDSSKiller': 'https://media.kaspersky.com/utilities/VirusUtilities/EN/tdsskiller.exe',
# Visual C++ Runtimes: https://docs.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist
'VCRedist_2012_x32': 'https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x86.exe',
'VCRedist_2012_x64': 'https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe',
'VCRedist_2013_x32': 'https://aka.ms/highdpimfc2013x86enu',
'VCRedist_2013_x64': 'https://aka.ms/highdpimfc2013x64enu',
'VCRedist_2022_x32': 'https://aka.ms/vs/17/release/vc_redist.x86.exe',
'VCRedist_2022_x64': 'https://aka.ms/vs/17/release/vc_redist.x64.exe',
# Build Kit
'AIDA64': 'https://download.aida64.com/aida64engineer675.zip',
'Adobe Reader DC': 'https://ardownload2.adobe.com/pub/adobe/reader/win/AcrobatDC/2200220191/AcroRdrDC2200220191_en_US.exe',

View file

@ -0,0 +1,32 @@
{
"$schema": "https://aka.ms/winget-packages.schema.2.0.json",
"CreationDate": "2023-06-25T01:40:45.003-00:00",
"Sources": [
{
"Packages": [
{
"PackageIdentifier": "7zip.7zip"
},
{
"PackageIdentifier": "Google.Chrome"
},
{
"PackageIdentifier": "Microsoft.Edge"
},
{
"PackageIdentifier": "Mozilla.Firefox"
},
{
"PackageIdentifier": "VideoLAN.VLC"
}
],
"SourceDetails": {
"Argument": "https://cdn.winget.microsoft.com/cache",
"Identifier": "Microsoft.Winget.Source_8wekyb3d8bbwe",
"Name": "winget",
"Type": "Microsoft.PreIndexed.Package"
}
}
],
"WinGetVersion": "1.4.11071"
}

View file

@ -0,0 +1,29 @@
{
"$schema": "https://aka.ms/winget-packages.schema.2.0.json",
"CreationDate": "2023-06-25T01:40:45.003-00:00",
"Sources": [
{
"Packages": [
{
"PackageIdentifier": "Microsoft.VCRedist.2013.x64"
},
{
"PackageIdentifier": "Microsoft.VCRedist.2013.x86"
},
{
"PackageIdentifier": "Microsoft.VCRedist.2015+.x64"
},
{
"PackageIdentifier": "Microsoft.VCRedist.2015+.x86"
}
],
"SourceDetails": {
"Argument": "https://cdn.winget.microsoft.com/cache",
"Identifier": "Microsoft.Winget.Source_8wekyb3d8bbwe",
"Name": "winget",
"Type": "Microsoft.PreIndexed.Package"
}
}
],
"WinGetVersion": "1.4.11071"
}

View file

@ -762,6 +762,30 @@ def winget_check(raise_exceptions: bool = False) -> None:
raise GenericError('Failed to install')
def winget_import(group_name: str = 'default', upgrade: bool = False) -> None:
"""Use winget to import a set of applications.
group_name should be the name of a JSON file exported from winget.
NOTE: The path is relative to .bin/Scripts/wk/cfg/winget/
"""
cmd = [
'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:
with open(tmp_file, 'w', encoding='utf-8') as _f:
_f.write('@echo off\n')
_f.write(" ".join(cmd))
cmd = ('cmd', '/c', tmp_file, '-new_console:n', '-new_console:s33V')
run_program(cmd, check=False, pipe=False)
sleep(1)
wait_for_procs('winget.exe')
def winget_upgrade() -> None:
"""Upgrade all supported programs with winget, returns subprocess.Popen."""
cmd = ['winget', 'upgrade', '--all']