termux

package
v2.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Termux, the Linux userland of Android, as a source of programs: its apt repository read as apt reads it (the signed release, the index of packages, the index of contents, the archives), what the Termux of a phone holds already, the libraries Android gives apps, and the closure of the libraries a program needs, worked out from all of them and from the program's own ELF files

Index

Constants

View Source
const (
	Upstream = "https://packages.termux.dev/apt/termux-main"
	Default  = "https://packages-cf.termux.dev/apt/termux-main"
)

Where Termux's own repository is served: the server it is published on, and the mirror termux-tools names as the default, which caches that server

View Source
const (
	Suite     = "stable"
	Component = "main"
)

Suite and component of the repository, as its release names them

View Source
const MaxFuture = 10 * time.Second

Most a release may be dated ahead of the clock, apt's default for Acquire::Max-FutureTime

View Source
const Origin = "${ORIGIN}"

The text Android's linker reads as the folder of the ELF file itself in a library path (from API level 24, Termux's floor)

View Source
const Prefix = "/data/data/com.termux/files/usr"

Folder Termux installs its programs, libraries and settings into, which PREFIX names in its shells

View Source
const Root = "data/data/com.termux/files/usr"

The same folder as the members of Termux's archives and the lines of its contents index name it, without the leading slash

Variables

View Source
var Arches = map[string]string{"arm64": "aarch64", "arm": "arm", "amd64": "x86_64", "386": "i686"}

Architecture of Termux's packages for each processor as Go names it; Termux builds for these four alone

View Source
var Public = []string{"libandroid.so", "libaaudio.so", "libamidi.so", "libbinder_ndk.so", "libc.so", "libcamera2ndk.so", "libdl.so", "libEGL.so",
	"libGLESv1_CM.so", "libGLESv2.so", "libGLESv3.so", "libicu.so", "libicui18n.so", "libicuuc.so", "libjnigraphics.so", "liblog.so",
	"libmediandk.so", "libm.so", "libnativehelper.so", "libnativewindow.so", "libneuralnetworks.so", "libOpenMAXAL.so", "libOpenSLES.so",
	"libRS.so", "libstdc++.so", "libsync.so", "libvulkan.so", "libwebviewchromium_plat_support.so", "libz.so"}

Libraries of AOSP's list of public libraries (platform/system/core, rootdir/etc/public.libraries.android.txt), which Android installs as /system/etc/public.libraries.txt: what an app may load when the phone's own lists can't be read

Functions

func Compare

func Compare(a, b string) int

Order of two Debian versions as dpkg orders them, [epoch:]upstream[-revision]: negative when a is older than b, zero when they are the same, positive when it is newer. Epochs compare as numbers; the upstream versions, then the revisions (none being 0), compare part by part: the text before the next digit with letters before every other character and a tilde before anything, even the end, then the digits as a number

func ContentsFile

func ContentsFile(arch string) string

Path of the index of contents of an architecture in the release

func Dist

func Dist(mirror, file string) string

Address of a file of the release, such as an index, under a mirror

func Either

func Either(group []Relation) string

Alternatives of one group of a relation field as a control file writes them, joined by a pipe

func InRelease

func InRelease(mirror string) string

Address of the signed release of a mirror of the repository

func Install

func Install(names ...string) string

Line a person types in Termux to install its own build of the packages, in the words of the system's installers

func Keys

func Keys(keyrings ...[]byte) (openpgp.EntityList, error)

The keys apt trusts, from the keyrings given (OpenPGP public keys, binary as termux-keyring installs them, or armored as apt takes them too); a keyring that does not read is left out, and none that reads is an error

func LibraryFiles

func LibraryFiles(paths []string) []string

Library files of a list of files, by name: those directly in the prefix's lib folder

func Machine

func Machine(arch string) (elf.Machine, bool)

Processor of an architecture of Termux, false for one Termux builds nothing for

func OriginPath

func OriginPath(path string) string

Library path of an ELF file at a path under the prefix that leads from its own folder to the prefix's lib folder: ${ORIGIN}/../lib for bin/python3, ${ORIGIN} for lib/libz.so.1, ${ORIGIN}/../.. for lib/python3.14/lib-dynload/zlib.so

func PackagesFile

func PackagesFile(arch string) string

