Skip to content

Commit

Permalink
only insert custom_conclusion if the file ends in .nsi (#701)
Browse files Browse the repository at this point in the history
* only insert custom_conclusion if the file ends in .nsi

* pre-commit

* add news

* warn when ignored

* Update constructor/winexe.py

Co-authored-by: Marco Esters <[email protected]>

---------

Co-authored-by: Marco Esters <[email protected]>
  • Loading branch information
jaimergp and marcoesters authored Jul 24, 2023
1 parent e1c0861 commit 9c16ce1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
5 changes: 4 additions & 1 deletion constructor/nsis/main.nsi.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,13 @@ Page Custom mui_AnaCustomOptions_Show
!define MUI_FINISHPAGE_TEXT __CONCLUSION_TEXT__
#endif

#if custom_conclusion
# Custom conclusion file(s)
@CUSTOM_CONCLUSION_FILE@

#else
!insertmacro MUI_PAGE_FINISH
#endif


!insertmacro MUI_UNPAGE_WELCOME
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.OnDirectoryLeave
Expand Down
25 changes: 22 additions & 3 deletions constructor/winexe.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@ def make_nsi(info, dir_path, extra_files=None, temp_extra_files=None):
# for the newlines business
replace['CONCLUSION_TEXT'] = "\r\n".join(conclusion_lines[1:])

for key in ['welcome_file', 'conclusion_file']:
value = info.get(key, "")
if value and not value.endswith(".nsi"):
logger.warning(
"On Windows, %s must be a .nsi file; %s will be ignored.",
key,
value,
)

for key, value in replace.items():
if value.startswith('@'):
value = join(dir_path, value[1:])
Expand Down Expand Up @@ -323,9 +332,19 @@ def make_nsi(info, dir_path, extra_files=None, temp_extra_files=None):
'${NAME} ${VERSION} (Python ${PYVERSION} ${ARCH})'
)),
('@EXTRA_FILES@', '\n '.join(extra_files_commands(extra_files, dir_path))),
('@CUSTOM_WELCOME_FILE@', custom_nsi_insert_from_file(info.get('welcome_file', ''))),
('@CUSTOM_CONCLUSION_FILE@', custom_nsi_insert_from_file(info.get('conclusion_file', ''))),
('@TEMP_EXTRA_FILES@', '\n '.join(insert_tempfiles_commands(temp_extra_files)))
(
'@CUSTOM_WELCOME_FILE@',
custom_nsi_insert_from_file(info.get('welcome_file', ''))
if ppd['custom_welcome']
else ''
),
(
'@CUSTOM_CONCLUSION_FILE@',
custom_nsi_insert_from_file(info.get('conclusion_file', ''))
if ppd['custom_conclusion']
else ''
),
('@TEMP_EXTRA_FILES@', '\n '.join(insert_tempfiles_commands(temp_extra_files))),
]:
data = data.replace(key, value)

Expand Down
19 changes: 19 additions & 0 deletions news/701-conclusion-file-windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* On Windows installers, only insert `conclusion_file` if the extension is `.nsi`. Ignore otherwise. Also prevents a double final page. (#700 via #701)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>

0 comments on commit 9c16ce1

Please sign in to comment.