Skip to content

Commit 5812444

Browse files
committed
Add support for INSTALLER_EXE templates
This commit adds support for creating package templates of type INSTALLER_EXE to deal with the installers these are distributed as EXE files.
1 parent 77af1d5 commit 5812444

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

categories.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ Utilities
3131
Visual Basic
3232
Web Application
3333
Wordlists
34+
VB

scripts/utils/create_package_template.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@ def package_version(dependency_version):
118118
VM-Install-From-Zip $toolName $category $zipUrl -zipSha256 $zipSha256 -consoleApp ${console_app} -innerFolder ${inner_folder} -arguments $arguments
119119
"""
120120

121+
INSTALLER_EXE_TEMPLATE = r"""$ErrorActionPreference = 'Stop'
122+
Import-Module vm.common -Force -DisableNameChecking
123+
124+
$toolName = '{tool_name}'
125+
$category = VM-Get-Category($MyInvocation.MyCommand.Definition)
126+
127+
$exeUrl = '{target_url}'
128+
$exeSha256 = '{target_hash}'
129+
130+
$toolDir = Join-Path ${{Env:RAW_TOOLS_DIR}} $toolName
131+
$executablePath = (Join-Path $toolDir '{target_file}')
132+
VM-Install-With-Installer $toolName $category "EXE" "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /Dir=`"$($toolDir)`"" $executablePath $exeUrl -sha256 $exeSha256
133+
"""
134+
121135
"""
122136
Needs the following format strings:
123137
tool_name="...", category="..."
@@ -228,6 +242,17 @@ def package_version(dependency_version):
228242
VM-Uninstall $toolName $category
229243
"""
230244

245+
UNINSTALLER_EXE_TEMPLATE = r"""$ErrorActionPreference = 'Continue'
246+
Import-Module vm.common -Force -DisableNameChecking
247+
248+
$toolName = '{tool_name}'
249+
$category = VM-Get-Category($MyInvocation.MyCommand.Definition)
250+
251+
VM-Uninstall-With-Uninstaller $toolName $category "EXE" "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"
252+
253+
VM-Uninstall $toolName $category
254+
"""
255+
231256
"""
232257
Needs the following format strings:
233258
tool_name="...", category="..."
@@ -280,6 +305,23 @@ def create_zip_exe_template(packages_path, **kwargs):
280305
)
281306

282307

308+
def create_installer_exe_template(packages_path, **kwargs):
309+
create_template(
310+
INSTALLER_EXE_TEMPLATE,
311+
uninstall_template=UNINSTALLER_EXE_TEMPLATE,
312+
packages_path=packages_path,
313+
pkg_name=kwargs.get("pkg_name"),
314+
version=kwargs.get("version"),
315+
authors=kwargs.get("authors"),
316+
description=kwargs.get("description"),
317+
tool_name=kwargs.get("tool_name"),
318+
category=kwargs.get("category"),
319+
target_url=kwargs.get("target_url"),
320+
target_hash=kwargs.get("target_hash"),
321+
target_file=kwargs.get("target_file"),
322+
)
323+
324+
283325
def create_node_template(packages_path, **kwargs):
284326
create_template(
285327
NODE_TEMPLATE,
@@ -388,6 +430,7 @@ def create_template(
388430
category="",
389431
target_url="",
390432
target_hash="",
433+
target_file="",
391434
shim_path="",
392435
dependency="",
393436
console_app="",
@@ -427,6 +470,7 @@ def create_template(
427470
arguments=arguments,
428471
target_url=target_url,
429472
target_hash=target_hash,
473+
target_file=target_file,
430474
shim_path=shim_path,
431475
console_app=console_app,
432476
inner_folder=inner_folder,
@@ -476,6 +520,22 @@ def get_script_directory():
476520
"target_hash",
477521
],
478522
},
523+
"INSTALLER_EXE": {
524+
"cb": create_installer_exe_template,
525+
"doc": "An installer distributed as an EXE file",
526+
"example": "<url>/tool.exe",
527+
"arguments": [
528+
"pkg_name",
529+
"version",
530+
"authors",
531+
"description",
532+
"tool_name",
533+
"category",
534+
"target_url",
535+
"target_hash",
536+
"target_file",
537+
],
538+
},
479539
"NODE": {
480540
"cb": create_node_template,
481541
"doc": "An tool from the JavaScript Package Registry installed with npm",
@@ -627,6 +687,7 @@ def main(argv=None):
627687
parser.add_argument("--dependency", type=str, default="", help="Metapackage dependency")
628688
parser.add_argument("--target_url", type=str, default="", help="URL to target file (zip or executable)")
629689
parser.add_argument("--target_hash", type=str, default="", help="SHA256 hash of target file (zip or executable)")
690+
parser.add_argument("--target_file", type=str, default="", help="EXE name/path under the installed tool folder")
630691
parser.add_argument("--shim_path", type=str, default="", help="Metapackage shim path")
631692
parser.add_argument(
632693
"--console_app",

0 commit comments

Comments
 (0)