Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[windows] fix npm upgrade bug #11446

Merged
merged 4 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions omnibus/resources/agent/msi/source.wxs.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<Property Id="APIKEY" Hidden="yes" />
<Property Id="SITE" Value="datadoghq.com" />
<Property Id="FinalizeInstall" Hidden="yes" />
<Property Id="NPMFEATURESTATE" />
<PropertyRef Id="WIX_ACCOUNT_ADMINISTRATORS" />
<PropertyRef Id="WIX_ACCOUNT_LOCALSYSTEM" />
<PropertyRef Id="WIX_ACCOUNT_USERS" />
Expand All @@ -101,7 +102,22 @@
<SetProperty Id="PROJECTLOCATIONONCMDLINESLASH" Value="[PROJECTLOCATION]\" Before="AppSearch">PROJECTLOCATION </SetProperty>
<SetProperty Id="CONFDIRONCOMMANDLINE" Value="[APPLICATIONDATADIRECTORY]" Before="AppSearch">APPLICATIONDATADIRECTORY </SetProperty>
<SetProperty Id="CONFDIRONCOMMANDLINESLASH" Value="[APPLICATIONDATADIRECTORY]\" Before="AppSearch">APPLICATIONDATADIRECTORY </SetProperty>

<!--
The following sets a property (to be used by the custom action).
the "&" indicates the action state of a feature (so &NPM refers to the NPM _feature_ not the NPM property that might be set on the command line)
"3" refers to the action state "on the local computer" (which is the only one we support besides "not present", which happens to be "2")

So, the NPMFEATURESTATE property will be set to "off" if the NPM feature is no installed on the local computer
and will be set to "on" if it is used on the local computer.

This flag will be used in the custom action to decide what service dependencies need to be set

For more information on this syntax see
https://www.firegiant.com/wix/tutorial/com-expression-syntax-miscellanea/expression-syntax/
-->
<SetProperty Action="SetNPMOff" Id="NPMFEATURESTATE" Before="SetFinalizeProperty" Value="off" Sequence="execute"><![CDATA[not (&NPM = 3)]]></SetProperty>
<SetProperty Action="SetNPMOn" Id="NPMFEATURESTATE" Before="SetFinalizeProperty" Value="on" Sequence="execute"><![CDATA[(&NPM = 3)]]></SetProperty>
Comment on lines +119 to +120
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if specifying NPM values or perhaps their location would be useful here. Strange to see a comparison to 3 IMHO. Just a thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "3" is a magic number provided by wix
https://www.firegiant.com/wix/tutorial/com-expression-syntax-miscellanea/expression-syntax/
(skip down to "prefixes")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh boy, thank you Derek. My comments shows WiX ignorance :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, your comment/question indicates I was remiss in describing what that meant. Added a very verbose comment.

<!-- This condition allows the install if
1) the user didn't supply the binary directory on the command line
2) this is NOT an upgrade
Expand Down Expand Up @@ -651,6 +667,7 @@
This does not affect the final artefact, as it seems to affects only the base string, not the expanded one.
At runtime this limitation doesn\'t seem to apply.
-->

<CustomAction Id='SetFinalizeProperty' Return='check' Property='FinalizeInstall'
Value='
UILevel=[UILevel]
Expand All @@ -659,6 +676,7 @@
DDAGENTUSER_NAME=[DDAGENTUSER_NAME]
DDAGENTUSER_PASSWORD=[DDAGENTUSER_PASSWORD]
SYSPROBE_PRESENT=[SYSPROBE_PRESENT]
NPMFEATURE=[NPMFEATURESTATE]
ADDLOCAL=[ADDLOCAL]
APIKEY=[APIKEY]
TAGS=[TAGS]
Expand Down
11 changes: 11 additions & 0 deletions releasenotes/notes/fixnpmupgrade-ef6b42d87c980541.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Each section from every release note are combined when the
# CHANGELOG.rst is rendered. So the text needs to be worded so that
# it does not depend on any information only available in another
# section. This may mean repeating some details, but each section
# must be readable independently of the other.
#
# Each section note must be formatted as reStructuredText.
---
fixes:
- |
For Windows, fixes problem in upgrade wherein NPM driver is not automatically started by system probe.
27 changes: 12 additions & 15 deletions tools/windows/install-help/cal/customactiondata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ bool CustomActionData::parseSysprobeData()
std::wstring sysprobePresent;
std::wstring addlocal;
std::wstring npm;
std::wstring npmFeature;
this->_doInstallSysprobe = false;
this->_ddnpmPresent = false;
if (!this->value(L"SYSPROBE_PRESENT", sysprobePresent))
Expand Down Expand Up @@ -172,24 +173,20 @@ bool CustomActionData::parseSysprobeData()
this->_ddnpmPresent = true;
}

// now check to see if we're installing the driver
if (!this->value(L"ADDLOCAL", addlocal))

if (this->value(L"NPMFEATURE", npmFeature))
{
// should never happen. But if the addlocalkey isn't there,
// don't bother trying
WcaLog(LOGMSG_STANDARD, "ADDLOCAL not present");

return true;
// this property is set to "on" or "off" depending on the desired installed state
// of the NPM feature.
WcaLog(LOGMSG_STANDARD, "NPMFEATURE key is present and (%S)", npmFeature.c_str());
if (_wcsicmp(npmFeature.c_str(), L"on") == 0)
{
this->_ddnpmPresent = true;
}
}
WcaLog(LOGMSG_STANDARD, "ADDLOCAL is (%S)", addlocal.c_str());
if (_wcsicmp(addlocal.c_str(), L"ALL") == 0)
else
{
// installing all components, do it
this->_ddnpmPresent = true;
WcaLog(LOGMSG_STANDARD, "ADDLOCAL is ALL");
} else if (addlocal.find(L"NPM") != std::wstring::npos) {
WcaLog(LOGMSG_STANDARD, "ADDLOCAL contains NPM %S", addlocal.c_str());
this->_ddnpmPresent = true;
WcaLog(LOGMSG_STANDARD, "NPMFEATURE not present");
}

return true;
Expand Down