Path of the index of packages of an architecture in the release, the compressed one Termux publishes

func Pool

func Pool(mirror, filename string) string

Address of an archive under a mirror, by the Filename its index gives it

func ReadList

func ReadList(r io.Reader) []string

Files of a dpkg file list (info/<package>.list): one path a line, a trailing slash dropped

func ReadMirror

func ReadMirror(r io.Reader) (string, int)

The mirror of the main repository a mirror file of termux-tools names ("MAIN=" a quoted address, as pkg sources it), and its weight

func ReadPacmanDesc

func ReadPacmanDesc(r io.Reader) (string, string)

Name and version of a package as the desc file of pacman's local database records it

func ReadPacmanFiles

func ReadPacmanFiles(r io.Reader) []string

Files of a package as the files file of pacman's local database lists them, each as an absolute path, directories left out

func ReadPublic

func ReadPublic(r io.Reader, bits int) []string

Libraries a list of public libraries names for a process of the bitness given (32 or 64): a library a line, perhaps followed by 32 or 64 when it is there for one bitness alone and by nopreload; comments after #

func ReadSources

func ReadSources(r io.Reader) []string

Addresses apt's sources name, in order: the address of each "deb" line of a sources.list, its options in brackets skipped, and of each "URIs:" field of a .sources file

func ReadStatus

func ReadStatus(r io.Reader) (map[string]string, error)

Packages dpkg's status file records as on disk, by name, at their versions

func Relations

func Relations(field string) ([][]Relation, error)

Groups of alternatives of a field such as Depends: commas read as and, pipes as or, binding tighter. An architecture qualifier after a colon and the restrictions in brackets or angle brackets are dropped, as Termux builds one architecture per index; the operators < and > are read as <= and >=, as dpkg reads them

func Relocate

func Relocate(data []byte, runpath string) ([]byte, bool, error)

The bytes of an ELF file with every library path it names (DT_RUNPATH and DT_RPATH) rewritten in place to runpath, the rest of the old text's room filled with zeros; false when it names none. Refused when the new path is longer than the old, or when another name of the file is read from within the old path, as rewriting it would change that name too

Types

type Contents

type Contents map[string][]string

Packages shipping each file of the prefix's lib folder, by the file's name: what the contents index of the repository says of the libraries

func ReadContents

func ReadContents(r io.Reader) (Contents, error)

Libraries of a contents index ("FILE LOCATION" first, then a path and the packages shipping it, comma separated, each perhaps after its section and a slash): the files directly in the prefix's lib folder

type Device

type Device struct {
	// Packages installed in the prefix, by name, at their versions
	Installed map[string]string
	// Files of the prefix's lib folder by name, with the package owning each, empty for a file no package owns
	Libraries map[string]string
	// Libraries Android lets an app load, by file name
	System map[string]bool
}

What the Termux of a phone holds toward a program's closure, and what Android gives every app

type File

type File struct {
	SHA256 string
	Size   int64
}

One file a release names

type Files

type Files struct {
	Libraries []string
	Objects   map[string]Object
}

One archive of the repository as a closure reads it: the files it puts directly into the prefix's lib folder, and each of its ELF files by its path under the prefix, such as bin/python3.14

type Index

type Index struct {
	Arch     string
	Packages map[string]Package
	// contains filtered or unexported fields
}

The repository's packages of one architecture, and the packages that provide each virtual name

func ReadIndex

func ReadIndex(r io.Reader, arch string) (*Index, error)

Packages of an index file of the repository (the Packages of one architecture), the newest of a name kept when it lists several; a stanza without its name, version, archive or SHA-256 is refused, as apt could not fetch it

func (*Index) Meeting

func (x *Index) Meeting(r Relation) []Package

Packages of the index that meet a relation: the package of its name at a version it takes, then those providing it at a version it takes (one providing it without a version meets a relation that asks for none), by name

type Object

type Object struct {
	Needed  []string
	Soname  string
	Runpath []string
	Machine elf.Machine
}

What an ELF file asks of Android's dynamic linker: the libraries it needs, its own name as a library, the folders it names to look for libraries in (DT_RUNPATH, else DT_RPATH), and the processor it is built for

func ReadObject

func ReadObject(r io.ReaderAt) (Object, bool, error)

