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
- Variables
- func Compare(a, b string) int
- func ContentsFile(arch string) string
- func Dist(mirror, file string) string
- func Either(group []Relation) string
- func InRelease(mirror string) string
- func Install(names ...string) string
- func Keys(keyrings ...[]byte) (openpgp.EntityList, error)
- func LibraryFiles(paths []string) []string
- func Machine(arch string) (elf.Machine, bool)
- func OriginPath(path string) string
- func PackagesFile(arch string) string
- func Pool(mirror, filename string) string
- func ReadList(r io.Reader) []string
- func ReadMirror(r io.Reader) (string, int)
- func ReadPacmanDesc(r io.Reader) (string, string)
- func ReadPacmanFiles(r io.Reader) []string
- func ReadPublic(r io.Reader, bits int) []string
- func ReadSources(r io.Reader) []string
- func ReadStatus(r io.Reader) (map[string]string, error)
- func Relations(field string) ([][]Relation, error)
- func Relocate(data []byte, runpath string) ([]byte, bool, error)
- type Contents
- type Device
- type File
- type Files
- type Index
- type Object
- type Opener
- type Package
- type Plan
- type Refusal
- type Relation
- type Release
- type Stanza
Constants ¶
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
const ( Suite = "stable" Component = "main" )
Suite and component of the repository, as its release names them
const MaxFuture = 10 * time.Second
Most a release may be dated ahead of the clock, apt's default for Acquire::Max-FutureTime
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)
const Prefix = "/data/data/com.termux/files/usr"
Folder Termux installs its programs, libraries and settings into, which PREFIX names in its shells
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 ¶
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
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 ¶
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 ¶
Path of the index of contents of an architecture in the release
func Either ¶
Alternatives of one group of a relation field as a control file writes them, joined by a pipe
func Install ¶
Line a user 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 ¶
Library files of a list of files, by name: those directly in the prefix's lib folder
func OriginPath ¶
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 ¶
Path of the index of packages of an architecture in the release, the compressed one Termux publishes
func ReadList ¶
Files of a dpkg file list (info/<package>.list): one path a line, a trailing slash dropped
func ReadMirror ¶
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 ¶
Name and version of a package as the desc file of pacman's local database records it
func ReadPacmanFiles ¶
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 ¶
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 ¶
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 ¶
Packages dpkg's status file records as on disk, by name, at their versions
func Relations ¶
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 ¶
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 ¶
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
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 Files ¶
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
type Object ¶
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, otherwise DT_RPATH), and the processor it is built for
type Opener ¶
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
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
// Wanted lists packages from the taken packages' Depends fields that the phone's Termux lacks and that do not supply any library the
// taken packages need. A user installs them. They are never taken, because nothing in icebath's folder would read them.
Wanted []string
// Stranded lists the taken packages' ELF files, by package, that need libraries besides Android's but do not set a library search
// folder, so they run from icebath's folder only when their libraries are already loaded.
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 ¶
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, otherwise 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; otherwise 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 ¶
Why a closure can't be had, in words, and the line a user types in Termux to install its own build instead, empty when that would not help either
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
type Release ¶
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 ¶
The release a Release text states, as it is, its signature checked elsewhere
type Stanza ¶
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