Skip to main content

apt-mirror Python reimplementation

Project description

apt-mirror2

apt-mirror2 is the Python/asyncio reimplementation of the apt-mirror developed as drop-in replacement for the latest.
This project should be suitable as general apt-mirror replacement.

One of the main advantages of the apt-mirror2 over the apt-mirror - you should never got broken mirror in case apt-mirror2 returns 0 exit code. This is ensured by data integrity checks at all stages of mirroring.

Requirements

Python 3.10 is the minimum supported version. PyPy 3.10 (7.3) is supported also.
For additional dependencies look to the pyproject.yml and/or requirements.txt.

Installation

Container (Docker/Podman)

Container images are available in the Docker Hub under aptmirror/apt-mirror2 repository and in the Red Hat Quay.io inder apt-mirror2/apt-mirror2 repository.

You can try it using

docker run -it --rm docker.io/aptmirror/apt-mirror2 --help

or

docker run -it --rm quay.io/apt-mirror2/apt-mirror2 --help

You may wish to use podman command instead of docker.

Image variants

aptmirror/apt-mirror2:latest

aptmirror/apt-mirror2:<version>

Images based on debian:stable image.

aptmirror/apt-mirror2:slim

aptmirror/apt-mirror2:<version>-slim

Images based on debian:stable-slim image.

aptmirror/apt-mirror2:alpine

aptmirror/apt-mirror2:<version>-alpine

Images based on alpine:3 image.

PyPi

PyPi package is available with the name apt-mirror:

pip install apt-mirror
apt-mirror --help

Debian and Ubuntu packages

Debian (bookworm, trixie) and Ubuntu (22.04, 24.04) packages are available in the Packagecloud repository.

Quick automated repository setup:

curl -s https://packagecloud.io/install/repositories/nE0sIghT/apt-mirror2/script.deb.sh | sudo bash

Package installation:

sudo apt-get install apt-mirror2

For manual steps please look to the Packagecloud repository.

Build from source with virtualenv

It's possible to use apt-mirror2 from a virtualenv:

# Let's work in the home folder
cd

# Create virtualenv
virtualenv ~/venv/apt-mirror2
source ~/venv/apt-mirror2/bin/activate

# Clone apt-mirror2 source code
git clone https://gitlab.com/apt-mirror2/apt-mirror2
cd apt-mirror2

# Install requirements
pip install -r requirements.txt

# Install apt-mirror2 into virtualenv
python setup.py install

apt-mirror --help

Usage

As the drop-in replacement for the apt-mirror this project supports same CLI syntax.

usage: apt-mirror [-h] [--version] [configfile]

positional arguments:
  configfile  Path to config file. Default /etc/apt/mirror.list

options:
  -h, --help  show this help message and exit
  --version   Show version

apt-mirror compatibility

Most of apt-mirror configuration directives are supported.
As of now proxy for FTP repositories is not supported.

File lists (ALL, NEW, MD5, SHA256, SHA512) are not written by default, but you can enable them with the write_file_lists option.

In addition there are some enhancements available:

  • Repositories without MD5 hashsums are correctly mirrored
  • Old index files are properly cleaned and don't produces errors in mirror processing
  • Standard source.list [ arch=arch1,arch2 ] can be used to specify multiple repository architectures for mirroring.
  • multiple codenames (or flat folders) can be specified using comma as delimiter.
  • mirror_path URL PATH option may be used to specify PATH to use for saving mirror files instead of path that is generated from URL.
  • Additional configuration is loaded from the *.list files in the directory named same as configfile with the .d suffix. Eg /etc/apt/mirror.list.d/*.list.
  • Rate limit is enforced for overall download rate.
  • Slow download rate protection is enabled by default and can be configured via mirror.list.
  • Non-zero exit code is returned if some of required files were not downloaded due to network or server errors or no repositories were configured.
  • HTTP user agent can be configured via user_agent configuration.
  • Configuration variables are exposed to postmirror_script.
  • by-hash list option can be used to control whether Acquire-By-Hash Release option should be respected or enforced.
  • mirror wipe protection is available and configurable via wipe_size_ratio and wipe_count_ratio settings.
  • per-repository log files are available in the var_path folder
  • dists folder is almost atomicaly replaced using move instead of copy/link
  • native Prometheus metrics are supported

License

GNU General Public License v3.0 or later

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apt_mirror-10.post1.tar.gz (509.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apt_mirror-10.post1-py3-none-any.whl (65.7 kB view details)

Uploaded Python 3

File details

Details for the file apt_mirror-10.post1.tar.gz.

File metadata

  • Download URL: apt_mirror-10.post1.tar.gz
  • Upload date:
  • Size: 509.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for apt_mirror-10.post1.tar.gz
Algorithm Hash digest
SHA256 159986933c48a26acaedcc336f5f8e0038a3155572faf97613aff0b55439984e
MD5 3873ca745d73dcf3e5cc5a1a3fbc6fe5
BLAKE2b-256 5f9b35e05a71f19defa834c6cc450801b258e64358a377562c9a4a79b0e53125

See more details on using hashes here.

File details

Details for the file apt_mirror-10.post1-py3-none-any.whl.

File metadata

  • Download URL: apt_mirror-10.post1-py3-none-any.whl
  • Upload date:
  • Size: 65.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for apt_mirror-10.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 a956f5493c2819462e66783bbc5cbb3757ef85cc676a775f0fff2e9af484ba88
MD5 65901e48fad253af71fd43aa2e1a56ff
BLAKE2b-256 eb5bd7954d96de848bb352bd9d6525a43a8c3b8ee8dfdef5241de9f7c8c74b14

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page