From 74e4960fef4b250de7ce0679db524325e4754a05 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 19 Jul 2023 15:27:14 +0200 Subject: [PATCH 1/5] only insert custom_conclusion if the file ends in .nsi --- constructor/nsis/main.nsi.tmpl | 5 ++++- constructor/winexe.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/constructor/nsis/main.nsi.tmpl b/constructor/nsis/main.nsi.tmpl index a0e11b3b..c4897dac 100644 --- a/constructor/nsis/main.nsi.tmpl +++ b/constructor/nsis/main.nsi.tmpl @@ -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 diff --git a/constructor/winexe.py b/constructor/winexe.py index 826243af..2ef01091 100644 --- a/constructor/winexe.py +++ b/constructor/winexe.py @@ -323,9 +323,9 @@ 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) From be73b7a1cd5e572b5cb825e52795f74d0ccd306d Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 19 Jul 2023 15:32:16 +0200 Subject: [PATCH 2/5] pre-commit --- constructor/winexe.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/constructor/winexe.py b/constructor/winexe.py index 2ef01091..4a0f3905 100644 --- a/constructor/winexe.py +++ b/constructor/winexe.py @@ -323,8 +323,18 @@ 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', '')) if ppd['custom_welcome'] else ''), - ('@CUSTOM_CONCLUSION_FILE@', custom_nsi_insert_from_file(info.get('conclusion_file', '')) if ppd['custom_conclusion'] else ''), + ( + '@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) From 4fc8e1e907f5d4bf1e05628ec8f5afbdb628a581 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 19 Jul 2023 15:34:37 +0200 Subject: [PATCH 3/5] add news --- news/701-conclusion-file-windows | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 news/701-conclusion-file-windows diff --git a/news/701-conclusion-file-windows b/news/701-conclusion-file-windows new file mode 100644 index 00000000..7c2ebc1e --- /dev/null +++ b/news/701-conclusion-file-windows @@ -0,0 +1,19 @@ +### Enhancements + +* + +### 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 + +* + +### Docs + +* + +### Other + +* From 79878b67dbac9b03524ba8cd0c4c02550f01194d Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 19 Jul 2023 17:18:19 +0200 Subject: [PATCH 4/5] warn when ignored --- constructor/winexe.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/constructor/winexe.py b/constructor/winexe.py index 4a0f3905..bf502da3 100644 --- a/constructor/winexe.py +++ b/constructor/winexe.py @@ -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 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:]) From 557a863f2cb9b9959e442114e4940f0c15ac4811 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 20 Jul 2023 19:31:03 +0200 Subject: [PATCH 5/5] Update constructor/winexe.py Co-authored-by: Marco Esters --- constructor/winexe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/constructor/winexe.py b/constructor/winexe.py index bf502da3..345378ce 100644 --- a/constructor/winexe.py +++ b/constructor/winexe.py @@ -276,7 +276,7 @@ def make_nsi(info, dir_path, extra_files=None, temp_extra_files=None): for key in ['welcome_file', 'conclusion_file']: value = info.get(key, "") - if not value.endswith(".nsi"): + if value and not value.endswith(".nsi"): logger.warning( "On Windows, %s must be a .nsi file; %s will be ignored.", key,