aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--repos/__init__.py3
-rw-r--r--repos/debian.py69
2 files changed, 71 insertions, 1 deletions
diff --git a/repos/__init__.py b/repos/__init__.py
index 005dcf8..e5e4f98 100644
--- a/repos/__init__.py
+++ b/repos/__init__.py
@@ -1,6 +1,6 @@
from typing import Mapping, List
-from . import alpine_linux, arch_linux, crates_io, homebrew
+from . import alpine_linux, arch_linux, crates_io, debian, homebrew
from .base import Repository, slug, Version
__all__ = [
@@ -17,6 +17,7 @@ all_repos: List[Repository] = [
*repos_from(alpine_linux),
*repos_from(arch_linux),
*repos_from(crates_io),
+ *repos_from(debian),
*repos_from(homebrew),
]
diff --git a/repos/debian.py b/repos/debian.py
new file mode 100644
index 0000000..6ad93fd
--- /dev/null
+++ b/repos/debian.py
@@ -0,0 +1,69 @@
+import gzip
+from pathlib import Path
+import re
+from typing import Mapping
+
+from .base import Repository, Version
+
+__all__ = [
+ 'buster_main_all',
+ 'buster_main_amd64',
+ 'buster_contrib_all',
+ 'buster_contrib_amd64',
+ 'buster_non_free_all',
+ 'buster_non_free_amd64',
+ 'testing_main_all',
+ 'testing_main_amd64',
+ 'testing_contrib_all',
+ 'testing_contrib_amd64',
+ 'testing_non_free_all',
+ 'testing_non_free_amd64',
+]
+
+PACKAGE_REVISION_INFO = re.compile(r'(\+\w+)?-\d+$')
+
+def parse_cached(cached: Path) -> Mapping[str, Version]:
+ result = dict()
+ with gzip.open(cached, mode='rt') as file:
+ this_package = None
+ this_version = None
+ for line in file:
+ line = line.strip()
+ pieces = line.split(': ', 1)
+ if len(pieces) != 2:
+ continue
+ line_type, line_data = pieces
+ if line_type == 'Package':
+ this_package = line_data
+ elif line_type == 'Version':
+ this_version = line_data
+
+ if this_package is not None and this_version is not None:
+ clean_version = PACKAGE_REVISION_INFO.sub('', this_version)
+ result[this_package] = Version(this_version, clean_version)
+ this_version = None
+ this_package = None
+ return result
+
+def build_repo(name: str, dist: str, section: str, arch: str = 'all') -> Repository:
+ url = f'https://deb.debian.org/debian/dists/{dist}/{section}/binary-{arch}/Packages.gz'
+ return Repository(
+ family='Debian',
+ repo=name,
+ index_url=url,
+ parse=parse_cached,
+ )
+
+buster_main_all = build_repo('10 - Buster (main)', 'buster', 'main')
+buster_main_amd64 = build_repo('10 - Buster (main/amd64)', 'buster', 'main', 'amd64')
+buster_contrib_all = build_repo('10 - Buster (contrib)', 'buster', 'contrib')
+buster_contrib_amd64 = build_repo('10 - Buster (contrib/amd64)', 'buster', 'contrib', 'amd64')
+buster_non_free_all = build_repo('10 - Buster (non-free)', 'buster', 'non-free')
+buster_non_free_amd64 = build_repo('10 - Buster (non-free/amd64)', 'buster', 'non-free', 'amd64')
+
+testing_main_all = build_repo('Testing (main)', 'testing', 'main')
+testing_main_amd64 = build_repo('Testing (main/amd64)', 'testing', 'main', 'amd64')
+testing_contrib_all = build_repo('Testing (contrib)', 'testing', 'contrib')
+testing_contrib_amd64 = build_repo('Testing (contrib/amd64)', 'testing', 'contrib', 'amd64')
+testing_non_free_all = build_repo('Testing (non-free)', 'testing', 'non-free')
+testing_non_free_amd64 = build_repo('Testing (non-free/amd64)', 'testing', 'non-free', 'amd64')