Skip to content
Hamza-b93Public

About

A modern, user-friendly package manager for Arch Linux.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

31 Commits

Folders and files

Repository files navigation

Anvil

A minimal, self-hosted pacman GUI: a FastAPI backend that shells out to the real pacman/checkupdates/yay binaries, and a Tailwind-based browser frontend that talks to it. The page loads nothing from other hosts, so it works offline. Nothing here reimplements pacman's logic — every action you take runs the actual CLI command and streams its actual output back to you, prompts included.

What it needs on your system

  • Python 3.10+ (Arch ships something newer by default, so this is almost certainly already satisfied)
  • pacman-contrib, for the checkupdates command used to check for repo updates without needing root:
    sudo pacman -S pacman-contrib
    
  • yay (optional), for AUR search/updates/install/remove. Without it, the AUR-related panels just report it's missing — everything else still works:
    git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si
    
  • polkit, with a graphical authentication agent running (this is already the case if you're on GNOME, KDE Plasma, or XFCE with its default polkit agent). Privileged actions (apply, remove, keyring refresh, mirror refresh) run via pkexec, which will pop your desktop's normal password prompt.
  • rate-mirrors (optional), for the two mirror-list buttons.
  • Nothing extra needed for AUR installs: yay shells out to plain sudo — not pkexec — for the final install step of an AUR build, and rather than relying on a system askpass dialog, Anvil supplies its own askpass helper that relays the password prompt into the browser (see "Interactive prompts" below for how). This relies on sudo: a yay configured to use doas instead isn't supported.

Running it

The easiest path is the AUR package:

yay -S anvil-manager
anvil-manager

Until then, install it from source with pip:

cd anvil
pip install -e .
anvil-manager

This installs FastAPI and uvicorn plus the anvil-manager console script. When started from a terminal it asks which port to use, defaulting to 8000 if you press Enter; anvil-manager --port 8123 skips the question, and so does starting it without a terminal (from a desktop entry or a service, which get port 8000). It then opens automatically in your browser.

For a no-install dev loop, ./run.sh sets up a local venv/, installs Anvil into it in editable mode, and runs anvil-manager — useful if you don't want to touch your system Python environment.

To stop it, use the Exit button in the header, or press Ctrl+C in the terminal it's running in.

How it works

anvil/
├── src/anvil/
│   ├── app.py              FastAPI app — read endpoints + WebSocket actions
│   ├── cli.py               `anvil-manager` console-script entry point
│   └── frontend/
│       ├── index.html       Tailwind UI, talks to the backend via fetch/WS
│       └── vendor/           Locally-vendored d3, Tailwind and fonts (no CDN)
├── tests/                   Backend tests, run against stub commands
├── packaging/
│   └── PKGBUILD             Arch package build recipe
├── .github/workflows/       CI, and publishing to the AUR on `v*` tags
├── pyproject.toml           Package metadata, dependencies, entry point
├── run.sh                    No-install dev convenience wrapper
├── CHANGELOG.md
├── TODO.md
├── LICENSE
└── README.md

Read-only data (GET /api/...) runs unprivileged commands directly:

  • /api/status → pacman -Q, -Qe, -Qdtq (orphans)
  • /api/updates → checkupdates (repo updates)
  • /api/aur_updates → yay -Qua (AUR updates)
  • /api/search → pacman -Ss <query> (repo search)
  • /api/aur_search → yay -Ss <query> (AUR search)
  • /api/installed → pacman -Q / pacman -Qe
  • /api/package_info?name= → pacman -Qi (falls back to -Si, then yay -Si); description, dependencies, and reverse dependencies for one package, fetched lazily when you expand a row in the Updates table
  • /api/history → parses /var/log/pacman.log

Actions that change the system (WS /ws/...) stream their output back to the browser as it happens. Those that need root ask through pkexec, except yay, which uses sudo itself (see "Interactive prompts"):

  • /ws/refresh_keyrings → pkexec pacman-key --refresh-keys, then pkexec pacman -Sy --needed archlinux-keyring, then pkexec pacman -Su
  • /ws/refresh_arch_mirrors, /ws/refresh_chaotic_mirrors → rate-mirrors into a temp file, then pkexec install over the mirror list, only if that file really contains mirrors. The previous list is kept next to it as <name>.anvil-bak.
  • /ws/apply → pkexec pacman -Syu [packages] (if updates are selected) or pkexec pacman -S <packages> (new installs alone)
  • /ws/remove → pkexec pacman -R <package>
  • /ws/remove_orphans → pkexec pacman -Rns <orphans>
  • /ws/aur_install → yay -Sua and/or yay -S <packages>
  • /ws/clean_cache → pkexec paccache -rk1 (trims /var/cache/pacman/pkg to the single most recent cached version of each package)
  • /ws/clean_aur_cache → yay -Sc (clears yay's AUR build cache, ~/.cache/yay)

One transaction runs at a time; a second is refused. Multi-step transactions stop at the first command that fails, and the drawer's final status reflects the real exit code.

Who can talk to it: only Anvil's own page. Binding to 127.0.0.1 keeps other machines out but not other websites, since browsers let any page open WebSockets and send simple POSTs to localhost. So the server refuses WebSockets and POSTs whose Origin isn't its own, any request whose Host isn't 127.0.0.1 or localhost, and package names that could be read as command-line flags.

Shutting down (POST /api/exit) stops the server itself — not a pacman action. It refuses (409) while any /ws/... transaction above is still running, so the "Exit" button in the header can't kill Anvil out from under a live install; otherwise it signals its own process to shut down cleanly.

Interactive prompts

All pacman- and yay-facing actions (refresh_keyrings, apply, remove, aur_install) run without --noconfirm. That's deliberate: with --noconfirm, pacman doesn't wait for anything — it silently takes the default answer to its own prompts and moves on, which for a package conflict means silently declining to resolve it and failing outright. --noconfirm also doesn't suppress yay's own AUR-build menus (exclude packages, clean build, show diffs, edit PKGBUILD).

Each command runs on its own pseudo-terminal, because yay can deadlock when it isn't attached to one. Output is stripped of terminal control codes, and pacman's redrawn progress bars become live bars rather than log lines: overall progress and running downloads in a panel above the log, and a download and an install bar for each package in the Updates table and search results.

Instead, the backend watches each command's output for text left sitting with no trailing newline and nothing more coming for a short idle window — and, to avoid mistaking pacman/yay just thinking (resolving dependencies, verifying signatures) for an actual unanswered prompt, only treats that as one if the leftover text also ends in the shape a real prompt uses ([Y/n], [y/N], yay's ==> menu marker, or a trailing :). A real prompt is relayed to the browser and rendered inline in the transaction drawer — Yes/No buttons for pacman's [Y/n] / [y/N] prompts, a free-text field for anything else (including yay's own menus). Your answer is written straight back to the process's stdin, so a "Proceed with installation?", a "pkgA and pkgB are in conflict, remove pkgB?", or a "Diffs to show?" from yay is something you can actually answer instead of a hard failure or a hang.

