[Feature Request] Add support for `Termux/pkg`
rami3l opened this issue · 2 comments
As requested by @itsaleph:
I'd personally like to see support for Termux's pkg PM, which is essentially a wrapper around apt.
apt list
lists all packages available unless--installed
was passed.pkg
instead of thelist
command have two separatelist-all
(acts likeapt list
) andlist-installed
(self-describing).apt
has both--help
flag andhelp
command, whereaspkg
only has command. Additionally,pkg
doesn't have man pages.pkg
doesn't have theautoremove
command (onlyautoclean
).pkg
doesn't have thefull-upgrade
command.pkg upgrade
instead always asks user what to do in case of a conflict (i suspect this behaviour is the same asapt upgrade
, but not sure since i never used it).pkg
doesn't havesatisfy
andedit-sources
commands.pkg
has several command shortcuts likepkg in
instead ofpkg install
andpkg rm
instead ofpkg remove
.Termux Wiki article on package management in Termux, including what is
pkg
and why it is (highly) recommended overapt
.If i understand correctly, the only thing missing from
pkg
support is that it should be preferred overapt
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
).
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 It seems that Termux actually provides a container for testing purposes: https://github.com/termux/termux-docker.pkg
's source code and some guesswork.
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.
@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 whenselect-mirror
is called. This leaves us with a few commands to support:apt install
apt search
apt update
(I choose not to care aboutapt upgrade
since you would usually perform anupdate
manually withpacman
before performing anupgrade
anyways.)
-
More interestingly,
pkg
has apacman
mode!How do you think me might handle the case where
$TERMUX_APP_PACKAGE_MANAGER
or$TERMUX_MAIN_PACKAGE_FORMAT
is set topacman
(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
isapt
$TERMUX_MAIN_PACKAGE_FORMAT
isdebian
- If so, I'll replace all
apt
usages in the command above withpkg
.