Update NSIS patch to override PothosSDR-set variables in "Just Me" mode.

This commit is contained in:
Ryan Volz 2022-02-28 22:58:23 -05:00
parent 1d8efe4f6f
commit 3c748f55ca

View File

@ -7,11 +7,11 @@ Subject: [PATCH] Customize Windows NSIS installer script.
2. Delete environment variables set in registry by PothosSDR 2. Delete environment variables set in registry by PothosSDR
3. Do not show "advanced" installation options 3. Do not show "advanced" installation options
--- ---
constructor/nsis/main.nsi.tmpl | 11 +++++++++-- constructor/nsis/main.nsi.tmpl | 33 +++++++++++++++++++++++++++++++--
1 file changed, 9 insertions(+), 2 deletions(-) 1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/constructor/nsis/main.nsi.tmpl b/constructor/nsis/main.nsi.tmpl diff --git a/constructor/nsis/main.nsi.tmpl b/constructor/nsis/main.nsi.tmpl
index 2426248..a7b6f1d 100644 index 2426248..95c94c2 100644
--- a/constructor/nsis/main.nsi.tmpl --- a/constructor/nsis/main.nsi.tmpl
+++ b/constructor/nsis/main.nsi.tmpl +++ b/constructor/nsis/main.nsi.tmpl
@@ -118,7 +118,7 @@ Page Custom InstModePage_Create InstModePage_Leave @@ -118,7 +118,7 @@ Page Custom InstModePage_Create InstModePage_Leave
@ -32,20 +32,49 @@ index 2426248..a7b6f1d 100644
push 'Failed to clear package cache' push 'Failed to clear package cache'
call AbortRetryNSExecWait call AbortRetryNSExecWait
${EndIf} ${EndIf}
@@ -964,6 +964,13 @@ Section "Install" @@ -964,6 +964,26 @@ Section "Install"
${EndIf} ${EndIf}
${If} $ARGV_NoRegistry == "0" ${If} $ARGV_NoRegistry == "0"
+ # Delete registry entries for environment variables set by PothosSDR + # Delete registry entries for environment variables set by PothosSDR
+ DeleteRegValue HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "GR_PREFIX" + # With admin rights, we can delete them
+ DeleteRegValue HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "GRC_BLOCKS_PATH" + ${If} ${UAC_IsAdmin}
+ DeleteRegValue HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "UHD_PKG_PATH" + DetailPrint "Deleting PothosSDR registry environment variables..."
+ DeleteRegValue HKEY_LOCAL_MACHINE "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "VOLK_PREFIX" + !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
+ #ClearErrors + DeleteRegValue ${env_hklm} "GR_PREFIX"
+ DeleteRegValue ${env_hklm} "GRC_BLOCKS_PATH"
+ DeleteRegValue ${env_hklm} "UHD_PKG_PATH"
+ DeleteRegValue ${env_hklm} "VOLK_PREFIX"
+ # Without admin rights, we have to shadow them with empty values set for the user
+ ${Else}
+ DetailPrint "Overriding PothosSDR registry environment variables for user..."
+ !define env_hkcu 'HKCU "Environment"'
+ WriteRegExpandStr ${env_hkcu} "GR_PREFIX" ""
+ WriteRegExpandStr ${env_hkcu} "GRC_BLOCKS_PATH" ""
+ WriteRegExpandStr ${env_hkcu} "UHD_PKG_PATH" ""
+ WriteRegExpandStr ${env_hkcu} "VOLK_PREFIX" ""
+ ${EndIf}
+ SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
+ +
# Registry uninstall info # Registry uninstall info
WriteRegStr SHCTX "${UNINSTREG}" "DisplayName" "${UNINSTALL_NAME}" WriteRegStr SHCTX "${UNINSTREG}" "DisplayName" "${UNINSTALL_NAME}"
WriteRegStr SHCTX "${UNINSTREG}" "DisplayVersion" "${VERSION}" WriteRegStr SHCTX "${UNINSTREG}" "DisplayVersion" "${VERSION}"
@@ -1014,6 +1034,15 @@ Section "Uninstall"
# In case the last command fails, run the slow method to remove leftover
RMDir /r /REBOOTOK "$INSTDIR"
+ # Delete user environment variables that we set during installation
+ ${IfNot} ${UAC_IsAdmin}
+ DeleteRegValue ${env_hkcu} "GR_PREFIX"
+ DeleteRegValue ${env_hkcu} "GRC_BLOCKS_PATH"
+ DeleteRegValue ${env_hkcu} "UHD_PKG_PATH"
+ DeleteRegValue ${env_hkcu} "VOLK_PREFIX"
+ SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
+ ${EndIf}
+
DeleteRegKey SHCTX "${UNINSTREG}"
# If Anaconda was registered as the official Python for this version,
# remove it from the registry
-- --
2.35.0 2.35.0