from Hacker News

Show HN: Meta Package Manager, a CLI that solves Xkcd #1654

by kdeldycke on 7/12/22, 2:26 PM with 1 comments

Tl;Dr: mpm implements a solution to XKCD #1654 (Universal Install Script). Now you can do:

    $ mpm --xkcd install <my_package>
and let it figure out which package manager to use to install your package.

The project is open-source: https://github.com/kdeldycke/meta-package-manager#readme

This CLI has some other capabilities, like listing the duplicate packages on your system:

    $ mpm list --duplicates
    ╭────────────┬─────────┬───────────────────╮
    │ Package ID │ Manager │ Installed version │
    ├────────────┼─────────┼───────────────────┤
    │ blah       │ cargo   │ 0.0.0             │
    │ blah       │ gem     │ 0.0.2             │
    │ blah       │ npm     │ 5.2.1             │
    │ coverage   │ pip     │ 6.4.1             │
    │ coverage   │ pipx    │ 6.4.1             │
    │ six        │ brew    │ 1.16.0_2          │
    │ six        │ pip     │ 1.16.0            │
    ╰────────────┴─────────┴───────────────────╯
List outdated packages:

    $ mpm outdated
    ╭───────────┬─────────┬───────────────────┬────────────────╮
    │ ID        │ Manager │ Installed version │ Latest version │
    ├───────────┼─────────┼───────────────────┼────────────────┤
    │ curl      │ brew    │ 7.79.1            │ 7.79.1_1       │
    │ git       │ brew    │ 2.33.0            │ 2.33.0_1       │
    │ npm@8.0.0 │ npm     │ 7.24.0            │ 8.0.0          │
    │ pip       │ pip     │ 21.2.4            │ 21.3           │
    │ regex     │ pip     │ 2021.9.30         │ 2021.10.8      │
    ╰───────────┴─────────┴───────────────────┴────────────────╯
Or dump all installed packages to a file:

    $ mpm snapshot packages.toml
    Dumping packages from brew...
    Dumping packages from cask...
    Dumping packages from gem...
    Dumping packages from mas...
    Dumping packages from npm...
    Dumping packages from pip...
    1109 packages total (npm: 659, brew: 229, pip: 115, gem: 49, cask: 48, mas: 9).
To install it, either use:

    $ pipx install meta-package-manager

    $ pip install meta-package-manager

    $ python -m pip install meta-package-manager

    $ brew untap hasnep/tap && brew install hasnep/tap/meta-package-manager

    $ paru -S meta-package-manager

    $ yay -S meta-package-manager
Or if you are meta:

    $ mpm install meta-package-manager
See install doc at: https://kdeldycke.github.io/meta-package-manager/install.html
  • by kdeldycke on 7/12/22, 2:26 PM

    I started working on this 6 years ago in the form of a hackish script to have all outdated packages listed in my macOS task bar. You can replicate this with an xBar/SwiftBar plugin: https://kdeldycke.github.io/meta-package-manager/bar-plugin....

    Now the CLI supports Linux, macOS and Windows. And implements list, outdated, search, install, upgrade, remove, sync and cleanup operations.

    Supported package managers are: apm, apt, apt-mint, brew, cargo, cask, chocolatey, composer, dnf, emerge, flatpak, gem, mas, npm, opkg, pacman, paru, pip, pipx, snap, steamcmd, vscode, yarn, yay, yum and zypper.

    Some other use-cases are documented here: https://kdeldycke.github.io/meta-package-manager/usecase.htm...

    The worst thing with this project is trying to run some sorts of integration tests over the whole matrix of OS/distribution/package managaer/versions. That's time consuming, tedious and implies lots of trials and errors. So I am just aiming at doing a good-enough work on that front.

    It's not perfect but the CLI is useable everyday judging by feedback I gathered so far. Now I need ever more feedback and help to manage all that menagerie! :)

    Note: this Show HN was suggested some month ago by other users at https://news.ycombinator.com/item?id=30290079