0
votes

In order to make install scripts and understanding existing ones, I would like to know what happens behind the scenes of the typical:

choco install notepadplusplus 

I found the following here:

Installation

  1. Chocolatey uses Nuget.Core to retrieve the package from the source.
  2. Choco determines if it self-contained or has automation scripts - PowerShell scripts (*.ps1 files), and soon to be open to Scriptcs files in the 0.9.10.x timeframe (I know, right?!).
  3. Choco takes a registry snapshot for later comparison.
  4. If there are automation scripts, choco will run those. They can contain whatever you need to do, if they are PowerShell you have the full power of Posh (PowerShell), but you should try to ensure they are compatible with Posh v2+.
  5. Choco compares the snapshot and determines uninstaller information and saves that to a .registry file.
  6. Choco snapshots the folder based on all files that are currently in the package directory.
  7. Choco looks for executable files in the package folder and generates shims into the $env:ChocolateyInstall\bin folder so those items are available on the path. Those could have been embedded into the package or brought down from somewhere (internet, ftp, file folder share, etc) and placed there.

That given,

    • How can I get the .nupkg package URL? In general it seems like this:

      https://chocolatey.org/api/v2/package/package-name

    • Which is the .nupkg package download directory?

    • Where is the content of the .nupkg package extracted by default? This is important since chocolateyInstall.ps1 sometime uses Split-Path -Parent $MyInvocation.MyCommand.Definition.

  1. "Scriptcs files in the 0.9.10.x timeframe" is rather cryptic. Can you give some references?

  2. Is Posh v2+ simply short for Powershell or is a specific technology?

  3. There are several executable files in $env:ChocolateyInstall\lib without a link in $env:ChocolateyInstall\bin. For example, the mpv.exe of the mpv player is not linked.

1
I've updated the wiki, which will update that link soon - please see if github.com/chocolatey/choco/wiki/GettingStarted#installation more sufficiently answers your questions.ferventcoder
@ferventcoder: thanks, what I was looking for. Little typo: "Choco determines if it self-contained", missing "is".antonio
Thanks, fixed on the wiki. Will update to site later.ferventcoder
@ferventcoder: As regards snapshots, what are the folders subject to the snapshots.antonio
Just the package directory currently (as indicated in number 6 above).ferventcoder

1 Answers

2
votes
  1. Yes, that download URL seems correct. The download directory is always into the Chocolatey installation folder, then lib\packageName, and this is where contents are extracted to.
  2. Right now, installation scripts are only written in PowerShell. This comment is referring to the ability to write in installation scripts in C#, using the ScriptCS run time. Currently, this isn't yet supported.
  3. Yes, this is just a short way of referring to PowerShell.
  4. In the case of the mpv package, you will notice that there is an mpv.exe.ignore file. The presence of this file in the package prevents a shim being created.