mirror of
https://github.com/MariaDB/server.git
synced 2025-07-23 00:55:06 +00:00
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
This commit is contained in:
@ -187,6 +187,27 @@ bool IsDirectoryEmptyOrNonExisting(const wchar_t *dir) {
|
|||||||
return empty;
|
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
|
Check for valid data directory is empty during install
|
||||||
A valid data directory is non-existing, or empty.
|
A valid data directory is non-existing, or empty.
|
||||||
|
@ -8,3 +8,4 @@ CheckDatabaseProperties
|
|||||||
CheckDataDirectory
|
CheckDataDirectory
|
||||||
CheckDBInUse
|
CheckDBInUse
|
||||||
CheckServiceUpgrades
|
CheckServiceUpgrades
|
||||||
|
CheckInstallDirectory
|
||||||
|
@ -346,6 +346,7 @@
|
|||||||
|
|
||||||
<Property Id="CRLF" Value="
" />
|
<Property Id="CRLF" Value="
" />
|
||||||
<CustomAction Id="CheckDataDirectory" BinaryKey="wixca.dll" DllEntry="CheckDataDirectory" Execute="immediate" Impersonate="yes"/>
|
<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 -->
|
<!-- What to do when navigation buttons are clicked -->
|
||||||
<UI Id="MyWixUI_Mondo">
|
<UI Id="MyWixUI_Mondo">
|
||||||
<UIRef Id="WixUI_FeatureTree" />
|
<UIRef Id="WixUI_FeatureTree" />
|
||||||
@ -365,6 +366,12 @@
|
|||||||
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="NewOrUpgradeInstanceDlg" Order="999">
|
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="NewOrUpgradeInstanceDlg" Order="999">
|
||||||
NOT Installed AND UpgradableServiceFound
|
NOT Installed AND UpgradableServiceFound
|
||||||
</Publish>
|
</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">
|
<Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="ConfirmDataCleanupDlg" Order="4">
|
||||||
<![CDATA[(&DBInstance=2) AND (!DBInstance=3)]]>
|
<![CDATA[(&DBInstance=2) AND (!DBInstance=3)]]>
|
||||||
</Publish>
|
</Publish>
|
||||||
@ -645,11 +652,17 @@
|
|||||||
|
|
||||||
<CustomAction Id='ErrorDataDir'
|
<CustomAction Id='ErrorDataDir'
|
||||||
Error='Invalid data directory, choose a different one. Error : [DATADIRERROR]'/>
|
Error='Invalid data directory, choose a different one. Error : [DATADIRERROR]'/>
|
||||||
|
<CustomAction Id="ErrorInstallDir"
|
||||||
|
Error="[INSTALLDIRERROR]" />
|
||||||
<InstallExecuteSequence>
|
<InstallExecuteSequence>
|
||||||
<Custom Action="CheckDataDirectory" After="CostFinalize">
|
<Custom Action="CheckDataDirectory" After="CostFinalize">
|
||||||
<![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED=""]]>
|
<![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED=""]]>
|
||||||
</Custom>
|
</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="CheckDatabaseProperties" Before="CreateDatabaseCommand">SERVICENAME</Custom>
|
||||||
<Custom Action="CreateDatabaseCommand" After="CostFinalize" >
|
<Custom Action="CreateDatabaseCommand" After="CostFinalize" >
|
||||||
<![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED=""]]>
|
<![CDATA[&DBInstance=3 AND NOT !DBInstance=3 AND OLDERVERSIONBEINGUPGRADED=""]]>
|
||||||
|
Reference in New Issue
Block a user