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

Chocolatey packaging script (chocolateyBeforeModify.ps1) incorrectly running on non-Windows platforms #2510

Closed
TheCakeIsNaOH opened this issue Jan 6, 2022 · 0 comments · Fixed by #2511
Assignees
Milestone

Comments

@TheCakeIsNaOH
Copy link
Member

TheCakeIsNaOH commented Jan 6, 2022

What You Are Seeing?

beforemodify scripts are still running during upgrades and uninstall on non-windows platforms.
Also, during uninstall, the automatic uninstaller and shimgen services are still running, while on the install/upgrade phase they are not running.

What is Expected?

The before modify scripts should not attempt to run on non-windows platforms.

How Did You Get This To Happen? (Steps to Reproduce)

  1. Build choco and run integration tests on non-windows
  2. Remove the upgradepackage install
  3. Run choco install --version=1.0.0 -s ./context upgradepackage
  4. Run choco upgrade -s ./context upgradepackage (or uninstall)

See this comment as well: #2434 (comment)

Output Log

Full Log Output

mono choco.exe uninstall --allow-unofficial --verbose --debug upgradepackage                         Chocolatey v0.11.3-108-g4c320478
Chocolatey is running on Linux v 5.14.0.0
Attempting to delete file "/path/choco/build_output/chocolatey/chocolatey.dll.old".
Attempting to delete file "/path/choco/build_output/chocolatey/choco.exe.old".
Command line: /path/choco/build_output/chocolatey/choco.exe uninstall --allow-unofficial --verbose --debug upgradepackage
Received arguments: uninstall --allow-unofficial --verbose --debug upgradepackage
RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
Sending message 'PreRunMessage' out if there are subscribers...
[Pending] Removing all pending packages that should not be considered installed...
Performing validation checks.
Global Configuration Validation Checks:
 - Package Exit Code / Exit On Reboot = Checked
System State Validation Checks:
The source 'https://community.chocolatey.org/api/v2/' evaluated to a 'normal' source type

NOTE: Hiding sensitive configuration data! Please double and triple
 check to be sure no sensitive data is shown, especially if copying
 output to a gist for review.
Configuration: CommandName='uninstall'|CacheLocation='/tmp/chocolatey'|
ContainsLegacyPackageInstalls='True'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
Sources='https://community.chocolatey.org/api/v2/'|SourceType='normal'|
Debug='True'|Verbose='True'|Trace='False'|Force='False'|Noop='False'|
HelpRequested='False'|UnsuccessfulParsing='False'|RegularOutput='True'|
QuietOutput='False'|PromptForConfirmation='True'|AcceptLicense='False'|
AllowUnofficialBuild='True'|Input='upgradepackage'|AllVersions='False'|
SkipPackageInstallProvider='False'|PackageNames='upgradepackage'|
Prerelease='False'|ForceX86='False'|OverrideArguments='False'|
NotSilent='False'|ApplyPackageParametersToDependencies='False'|
ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'|
AllowMultipleVersions='False'|AllowDowngrade='False'|
ForceDependencies='False'|Information.PlatformType='Linux'|
Information.PlatformVersion='5.14.0.0'|
Information.PlatformName='Linux'|
Information.ChocolateyVersion='0.12.0.0'|
Information.ChocolateyProductVersion='0.11.3-108-g4c320478'|
Information.FullName='chocolatey, Version=0.12.0.0, Culture=neutral, PublicKeyToken=fd112f53c3ab578c'|

Information.Is64BitOperatingSystem='True'|
Information.Is64BitProcess='True'|Information.IsInteractive='False'|
Information.UserName='user'|Information.UserDomainName='system'|
Information.IsUserAdministrator='False'|
Information.IsUserSystemAccount='False'|
Information.IsUserRemoteDesktop='False'|
Information.IsUserRemote='True'|
Information.IsProcessElevated='False'|
Information.IsLicensedVersion='False'|Information.LicenseType='Foss'|
Information.CurrentDirectory='/path/choco/build_output/chocolatey'|

Features.AutoUninstaller='True'|Features.ChecksumFiles='True'|
Features.AllowEmptyChecksums='False'|
Features.AllowEmptyChecksumsSecure='True'|
Features.FailOnAutoUninstaller='False'|
Features.FailOnStandardError='False'|Features.UsePowerShellHost='True'|
Features.LogEnvironmentValues='False'|Features.LogWithoutColor='False'|
Features.VirusCheck='False'|
Features.FailOnInvalidOrMissingLicense='False'|
Features.IgnoreInvalidOptionsSwitches='True'|
Features.UsePackageExitCodes='True'|
Features.UseEnhancedExitCodes='False'|
Features.UseFipsCompliantChecksums='False'|
Features.ShowNonElevatedWarnings='True'|
Features.ShowDownloadProgress='True'|
Features.StopOnFirstPackageFailure='False'|
Features.UseRememberedArgumentsForUpgrades='False'|
Features.IgnoreUnfoundPackagesOnUpgradeOutdated='False'|
Features.SkipPackageUpgradesWhenNotInstalled='False'|
Features.RemovePackageInformationOnUninstall='False'|
Features.ExitOnRebootDetected='False'|
Features.LogValidationResultsOnWarnings='True'|
Features.UsePackageRepositoryOptimizations='True'|
Features.ScriptsCheckLastExitCode='False'|
ListCommand.LocalOnly='False'|
ListCommand.IdOnly='False'|ListCommand.IncludeRegistryPrograms='False'|
ListCommand.PageSize='25'|ListCommand.Exact='False'|
ListCommand.ByIdOnly='False'|ListCommand.ByTagOnly='False'|
ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'|
ListCommand.ApprovedOnly='False'|
ListCommand.DownloadCacheAvailable='False'|
ListCommand.NotBroken='False'|
ListCommand.IncludeVersionOverrides='False'|
UpgradeCommand.FailOnUnfound='False'|
UpgradeCommand.FailOnNotInstalled='False'|
UpgradeCommand.NotifyOnlyAvailableUpgrades='False'|
UpgradeCommand.ExcludePrerelease='False'|
NewCommand.AutomaticPackage='False'|
NewCommand.UseOriginalTemplate='False'|SourceCommand.Command='unknown'|
SourceCommand.Priority='0'|SourceCommand.BypassProxy='False'|
SourceCommand.AllowSelfService='False'|
SourceCommand.VisibleToAdminsOnly='False'|
FeatureCommand.Command='unknown'|ConfigCommand.Command='unknown'|
ApiKeyCommand.Remove='False'|PinCommand.Command='unknown'|
OutdatedCommand.IgnorePinned='False'|
ExportCommand.IncludeVersionNumbers='False'|Proxy.BypassOnLocal='True'|

