diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2022-01-31 20:09:45 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2022-01-31 20:10:08 +0100 |
commit | 8c457dad4847c47cc9b1dc4afa5f5b200a27b195 (patch) | |
tree | d29ae5cb2618d769f92adba0d17444ea3c0c9268 /win | |
parent | 12cea0971381fa7404555d2e5ae598a4e59ee7df (diff) | |
download | mariadb-git-8c457dad4847c47cc9b1dc4afa5f5b200a27b195.tar.gz |
MDEV-27546 MSI should fail if INSTALLDIR is a non-empty existing directory
Make installer fail if INSTALLDIR exists.
In UI mode, show a popup and disable "Next" button until install root is
corrected
Diffstat (limited to 'win')
-rw-r--r-- | win/packaging/ca/CustomAction.cpp | 21 | ||||
-rw-r--r-- | win/packaging/ca/CustomAction.def | 1 | ||||
-rw-r--r-- | win/packaging/extra.wxs.in | 15 |
3 files changed, 36 insertions, 1 deletions
diff --git a/win/packaging/ca/CustomAction.cpp b/win/packaging/ca/CustomAction.cpp index cbef4d2ee41..328e73accb8 100644 --- a/win/packaging/ca/CustomAction.cpp +++ b/win/packaging/ca/CustomAction.cpp @@ -187,6 +187,27 @@ bool IsDirectoryEmptyOrNonExisting(const wchar_t *dir) { return empty; } +extern "C" UINT __stdcall CheckInstallDirectory(MSIHANDLE hInstall) +{ + HRESULT hr= S_OK; + UINT er= ERROR_SUCCESS; + wchar_t *path= 0; + + hr= WcaInitialize(hInstall, __FUNCTION__); + ExitOnFailure(hr, "Failed to initialize"); + WcaGetFormattedString(L"[INSTALLDIR]", &path); + if (!IsDirectoryEmptyOrNonExisting(path)) + { + wchar_t msg[2*MAX_PATH]; + swprintf(msg,countof(msg), L"Installation directory '%s' exists and is not empty. Choose a " + "different install directory",path); + WcaSetProperty(L"INSTALLDIRERROR", msg); + } +LExit: + ReleaseStr(path); + return WcaFinalize(er); +} + /* Check for valid data directory is empty during install A valid data directory is non-existing, or empty. diff --git a/win/packaging/ca/CustomAction.def b/win/packaging/ca/CustomAction.def index aed69cf7827..c18a0d92058 100644 --- a/win/packaging/ca/CustomAction.def +++ b/win/packaging/ca/CustomAction.def @@ -8,3 +8,4 @@ CheckDatabaseProperties CheckDataDirectory CheckDBInUse CheckServiceUpgrades +CheckInstallDirectory diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in index a6428313f24..8b06ea1c24d 100644 --- a/win/packaging/extra.wxs.in +++ b/win/packaging/extra.wxs.in @@ -346,6 +346,7 @@ <Property Id="CRLF" Value="
" /> <CustomAction Id="CheckDataDirectory" BinaryKey="wixca.dll" DllEntry="CheckDataDirectory" Execute="immediate" Impersonate="yes"/> + <CustomAction Id="CheckInstallDirectory" BinaryKey="wixca.dll" DllEntry="CheckInstallDirectory" Execute="immediate" Impersonate="yes"/> <!-- What to do when navigation buttons are clicked --> <UI Id="MyWixUI_Mondo"> <UIRef Id="WixUI_FeatureTree" /> @@ -365,6 +366,12 @@ <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="NewOrUpgradeInstanceDlg" Order="999"> NOT Installed AND UpgradableServiceFound </Publish> + <Publish Dialog="CustomizeDlg" Control="Next" Event="DoAction" Value="CheckInstallDirectory" Order="1">NOT Installed</Publish> + <Publish Dialog="CustomizeDlg" Control="Next" Property="WarningText" Order="2" + Value="[INSTALLDIRERROR]"> + INSTALLDIRERROR + </Publish> + <Publish Dialog="CustomizeDlg" Control="Next" Event="SpawnDialog" Value="WarningDlg" Order="3">WarningText</Publish> <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="ConfirmDataCleanupDlg" Order="4"> <![CDATA[(&DBInstance=2) AND (!DBInstance=3)]]> </Publish> @@ -645,11 +652,17 @@ <CustomAction Id='ErrorDataDir' Error='Invalid data directory, choose a different one. Error : [DATADIRERROR]'/> + <CustomAction Id="ErrorInstallDir" + Error="[INSTALLDIRERROR]" /> <InstallExecuteSequence> <Custom Action="CheckDataDirectory" After="CostFinalize"> <![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED=""]]> </Custom> - <Custom Action="ErrorDataDir" After="CheckDataDirectory">DATADIRERROR</Custom> + <Custom Action="ErrorDataDir" After="CheckDataDirectory">DATADIRERROR</Custom> + <Custom Action="CheckInstallDirectory" After="CostFinalize"> + NOT Installed + </Custom> + <Custom Action="ErrorInstallDir" After="CheckInstallDirectory">INSTALLDIRERROR</Custom> <Custom Action="CheckDatabaseProperties" Before="CreateDatabaseCommand">SERVICENAME</Custom> <Custom Action="CreateDatabaseCommand" After="CostFinalize" > <![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED=""]]> |