From 92f595a6598083637d8ac4b594966506286d5bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Thu, 2 Jul 2015 16:34:27 +0100 Subject: [PATCH 1/3] win,msi: change InstallScope to perMachine The MSI install scope was set to the WiX default, which is per-user. However, with UAC, it could not be installed by a standard user because InstallPrivileges is elevated by default, hence the install scope should be set to per-machine. Furthermore, the default install path is a per-machine location and setting the system path requires administrator privileges. By changing the InstallScope to perMachine, Start Menu shortcuts are placed in ProgramData and not the installing user's AppData folder, making the shortcuts available to other users. This also fixes the installation when AppData is a network folder. The custom action is necessary to allow upgrades. Since a per-machine MSI cannot upgrade an application installed per-user, the custom action checks if there is going to be an upgrade to a previous version installed per-user and sets the installation as per-user to allow upgrading. Hence, the advantages of installing per-machine will only apply in fresh installations. Fixes #5849 Fixes #7629 --- tools/msvs/msi/custom_actions.c | 52 ++++++++++++++++++++++++++++++- tools/msvs/msi/custom_actions.def | 3 +- tools/msvs/msi/product.wxs | 17 ++++++++-- 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/tools/msvs/msi/custom_actions.c b/tools/msvs/msi/custom_actions.c index 5e7d617f387..bf36edc734e 100644 --- a/tools/msvs/msi/custom_actions.c +++ b/tools/msvs/msi/custom_actions.c @@ -1,10 +1,60 @@ - #define WIN32_LEAN_AND_MEAN #include #include #include +#define GUID_BUFFER_SIZE 39 // {8-4-4-4-12}\0 + + +UINT WINAPI SetInstallScope(MSIHANDLE hInstall) { + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + TCHAR upgrade_code[GUID_BUFFER_SIZE]; + DWORD upgrade_code_len = GUID_BUFFER_SIZE; + DWORD iProductIndex; + TCHAR product_code[GUID_BUFFER_SIZE]; + TCHAR assignment_type[2]; + DWORD assignment_type_len = 2; + + hr = WcaInitialize(hInstall, "SetInstallScope"); + ExitOnFailure(hr, "Failed to initialize"); + + er = MsiGetProperty(hInstall, TEXT("UpgradeCode"), upgrade_code, + &upgrade_code_len); + ExitOnWin32Error(er, hr, "Failed to get UpgradeCode property"); + + for (iProductIndex = 0;; iProductIndex++) { + er = MsiEnumRelatedProducts(upgrade_code, 0, iProductIndex, product_code); + if (er == ERROR_NO_MORE_ITEMS) break; + ExitOnWin32Error(er, hr, "Failed to get related product code"); + + er = MsiGetProductInfo(product_code, INSTALLPROPERTY_ASSIGNMENTTYPE, + assignment_type, &assignment_type_len); + ExitOnWin32Error(er, hr, "Failed to get the assignment type property " + "from related product"); + + // '0' = per-user; '1' = per-machine + if (assignment_type[0] == '0') { + /* When old versions which were installed as per-user are detected, the + * installation scope has to be set to per-user to be able to do an + * upgrade. If not, two versions will be installed side-by-side: one as + * per-user and the other as per-machine. + * + * If we wanted to disable backward compatibility, the installer should + * abort here, and request the previous version to be manually + * uninstalled before installing this one. + */ + er = MsiSetProperty(hInstall, TEXT("ALLUSERS"), TEXT("")); + ExitOnWin32Error(er, hr, "Failed to set the install scope to per-user"); + break; + } + } + +LExit: + return WcaFinalize(ERROR_SUCCESS); +} + UINT WINAPI BroadcastEnvironmentUpdate(MSIHANDLE hInstall) { HRESULT hr = S_OK; diff --git a/tools/msvs/msi/custom_actions.def b/tools/msvs/msi/custom_actions.def index 29e0933e379..5f6b25fc423 100644 --- a/tools/msvs/msi/custom_actions.def +++ b/tools/msvs/msi/custom_actions.def @@ -1,4 +1,5 @@ LIBRARY "custom_actions" EXPORTS -BroadcastEnvironmentUpdate \ No newline at end of file +SetInstallScope +BroadcastEnvironmentUpdate diff --git a/tools/msvs/msi/product.wxs b/tools/msvs/msi/product.wxs index 6ff0d4b149b..2ce00a44b1d 100755 --- a/tools/msvs/msi/product.wxs +++ b/tools/msvs/msi/product.wxs @@ -18,7 +18,7 @@ Manufacturer="$(var.ProductAuthor)" UpgradeCode="1d60944c-b9ce-4a71-a7c0-0384eb884baa"> - + @@ -249,16 +249,27 @@ - + + + + + + + From 65d5d07765d5c49f18ca44457d745a5bb7b9fa65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Thu, 2 Jul 2015 16:48:59 +0100 Subject: [PATCH 2/3] win,msi: correct installation path registry keys Since install is per machine only, installation path should be stored in local machine instead of current user. The registry stores HKLM in different places for 32 and 64 bit applications, so the installer will not suggest the old path when upgrading from 32 to 64 bit version. Fixes #5592 Fixes #25087 --- tools/msvs/msi/product.wxs | 42 ++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/tools/msvs/msi/product.wxs b/tools/msvs/msi/product.wxs index 2ce00a44b1d..3c3eb685bcc 100755 --- a/tools/msvs/msi/product.wxs +++ b/tools/msvs/msi/product.wxs @@ -32,6 +32,14 @@ + + + - + @@ -117,6 +126,20 @@ + + + + + @@ -139,18 +162,15 @@ - + + - Date: Wed, 22 Jul 2015 16:12:02 +0200 Subject: [PATCH 3/3] test: mark test-signal-unregister as flaky This test just failed on Ubuntu in Jenkins, for a change that is 100% Windows-specific. --- test/simple/simple.status | 1 + 1 file changed, 1 insertion(+) diff --git a/test/simple/simple.status b/test/simple/simple.status index 58df7e9840e..ed6513a7b13 100644 --- a/test/simple/simple.status +++ b/test/simple/simple.status @@ -14,6 +14,7 @@ test-fs-readfile-error : PASS,FLAKY test-net-GH-5504 : PASS,FLAKY test-stdin-script-child : PASS,FLAKY test-util-debug : PASS,FLAKY +test-signal-unregister : PASS,FLAKY [$system==macos] test-fs-watch : PASS,FLAKY