Chocolatey is not an official build (bypassed with --allow-unofficial).
 If you are seeing this message and it is not expected, your system may
 now be in a bad state. Only official builds are to be trusted.

_ Chocolatey:ChocolateyUninstallCommand - Normal Run Mode _
Uninstalling the following packages:
upgradepackage
Running list with the following filter = ''
--- Start of List ---
upgradepackage 1.1.0
badpackage 1.0
installpackage 1.0.0
--- End of List ---
Unable to determine current user to determine if LocalSystem account (to skip user env vars).
 Reported error: The method or operation is not implemented.
Setting installer args for upgradepackage
Setting package parameters for upgradepackage
Contents of '/path/choco/build_output/chocolatey/lib/upgradepackage/tools/chocolateyBeforeModify.ps1':
Write-Output "$env:PackageName $env:PackageVersion Before Modification"
The package upgradepackage wants to run 'chocolateyBeforeModify.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint):

TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Jan 6, 2022
This sets the beforemodify script to only run on windows platforms.
The powershell scripts do not work on non-windows platforms, so they
should not be run.
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Jan 6, 2022
…dows

This put a check on the powershell uninstall script, shimgen uninstall,
autoUninstaller and shutdown /a calls during uninstall. They will now
only run on windows. None of these services work on non-windows, so
they should not be run
TheCakeIsNaOH added a commit to TheCakeIsNaOH/choco that referenced this issue Jan 6, 2022
This skips the when_uninstalling_a_package_with_an_exclusively_locked_file
test on non-windows systems. This test previously worked because the install
was failing due to the beforemodify script, but now that the script run has
been disabled, this test fails on non-windows platforms.
@gep13 gep13 added this to the 0.12.0 milestone Jan 10, 2022
gep13 pushed a commit to TheCakeIsNaOH/choco that referenced this issue Jan 10, 2022
This sets the beforemodify script to only run on windows platforms.
The powershell scripts do not work on non-windows platforms, so they
should not be run.
gep13 pushed a commit to TheCakeIsNaOH/choco that referenced this issue Jan 10, 2022
…dows

This put a check on the powershell uninstall script, shimgen uninstall,
autoUninstaller and shutdown /a calls during uninstall. They will now
only run on windows. None of these services work on non-windows, so
they should not be run
gep13 pushed a commit to TheCakeIsNaOH/choco that referenced this issue Jan 10, 2022
This skips the when_uninstalling_a_package_with_an_exclusively_locked_file
test on non-windows systems. This test previously worked because the install
was failing due to the beforemodify script, but now that the script run has
been disabled, this test fails on non-windows platforms.
gep13 added a commit that referenced this issue Jan 10, 2022
(#2510) Stop Beforemodify scripts from running on non-windows
@gep13 gep13 added 4 - Done and removed 3 - Review labels Jan 10, 2022
@gep13 gep13 changed the title Beforemodify scripts still running on non-windows platforms Chocolatey packaging script (chocolateyBeforeModify.ps1) incorrectly running on non-windows platforms Jan 17, 2022
@gep13 gep13 changed the title Chocolatey packaging script (chocolateyBeforeModify.ps1) incorrectly running on non-windows platforms Chocolatey packaging script (chocolateyBeforeModify.ps1) incorrectly running on non-Windows platforms Jan 18, 2022
gep13 added a commit that referenced this issue Jan 18, 2022
* release/0.12.0: (102 commits)
  (maint) Add generation of template command
  (#2522) Update documentation
  (maint) Remove unnecessary whitespace
  (#2522) Remove deprecated ScriptsCheckLastExitCode
  (maint) Fix spelling mistake
  (version) 0.12.0-beta
  (#2518) Add tab completion for template command
  (#2481) Warn about unuspported packages on non-Windows
  (#357) Add information about when command added
  (#449) Add information about when command added
  (#499) Add specs for template service list noop
  (#499) Add specs for template command
  (#449) Add template command
  (#449) Template service rename noop to generate_noop
  (#2434) Correct casing of filename in changed files tests
  (#2434) Enable more scenarios, skip only shim and powershell facts
  (#2450) Enable configTransform tests on non-Windows
  (#2450) Enable functions on non-Windows systems
  (maint) Corrected casing of PowerShell
  (#2510) Exclude uninstalling with locked file on non-windows
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants