From d4224406b888c87db9ac081742644f24291deaa5 Mon Sep 17 00:00:00 2001 From: Ryan Volz Date: Thu, 24 Feb 2022 14:55:59 -0500 Subject: [PATCH] Patch NSIS installer script on Windows. 1. Never clear the full pkg dir 2. Delete environment variables set in registry by PothosSDR --- build_installer.py | 13 ++++++ buildenv.yaml | 1 + rerender.py | 2 + ...tomize-Windows-NSIS-installer-script.patch | 41 +++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 static/0001-Customize-Windows-NSIS-installer-script.patch diff --git a/build_installer.py b/build_installer.py index ec44993..062a323 100755 --- a/build_installer.py +++ b/build_installer.py @@ -70,6 +70,19 @@ if __name__ == "__main__": platform = spec_dir_extract_platform(args.installer_spec_dir) + if platform.startswith("win"): + # patch constructor's nsis template + import patch + + pset = patch.fromfile( + "static/0001-Customize-Windows-NSIS-installer-script.patch" + ) + pset.write_hunks( + pathlib.Path(constructor_main.__file__).parent / "nsis" / "main.nsi.tmpl", + args.installer_spec_dir / "main.nsi.tmpl", + pset.items[0].hunks, + ) + args.output_dir.mkdir(parents=True, exist_ok=True) constructor_cmdline = [ diff --git a/buildenv.yaml b/buildenv.yaml index 399b0c9..b0bee53 100644 --- a/buildenv.yaml +++ b/buildenv.yaml @@ -5,3 +5,4 @@ dependencies: - anaconda-client - conda-build - constructor + - python-patch diff --git a/rerender.py b/rerender.py index bf00c98..71470d7 100755 --- a/rerender.py +++ b/rerender.py @@ -109,6 +109,8 @@ def render_constructor( ) if platform.startswith("win"): construct_dict["post_install"] = "post_install.bat" + # point to template that we generate at build time with a patch over default + construct_dict["nsis_template"] = "main.nsi.tmpl" else: construct_dict["post_install"] = "post_install.sh" diff --git a/static/0001-Customize-Windows-NSIS-installer-script.patch b/static/0001-Customize-Windows-NSIS-installer-script.patch new file mode 100644 index 0000000..7db6307 --- /dev/null +++ b/static/0001-Customize-Windows-NSIS-installer-script.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ryan Volz +Date: Wed, 23 Feb 2022 18:11:22 -0500 +Subject: [PATCH] Customize Windows NSIS installer script. + +1. Never clear the full pkg dir +2. Delete environment variables set in registry by PothosSDR +--- + constructor/nsis/main.nsi.tmpl | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/constructor/nsis/main.nsi.tmpl b/constructor/nsis/main.nsi.tmpl +index 2426248..9ea05cf 100644 +--- a/constructor/nsis/main.nsi.tmpl ++++ b/constructor/nsis/main.nsi.tmpl +@@ -933,7 +933,7 @@ Section "Install" + + ${If} $Ana_ClearPkgCache_State = ${BST_CHECKED} + DetailPrint "Clearing package cache..." +- push '"$INSTDIR\_conda.exe" clean --all --force-pkgs-dirs --yes' ++ push '"$INSTDIR\_conda.exe" clean --all --yes' + push 'Failed to clear package cache' + call AbortRetryNSExecWait + ${EndIf} +@@ -964,6 +964,13 @@ Section "Install" + ${EndIf} + + ${If} $ARGV_NoRegistry == "0" ++ # Delete registry entries for environment variables set by PothosSDR ++ DeleteRegValue HKEY_LOCAL_MACHINE "System\CurrentControlSet\Control\Session Manager\Environment" "GR_PREFIX" ++ DeleteRegValue HKEY_LOCAL_MACHINE "System\CurrentControlSet\Control\Session Manager\Environment" "GRC_BLOCKS_PATH" ++ DeleteRegValue HKEY_LOCAL_MACHINE "System\CurrentControlSet\Control\Session Manager\Environment" "UHD_PKG_PATH" ++ DeleteRegValue HKEY_LOCAL_MACHINE "System\CurrentControlSet\Control\Session Manager\Environment" "VOLK_PREFIX" ++ ClearErrors ++ + # Registry uninstall info + WriteRegStr SHCTX "${UNINSTREG}" "DisplayName" "${UNINSTALL_NAME}" + WriteRegStr SHCTX "${UNINSTREG}" "DisplayVersion" "${VERSION}" +-- +2.35.0 +