- Python 99.4%
- Shell 0.6%
|
All checks were successful
Formatting check / check_formatting (alt-sisyphus) (push) Successful in 28s
- First build for Sisyphus. |
||
|---|---|---|
| .forgejo/workflows | ||
| .gear | ||
| .githooks | ||
| src | ||
| .gitignore | ||
| LICENSE | ||
| pyproject.toml | ||
| README.md | ||
apt-source
apt-source is a lightweight Python library and command-line tool for working with apt-rpm repository entries (sources.list, vendors.list).
The project provides:
- a clean object-oriented API for working with APT sources and vendors
- a CLI interface built strictly on top of the API
- stable, content-based identifiers for entries
- pseudo-atomic persistence to the filesystem
Project Architecture
The project is strictly divided into two modules:
api→ domain logic and filesystem abstractioncli→ user-facing command-line interface
High-level Dependency Diagram
┌────────────┐
│ cli │
│ (commands) │
└─────┬──────┘
│
▼
┌────────────────┐
│ api.Database │ ← central API object
└─────┬─────┬────┘
│ │
┌───────────┘ └───────────┐
▼ ▼
┌───────────────────┐ ┌───────────────────┐
│ sources.Repository│ │ vendors.Repository│
└──────┬────────────┘ └──────┬────────────┘
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ sources.Table│ │ vendors.Table│
└──────┬───────┘ └──────┬───────┘
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ sources.Entry│ │ vendors.Entry│
└──────────────┘ └──────────────┘
Submodule api.source
Entry
api.sources.Entry represents APT-RPM repo line from sources lists as program entity and can be parsed from string and back.
Table
api.sources.Table represents string content of sources file as container of entries (api.sources.Entry) indexed by ID.
The ID is constructed from significant entry fields (everything except vendor sign and enabling status).
Entry also corresponds to line number in file content. Table can be parsed from string and back. Invalid entries are not included in table. Commented entries are included in table as disabled.
Tables supports adding and removing entries. Changing entry contents also supported.
Repository
api.sources.Repository is functional entity over file system and includes mapping sources.list files to
api.sources.Table examples. It supports transactional saving changes to file system.
Repositories supports adding and removing tables by file paths.
Submodule api.vendors
The submodule includes analog entities (but read-only yet) for vendors.list.
High-level API
api.Database composes api.sources.Repository and api.vendors.Repository, building relationship
between sign field from api.sources.Entry and entry as api.vendors.Entry.
Installation
sudo apt-get install apt-source
Usage
API
Example usage:
from apt_source.api import Database
from apt_source.api import sources
db = Database()
db.load()
entry = sources.Entry(type="rpm", sign=None, uri="https://urg.org/pub", suite="example/suite/x86_64", components=["classic", "debuginfo"], enabled=True)
db.sources.add(entry)
entry = sources.Entry.from_string("rpm https://uri.org/pub example/suite/noarch classic")
db.sources.add(entry)
db.sign(source_id=source_id, vendor_id="alt")
db.save()
Use help(...) for more details.
CLI
Example usage:
apt-source list
sudo apt-source add "# rpm https://example.org stable main"
sudo apt-source enable ab12f
sudo apt-source disable ab12f
sudo apt-source sign ab12f alt
Use apt-source --help for more details.
Project Status
The project is under active development. API, CLI and implementation details may evolve.