APT-RPM Source Manager
  • Python 99.4%
  • Shell 0.6%
Find a file
Maria Alexeeva 6e3bd4c9eb
All checks were successful
Formatting check / check_formatting (alt-sisyphus) (push) Successful in 28s
0.1.0-alt1
- First build for Sisyphus.
2026-05-14 13:49:38 +04:00
.forgejo/workflows chore: add YAPF formatting setup 2026-05-07 15:16:46 +03:00
.gear 0.1.0-alt1 2026-05-14 13:49:38 +04:00
.githooks chore: only format and stage Python files that are actually staged 2026-05-13 22:30:54 +03:00
src style: format Python files with YAPF 2026-05-07 15:16:47 +03:00
.gitignore chore: remove .* pattern from .gitignore 2026-03-30 14:29:43 +04:00
LICENSE init: initial commit 2025-12-12 12:43:43 +04:00
pyproject.toml chore: add YAPF formatting setup 2026-05-07 15:16:46 +03:00
README.md docs: describe entities in readme 2026-02-20 12:50:26 +04:00

apt-source

License Language Platform

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 abstraction
  • cli → 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.