Skip to content

Commit c58b59c

Browse files
committed
Add --postinstall argument for running commands at the end of install.
Fix multiple startmenu shortcut generation.
1 parent fe1e5ca commit c58b59c

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# TODO: include package data (templates)
33
setup(
44
name='syrup',
5-
version='0.0.1',
5+
version='0.0.2',
66
packages=find_packages(),
77
package_data={
88
'': ['templates/*']

syrup/__main__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ def validate_version(ctx, param, value):
5151
@click.option('--artifact-dir', default="artifacts", type=click.Path(file_okay=False), help="Path to installer output directory.")
5252
@click.option('--src-dir', default="src", type=click.Path(file_okay=False, exists=True), help="Path to application files to create installer from.")
5353
@click.option('--executable', '-e', multiple=True, default=["*.exe"], help="Path of executables to create startmenu shortcuts to. Relative to src-dir. Can be passed multiple times. (default: *.exe)")
54+
@click.option('--postinstall', '-p', multiple=True, default=None, help="Commands to run post-install (at the end of installer)")
5455

5556
@click.option('--help-url', help="Help URL to display in 'Add/Remove Programs'. mailto: is allowed.")
5657
@click.option('--update-url', help="Update URL to display in 'Add/Remove Programs'. mailto: is allowed.")
5758
@click.option('--website-url', help="Website(about) URL to display in 'Add/Remove Programs'. mailto: is allowed.")
5859

5960
@click.pass_context
60-
def build(ctx, do_clean, version, name, company, description, license, icon, build_dir, artifact_dir, src_dir, clean_artifacts, help_url, update_url, website_url, executable):
61+
def build(ctx, do_clean, version, name, company, description, license, icon, build_dir, artifact_dir, src_dir, clean_artifacts, help_url, update_url, website_url, executable, postinstall):
6162
click.echo("Building {} v{}...".format(name, version))
6263
if do_clean:
6364
ctx.forward(clean)
@@ -78,6 +79,7 @@ def build(ctx, do_clean, version, name, company, description, license, icon, bui
7879
name=name, company=company,
7980
description=description,
8081
help_url=help_url, update_url=update_url, website_url=website_url,
82+
postinstall=postinstall,
8183
)
8284

8385
NSISBuildInstaller(nsi_script=nsi_script, artifact_dir=artifact_dir)

syrup/templates/generic.nsi.j2

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ section "install"
9191
# Start Menu
9292
createDirectory "$SMPROGRAMS\${COMPANYNAME}"
9393
{% for executable in executables %}
94-
{% if prev is undefined %}
94+
{% if loop.first %}
9595
{% if icon is defined and icon %}
9696
createShortCut "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk" "$INSTDIR\{{ executable }}" "" "$INSTDIR\{{ icon }}"
9797
{% else %}
@@ -135,6 +135,11 @@ section "install"
135135
# Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size
136136
WriteRegDWORD "${REG}" "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "EstimatedSize" ${INSTALLSIZE}
137137

138+
{% if postinstall is defined and postinstall %}
139+
{% for cmd in postinstall %}
140+
ExecDos::exec /DETAILED "{{ cmd }}"
141+
{% endfor %}
142+
{% endif %}
138143
sectionEnd
139144

140145
# Uninstaller

0 commit comments

Comments
 (0)