aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-29 20:22:02 -0600
committerMelody Horn <melody@boringcactus.com>2021-03-29 20:22:02 -0600
commit3fbdd8c97383df4a67c75a0cc9405d5349854e9b (patch)
tree6909c9828bd0ebc51feae4ade0636df622554243
parentfaee70554a0e18f15676ba850d584f2d3e990c97 (diff)
downloadwhere-packaged-3fbdd8c97383df4a67c75a0cc9405d5349854e9b.tar.gz
where-packaged-3fbdd8c97383df4a67c75a0cc9405d5349854e9b.zip
ubuntu
-rw-r--r--repos/__init__.py3
-rw-r--r--repos/debian.py2
-rw-r--r--repos/ubuntu.py122
3 files changed, 125 insertions, 2 deletions
diff --git a/repos/__init__.py b/repos/__init__.py
index e5e4f98..eb70711 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, debian, homebrew
+from . import alpine_linux, arch_linux, crates_io, debian, homebrew, ubuntu
from .base import Repository, slug, Version
__all__ = [
@@ -19,6 +19,7 @@ all_repos: List[Repository] = [
*repos_from(crates_io),
*repos_from(debian),
*repos_from(homebrew),
+ *repos_from(ubuntu),
]
def get_versions(package: str, args: Mapping[str, str]) -> Mapping[str, Version]:
diff --git a/repos/debian.py b/repos/debian.py
index 6ad93fd..db93b2e 100644
--- a/repos/debian.py
+++ b/repos/debian.py
@@ -20,7 +20,7 @@ __all__ = [
'testing_non_free_amd64',
]
-PACKAGE_REVISION_INFO = re.compile(r'(\+\w+)?-\d+$')
+PACKAGE_REVISION_INFO = re.compile(r'(\+\w+)*-\d+$')
def parse_cached(cached: Path) -> Mapping[str, Version]:
result = dict()
diff --git a/repos/ubuntu.py b/repos/ubuntu.py
new file mode 100644
index 0000000..f1a02d2
--- /dev/null
+++ b/repos/ubuntu.py
@@ -0,0 +1,122 @@
+import gzip
+from pathlib import Path
+import re
+from typing import Mapping
+
+from .base import Repository, Version
+
+__all__ = [
+ 'focal_main_amd64',
+ 'focal_restricted_amd64',
+ 'focal_universe_amd64',
+ 'focal_multiverse_amd64',
+
+ 'focal_updates_main_amd64',
+ 'focal_updates_restricted_amd64',
+ 'focal_updates_universe_amd64',
+ 'focal_updates_multiverse_amd64',
+
+ 'focal_backports_main_amd64',
+ 'focal_backports_restricted_amd64',
+ 'focal_backports_universe_amd64',
+ 'focal_backports_multiverse_amd64',
+
+ 'focal_security_main_amd64',
+ 'focal_security_restricted_amd64',
+ 'focal_security_universe_amd64',
+ 'focal_security_multiverse_amd64',
+
+ 'groovy_main_amd64',
+ 'groovy_restricted_amd64',
+ 'groovy_universe_amd64',
+ 'groovy_multiverse_amd64',
+
+ 'groovy_updates_main_amd64',
+ 'groovy_updates_restricted_amd64',
+ 'groovy_updates_universe_amd64',
+ 'groovy_updates_multiverse_amd64',
+
+ 'groovy_backports_main_amd64',
+ 'groovy_backports_restricted_amd64',
+ 'groovy_backports_universe_amd64',
+ 'groovy_backports_multiverse_amd64',
+
+ 'groovy_security_main_amd64',
+ 'groovy_security_restricted_amd64',
+ 'groovy_security_universe_amd64',
+ 'groovy_security_multiverse_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'http://archive.ubuntu.com/ubuntu/dists/{dist}/{section}/binary-{arch}/Packages.gz'
+ return Repository(
+ family='Ubuntu',
+ repo=name,
+ index_url=url,
+ parse=parse_cached,
+ )
+
+focal_main_amd64 = build_repo('20.04 Focal (main/amd64)', 'focal', 'main', 'amd64')
+focal_restricted_amd64 = build_repo('20.04 Focal (restricted/amd64)', 'focal', 'restricted', 'amd64')
+focal_universe_amd64 = build_repo('20.04 Focal (universe/amd64)', 'focal', 'universe', 'amd64')
+focal_multiverse_amd64 = build_repo('20.04 Focal (multiverse/amd64)', 'focal', 'multiverse', 'amd64')
+
+focal_updates_main_amd64 = build_repo('20.04 Focal Updates (main/amd64)', 'focal-updates', 'main', 'amd64')
+focal_updates_restricted_amd64 = build_repo('20.04 Focal Updates (restricted/amd64)', 'focal-updates', 'restricted', 'amd64')
+focal_updates_universe_amd64 = build_repo('20.04 Focal Updates (universe/amd64)', 'focal-updates', 'universe', 'amd64')
+focal_updates_multiverse_amd64 = build_repo('20.04 Focal Updates (multiverse/amd64)', 'focal-updates', 'multiverse', 'amd64')
+
+focal_backports_main_amd64 = build_repo('20.04 Focal Backports (main/amd64)', 'focal-backports', 'main', 'amd64')
+focal_backports_restricted_amd64 = build_repo('20.04 Focal Backports (restricted/amd64)', 'focal-backports', 'restricted', 'amd64')
+focal_backports_universe_amd64 = build_repo('20.04 Focal Backports (universe/amd64)', 'focal-backports', 'universe', 'amd64')
+focal_backports_multiverse_amd64 = build_repo('20.04 Focal Backports (multiverse/amd64)', 'focal-backports', 'multiverse', 'amd64')
+
+focal_security_main_amd64 = build_repo('20.04 Focal Updates (main/amd64)', 'focal-security', 'main', 'amd64')
+focal_security_restricted_amd64 = build_repo('20.04 Focal Updates (restricted/amd64)', 'focal-security', 'restricted', 'amd64')
+focal_security_universe_amd64 = build_repo('20.04 Focal Updates (universe/amd64)', 'focal-security', 'universe', 'amd64')
+focal_security_multiverse_amd64 = build_repo('20.04 Focal Updates (multiverse/amd64)', 'focal-security', 'multiverse', 'amd64')
+
+groovy_main_amd64 = build_repo('20.10 Groovy (main/amd64)', 'groovy', 'main', 'amd64')
+groovy_restricted_amd64 = build_repo('20.10 Groovy (restricted/amd64)', 'groovy', 'restricted', 'amd64')
+groovy_universe_amd64 = build_repo('20.10 Groovy (universe/amd64)', 'groovy', 'universe', 'amd64')
+groovy_multiverse_amd64 = build_repo('20.10 Groovy (multiverse/amd64)', 'groovy', 'multiverse', 'amd64')
+
+groovy_updates_main_amd64 = build_repo('20.10 Groovy Updates (main/amd64)', 'groovy-updates', 'main', 'amd64')
+groovy_updates_restricted_amd64 = build_repo('20.10 Groovy Updates (restricted/amd64)', 'groovy-updates', 'restricted', 'amd64')
+groovy_updates_universe_amd64 = build_repo('20.10 Groovy Updates (universe/amd64)', 'groovy-updates', 'universe', 'amd64')
+groovy_updates_multiverse_amd64 = build_repo('20.10 Groovy Updates (multiverse/amd64)', 'groovy-updates', 'multiverse', 'amd64')
+
+groovy_backports_main_amd64 = build_repo('20.10 Groovy Backports (main/amd64)', 'groovy-backports', 'main', 'amd64')
+groovy_backports_restricted_amd64 = build_repo('20.10 Groovy Backports (restricted/amd64)', 'groovy-backports', 'restricted', 'amd64')
+groovy_backports_universe_amd64 = build_repo('20.10 Groovy Backports (universe/amd64)', 'groovy-backports', 'universe', 'amd64')
+groovy_backports_multiverse_amd64 = build_repo('20.10 Groovy Backports (multiverse/amd64)', 'groovy-backports', 'multiverse', 'amd64')
+
+groovy_security_main_amd64 = build_repo('20.10 Groovy Updates (main/amd64)', 'groovy-security', 'main', 'amd64')
+groovy_security_restricted_amd64 = build_repo('20.10 Groovy Updates (restricted/amd64)', 'groovy-security', 'restricted', 'amd64')
+groovy_security_universe_amd64 = build_repo('20.10 Groovy Updates (universe/amd64)', 'groovy-security', 'universe', 'amd64')
+groovy_security_multiverse_amd64 = build_repo('20.10 Groovy Updates (multiverse/amd64)', 'groovy-security', 'multiverse', 'amd64')