Passwords get separate handling. yay shells out to plain sudo (not pkexec) for an AUR build's final install step, so Anvil runs yay with --sudoflags=-A and points SUDO_ASKPASS at a small helper script it writes per-run rather than a system askpass dialog: when sudo invokes it, it connects back to a Unix socket the server opened just for that transaction, the password prompt is relayed into the browser and rendered as a masked field in the same transaction drawer, and the typed password is written back down that socket for sudo to consume.

As a backstop, any other prompt that mentions a password, or that arrives while the program has turned terminal echo off (as sudo and pkexec's text-mode agent do), gets the same masked field. Either way the password is never written to disk, logged, or echoed into the transaction log — it only ever exists in the server's memory and the browser tab for the moment it takes to relay it.

Why "Apply" always does a full upgrade when any update is checked

Arch explicitly does not support partial upgrades — installing some sync-DB packages while leaving others behind can break dependency resolution in ways that are hard to undo. So rather than quietly doing something Arch itself warns against, Anvil always runs a full pacman -Syu if you've enabled the "Upgrade all" toggle for pending repo updates, with any new packages you've selected in that same transaction. Updates can't be picked individually for the same reason — each update section is an all-or-nothing toggle, not a per-package checklist.

The same rule shapes two other things. "Check for updates" uses checkupdates, which syncs a private copy of the databases, rather than pacman -Sy, which would leave the real ones ahead of what's installed. And if something else has left them that way, installing a package is refused until you've upgraded. A package may fail to download if your databases are old enough that mirrors no longer carry that version; upgrading fixes that too.

Notes and known limitations

  • This is a prototype built for one machine, one user, listening only on 127.0.0.1 — it is not hardened for exposing on a network.
  • Closing or reloading the tab mid-transaction hangs up the running command. pacman finishes a commit that's already underway, but the tab can't reattach to it.
  • AUR helper support is yay-specific; if you use paru or another helper instead, the AUR panels will report yay as missing.
  • Manual keyring refresh (Refresh keyring button) only covers pacman-key --refresh-keys + resyncing archlinux-keyring. It won't help if your keyring is broken badly enough that pacman can't even verify that package — at that point you're into manual pacman-key --init territory, outside what a GUI button can safely automate.

Development

python -m venv venv && source venv/bin/activate
pip install -e '.[test]'
pytest

The tests never touch your real package manager: every command is a stub script on PATH, run through the real pseudo-terminal code.

See CHANGELOG.md for version history.

About

A modern, user-friendly package manager for Arch Linux.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages