r/sysadmin • • May 19 '20

Microsoft 📢 Windows Package Manager | winget.exe

[deleted] — view deleted post

383 Upvotes

126 comments sorted by

View all comments

Show parent comment

1

u/Aetheus May 21 '20

In what way will it require a complete redesign to improve it? What features or behaviours are impossible for it right now?

2

u/fast4shoot May 21 '20 edited May 22 '20

Managing anything installed via EXEs or (I believe) MSIs is going to be impossible.

1

u/Aetheus May 22 '20

How so? Aren't most EXE/MSI installers deterministic (e.g: glorified archives that just need to be extracted + maybe some registry key bullshit)? If so, it shouldn't be too hard to keep checksums of installs for verifying versions, repairing broken installs, etc.

Genuine question btw. I don't dive deep into how Linux package managers like apt or pacman work. I'm not even a sysadmin - I'm just a dev that heard about winget, searched it on Reddit, and stumbled into this thread.

2

u/fast4shoot May 22 '20

EXE installers are just arbitrary executables whose purpose is to install an application. Because it's an executable, there's really no general way to inspect that executable. You can't extract the files that it installs out of it, because they may be stored in whatever weird way the installer's author (or the tool they used) decided. Or the files may not be stored in the executable at all, they may be downloaded from the internet. Or some of the files (like configuration files, desktop shortcuts and such) may be generated on the fly.

The same also applies to registry keys.

You could, for example, run the installer and trace what it does (by capturing the system calls that the application does) to get an idea pretty good idea of what the installer does, but it's hard to automate (especially with installers that provide the user with some options) and it's still not a general solution, you have no way of knowing (well, short of disassembling the installer) if the installer would act the same way on a different machine. Its behavior could depend on arbitrary data from the internet, on the permissions of the logged in user, on the already installed pieces of software, on the current time, on the directory it ran from, on arbitrary files on the computer, on system settings, on registry keys and on a whole lot more. And in general you just can't capture its behavior well enough.

With MSIs the situation is a bit different. MSI is meant to be an installation package - it's not just an arbitrary executable, it's got some structure to it, so you can get some good behavior out of it. I believe that, if used properly, MSI installations are atomic (meaning that either the full installation succeeds or the whole thing just fails but doesn't leave your system in some weird intermediate state) and behave well enough that the system can automatically figure out how to uninstall the application.

The critical bit here is the "if used properly" one.

I believe that MSI is such a complicated format that not even Microsoft understands it. And that leads half-assed MSI packages that abuse the format in one way or another and that break some of MSI's promises. I believe I've seen some MSIs that just contained an EXE which they ran during the install process. And that's because MSIs still allow you to run arbitrary code that can do anything.

On Linux, the situation is, once again, different. Software packages are generally much simpler - in many cases they are indeed just an archive that needs to be extracted plus some metadata. Why's that good? Well, because archives are easy and it's hard to screw up a package like that. That gives the user more control over the installation process, makes it easier to automate and makes it more flexible.

Some (most?) package managers allow a package to run arbitrary code during the installation/upgrade/uninstallation process, so in essence they could have the same issues that installers have on Windows, but in practice that doesn't happen too often. Probably because it would go against the established conventions. Also, it's highly probable that your uninstaller is just a piece of crap that would probably break half of the OS if executed (remember how Steam once deleted everything on the system that it could?). People wouldn't like you if your package did that.

One exception in the world of Linux packages that I know of would be RPM. Apparently it's not a nice format. But it appears that even that didn't stop yum and dnf from being good package managers.

This all comes to the fact that software installation is a complicated thing that's easy to screw up and so you shouldn't roll your own installers. However that requires you to provide your application in some logical, nicely packaged way. EXEs and MSIs are not that (and I'm not even sure if MSIX is either).

I hope that this was helpful.

1

u/Aetheus May 22 '20

That was an incredibly detailed and clear explanation - thank you! I understand the challenges involved with building a Windows package manager a lot better now.

I'm assuming that alternative Windows package managers like Scoop or Chocolatey are doing something similar to most Linux package managers (i.e: just extracting some archives to a standard location)?

Or do they too suffer from the same flaw?

2

u/fast4shoot May 22 '20 edited May 22 '20

I'm not sure about Scoop, but Chocolatey reminds me more of winget than of Linux package managers, because quite a lot of the packages on there consist of an installer and a script that just runs the installer.

Edit: By the way, I just realized one thing - on Linux you can just replace files even if they're currently open and the processes that have them open will still see the old contents of those files. This is huge for upgrades, because it means that you can just replace an application even though it's currently running and in a lot of cases everything will be fine.

This is one of the reasons why I can just upgrade my entire operating system and all applications by extracting a bunch of archives. Doing something like that on Windows would be much more complicated. That's why windows updates have to restart your computer and then do some additional steps immediately before or after the actual reboot.

1

u/Aetheus May 23 '20

Interesting. Scoop is primarily meant for installing developer tools instead of GUI apps, so app manifest for GUI apps are in a separate repo (scoop-extras).

Taking a look at the app manifest for Notepad++, it looks like Scoop primarily just grabs an archive for it and unpacks it (https://github.com/lukesampson/scoop-extras/blob/master/bucket/notepadplusplus.json). The simplest example given by Scoop's wiki is also just a "grab this zip file, unpack it, and make the script in it available to the PATH" (https://github.com/lukesampson/scoop/wiki/App-Manifests).

Of course, it does still allow app manifests to define a pre/post install script, similar to what you mentioned about Linux package managers.

That's a good point on Linux updates. It's ... Curious. I recall hearing that Windows 10X will have a more seamless upgrade process, where the OS will "install [updates] in the background" and won't restart "until [installing the updates] is done" (ref: https://www.windowscentral.com/windows-10x - "Improved Windows Updates"). If this is technically possible, I wonder why it hasn't already been applied to "standard" Windows 10 (or older Windows versions, for that matter).