What an ELF file asks, false for a file that is no ELF file

type Opener

type Opener func(p Package) (Files, error)

Reads the archive of a package of the repository, fetched and checked by its SHA-256, for a closure

type Package

type Package struct {
	Name, Version, Arch string
	Depends, PreDepends [][]Relation
	Provides            []Relation
	// Path of its archive under a mirror, its size and its SHA-256 in lower case hex
	Filename string
	Size     int64
	SHA256   string
}

One package of the repository's index of an architecture

func (Package) Needs

func (p Package) Needs() [][]Relation

What must be there before it: its Pre-Depends, then its Depends

type Plan

type Plan struct {
	Arch string
	// The program's package first, then every package taken with it, in the order the closure reached them
	Take []Package
	// Libraries of each package past the first that something taken needs, which is why it is taken
	For map[string][]string
	// Libraries Android gives apps that something taken needs
	System []string
	// Libraries something taken needs that the phone's Termux has from a current package, by file name, with the package owning each (empty
	// for a file no package owns)
	Linked map[string]string
	// Packages the Depends of the packages taken name that they need no library of and that the phone's Termux lacks, as a person installs
	// them: never taken, as nothing would read them in icebath's folder
	Wanted []string
	// ELF files of the packages taken, by package, that need libraries besides Android's and name no folder to find them in, so they run
	// from icebath's folder only when what they need is loaded already
	Stranded map[string][]string
	// ELF files of the packages taken built for another processor, by package, which nothing here loads
	Foreign map[string][]string
}

The closure of a program on a phone: what is taken from the repository, and what it finds elsewhere

func Close

func Close(index *Index, contents Contents, device Device, root string, open Opener) (*Plan, error)

The closure of the program a package of the repository holds, on a phone as the device describes it. The package's Depends and Pre-Depends are followed to their end first, through the repository where the phone lacks what they name (alternatives: the first the phone has, else the first the repository has; virtual names through Provides; every version relation honoured; a cycle ended where it closes). Then each archive taken is read through open, and every library its ELF files need is found, in order: in an archive taken; among Android's; in the phone's Termux, from a package installed at the repository's version or newer, or from a file no package owns; else in the package of the repository that ships it by the contents index, one the Depends reach first, which is taken and read in turn, until nothing new is needed

type Refusal

type Refusal struct {
	Reason  string
	Install string
}

Why a closure can't be had, in words, and the line a person types in Termux to install its own build instead, empty when that would not help either

func (*Refusal) Error

func (r *Refusal) Error() string

type Relation

type Relation struct {
	Name string
	// <<, <=, =, >= or >>, empty for any version
	Op      string
	Version string
}

One package a relation names, with the version it asks for when it asks one

func (Relation) String

func (r Relation) String() string

The relation as a control file writes it

func (Relation) Takes

func (r Relation) Takes(version string) bool

Whether a version of the package the relation names meets it

type Release

type Release struct {
	Date       time.Time
	ValidUntil time.Time
	Arches     []string
	Files      map[string]File
}

The release of a repository as its InRelease states it once its signature checks: when it was made and, when it says so, until when it may be taken, the architectures it serves and the files of its indexes with their SHA-256 and size, by their path under dists/<suite>

func ReadRelease

func ReadRelease(text []byte) (*Release, error)

The release a Release text states, as it is, its signature checked elsewhere

func Signed

func Signed(inRelease []byte, keys openpgp.KeyRing) (*Release, error)

The release a clearsigned InRelease states, refused unless a key of the ring signed exactly that text

func (*Release) Current

func (r *Release) Current(now time.Time) error

Why the release can't be taken at the time given, nil when it can: past the Valid-Until it names, or dated further ahead of the clock than MaxFuture, both of which apt refuses

type Stanza

type Stanza map[string]string

One paragraph of a control file, such as a package of an index or of dpkg's status: its fields by name in lower case, a field folded over several lines kept with its lines joined by newlines

func Stanzas

func Stanzas(r io.Reader) ([]Stanza, error)

Paragraphs of a control file as Debian's policy writes them: a field "Name: value", its continuation lines starting with a space or a tab, paragraphs apart by blank lines

func (Stanza) Field

func (s Stanza) Field(name string) string

Value of a field, its name in any case

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL