rami3l / pacaptr

Pacman-like syntax wrapper for many package managers.

Home Page:https://crates.io/crates/pacaptr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Add support for `Termux/pkg`

rami3l opened this issue · comments

commented

As requested by @itsaleph:

#142 (comment)

I'd personally like to see support for Termux's pkg PM, which is essentially a wrapper around apt.

#142 (comment)

  • apt list lists all packages available unless --installed was passed. pkg instead of the list command have two separate list-all (acts like apt list) and list-installed (self-describing).
  • apt has both --help flag and help command, whereas pkg only has command. Additionally, pkg doesn't have man pages.
  • pkg doesn't have the autoremove command (only autoclean).
  • pkg doesn't have the full-upgrade command. pkg upgrade instead always asks user what to do in case of a conflict (i suspect this behaviour is the same as apt upgrade, but not sure since i never used it).
  • pkg doesn't have satisfy and edit-sources commands.
  • pkg has several command shortcuts like pkg in instead of pkg install and pkg rm instead of pkg remove.

Termux Wiki article on package management in Termux, including what is pkg and why it is (highly) recommended over apt.

If i understand correctly, the only thing missing from pkg support is that it should be preferred over apt by pacaptr if running inside Termux ($HOME or $PREFIX start with /data/data/com.termux/ or one of the following variables are defined: TERMUX_VERSION, TERMUX_IS_DEBUGGABLE_BUILD, TERMUX_MAIN_PACKAGE_FORMAT, TERMUX_API_VERSION, TERMUX_APK_RELEASE, TERMUX_APP_PID).

commented

From the Termux Wiki: Package Mangement page, it seems to me that for the moment pkg only supports the following commands:

Command Description
pkg install Install a package.
pkg uninstall Uninstall a package.
pkg upgrade Upgrade installed package(s).
pkg autoclean Remove outdated .deb files from the cache.
pkg clean Remove all .deb files from the cache.
pkg files List files installed by specified package.
pkg list-all List all available packages.
pkg list-installed List currently installed packages.
pkg reinstall Re-install specified package.
pkg search Search package by query.
pkg show Show information about specific package.

Since I don't currently have a Termux environment for testing, if I'll be adding support for Termux, I will only be able to perform my greatest efforts based on pkg's source code and some guesswork. It seems that Termux actually provides a container for testing purposes: https://github.com/termux/termux-docker.


I'm reluctant to build a wrapper on top of a wrapper, and since most features have already been included in pacaptr, e.g. apt list --installed, I'd like to keep them as-is.

However, given that pkg also:

  • Automatically runs "apt update" before installing a package if necessary.
  • Performs some client side repository load-balancing by automatically switching mirrors on a regular basis. That is important to prevent us hitting quota limit on hosting.

My initial plan is to support install/upgrade/uninstall/reinstall with pkg, which should be a reasonable compromise. Of course this list might also be subject to change if I have found something interesting after digging into pkg's source code.

commented

@ItsAleph Hi again! I took my time to do some more research about Termux, here's what I've found:

  • It turns out that pkg's source code is extremely simple, it just passes all parameters transparently to the underlying package manager.

    We don't really care about abbreviations, since pacaptr has done just that. What we really care is when select-mirror is called. This leaves us with a few commands to support:

    • apt install
    • apt search
    • apt update (I choose not to care about apt upgrade since you would usually perform an update manually with pacman before performing an upgrade anyways.)
  • More interestingly, pkg has a pacman mode!

    How do you think me might handle the case where $TERMUX_APP_PACKAGE_MANAGER or $TERMUX_MAIN_PACKAGE_FORMAT is set to pacman (termux/termux-packages#10460)? Thanks!


On my side, I now expect the business logic to be the following:

  • Check if one of the following conditions are met:
    • $TERMUX_APP_PACKAGE_MANAGER is apt
    • $TERMUX_MAIN_PACKAGE_FORMAT is debian
  • If so, I'll replace all apt usages in the command above with pkg.