Skip to content

Determine installer type heuristically #24

@coolaj86

Description

@coolaj86

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

  • License
  • Readme
  • Shell Completions
  • Top-level Man pages

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

  • Go (has two bin dirs)
  • Node (no bin on Windows)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions