* Weight-based mirror selection: do not give each mirror same usage ratio as hosts have different properties.
* Rotate mirrors after 6h: pkg now checks usability of all mirrors before selecting one, this takes time but we may want to reduce delays before the actual `apt` operation will be started.
* Update apt cache after 20min: reduce amount of necessary package list queries. We even can go with 1h, but since we prefer origin repository over mirrors as download source, 20 minutes should be fine.
* Avoid long lines.
* Add missing info for some commands.
* Do not show deb cache size if its size cannot be determined, for example if cache dir was deleted.
The openssl code is unmaintained [1] and I get errors about
certificate verification failure on one of my emails ("TLS certificate
verification failed: the certificate owner does not match
hostname"). With gnutls everything works.
[1] https://marlam.de/msmtp/news/openssl-discouraged
See https://github.com/termux/termux-packages/issues/5620.
Implements automatic mirror selection:
* Pick a random URL of top 4 mirrors of Termux main repository and use it during 30 minutes limit, then rotate to a new one. Distribute traffic accross multiple mirrors, including origin Bintray repository.
* During 30 minutes limit, let `pkg` to check whether mirror is accessible on each run. If mirror is not accessible, use a new one. Mirrors are not guaranteed to be 100% accessible, so let pkg to check which one is working before using `apt`.
* Skip rotating if using `.cn` mirrors - Chinese users will not want to use something else due to great firewall and download speed issues.