winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Add support for installing portables from a zip

Open ryfu-msft opened this issue 3 years ago • 2 comments

Resolves #140

This PR adds functionality for supporting the installation of portable(s) from a zip archive.

Changes:

  • PortableEntry has been removed and replaced with PortableInstaller, which encapsulates the state and logic flow for handling a portable install/uninstall.
  • Portables from a zip are extracted directly to the target install folder. To support this, The ExtractArchive function passes a list by reference which will contain all of the extracted files after extraction is complete. Each extracted item is then recorded in the PortableIndex so that we can keep track of the files we place down during installation.
  • The portable target directory will always create and append a packageId_sourceId folder. This is to ensure that we always create the target install directory folder and do not risk attempting to delete a folder which we did not create (which can be an issue when using --purge)
  • Uninstall will now check that all exe and symlinks that are created have not been modified and can be safely removed prior to starting the uninstall flow. This is to ensure that we do not partially uninstall the package if a file does not match what is recorded in the index. This check can be overridden with the --force argument.

Tests:

  • E2E tests to verify that install, update, and uninstall work as expected for portable in zip.
  • Unit tests to ensure that all files recorded in the index are correctly verified prior to uninstall.
  • Added more granular tests for verifying portable installation (moving exe, creating symlink, and adding to PATH).
Microsoft Reviewers: Open in CodeFlow

ryfu-msft avatar Sep 06 '22 23:09 ryfu-msft

Is the output of the files removed intentional?

PS D:\Git\winget-pkgs> wingetdev install -m D:\Git\winget-pkgs\manifests\c\Codex\ffmpeg\essentials\5.1.1
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-5.1.1-essentials_build.zip
  ██████████████████████████████  78.9 MB / 78.9 MB
Successfully verified installer hash
Starting package install...
Successfully installed
PS D:\Git\winget-pkgs> winget list ffmpeg
Name              Id                                     Version
----------------------------------------------------------------
ffmpeg essentials Codex.ffmpeg.essentials__DefaultSource 5.1.1
PS D:\Git\winget-pkgs> wingetdev uninstall ffmpeg  
No installed package found matching input criteria.
PS D:\Git\winget-pkgs> wingetdev uninstall 'ffmpeg essentials'
Found ffmpeg essentials [Codex.ffmpeg.essentials__DefaultSource]
Starting package uninstall...
"C:\\Users\\Trenly\\AppData\\Local\\Microsoft\\WinGet\\Packages\\Codex.ffmpeg.essentials__DefaultSource\\ffmpeg-5.1.1-essentials_build"
"C:\\Users\\Trenly\\AppData\\Local\\Microsoft\\WinGet\\Links\\ffmpeg.exe"
"C:\\Users\\Trenly\\AppData\\Local\\Microsoft\\WinGet\\Links\\ffplay.exe"
"C:\\Users\\Trenly\\AppData\\Local\\Microsoft\\WinGet\\Links\\ffprobe.exe"
Successfully uninstalled

Trenly avatar Sep 17 '22 14:09 Trenly

Is the output of the files removed intentional?

I don't know if it is there for debugging purposes, but it should be written to log instead of stdout.

WinGet-2022-09-17-21-50-32.732.log

vedantmgoyal9 avatar Sep 17 '22 16:09 vedantmgoyal9

@ryfu-msft, is there documentation on how to prepare WinGet zip-based manifest? Thank you.

SeanFeldman avatar Oct 11 '22 19:10 SeanFeldman

@ryfu-msft, is there documentation on how to prepare WinGet zip-based manifest? Thank you.

I have a few examples on my fork - https://github.com/Trenly/winget-pkgs/branches/all?query=zips

YamlCreate.ps1 also supports Zip, but you have to enable developer options and override the manifest version to 1.4.0 using the YamlCreate settings. Just be aware that the community repository won't start accepting zip based manifests until the 1.4 client is in a stable release and has a high percentage of adoption

Trenly avatar Oct 11 '22 19:10 Trenly

We're going to update wingetcreate as well so it can also create manifests for .zip based packages.

denelon avatar Oct 11 '22 20:10 denelon