webinstall / webi-roadmap

A space where we can ideate without cluttering the main repo with stale issues
Mozilla Public License 2.0
2 stars 0 forks source link

Determine installer type heuristically #24

Open coolaj86 opened 8 months ago

coolaj86 commented 8 months ago

A very high percentage of developer tools that provide packaged releases (~99%) can be categorized into a finite set of formats that can be installed with a finite set of rules - probably around 6 for unpacking, and 6 for type of contents.

We should be able to create almost all (80%+) installers from a set of rules.

Rules

Typically we're dealing with one of these package styles:

# bare (like ollama)
thing-1.0-linux

# bare, compressed
unxz thing-1.0-linux.xz

# compressed container
tar xvf thing-1.0-linux.tar.xz
unzip thing-1.0-linux.zip
diskutil ... thing-1.0-arm.dmg

Once unpacked, the directory structure almost always falls into one of these hierarchies:

./thing
./bin/thing
./thing-1.0/thing
./thing-1.0/bin/thing

# macOS apps (iTerm2, Brave)
Thing.app/

# macOS faux apps (fish, cmake)
Thing.app/Contents/thing
Thing.app/Contents/bin/thing

# Windows files have .exe
thing.exe

We should always know the exact name of the command that will be installed.

We should be able to determine if there are other files or just the one.

We should be able to tell if the manpage file exists or not.

Exceptions

If we detect extra loose files outside the opt directory structure, we can "best guess it" flag it for manual review.

Notes

we probably shouldn't attempt this in shell, but...

# count how deep "thing" is once unpacked 
echo "thing/bin/thing" | tr -dc '/' | wc -c