aboutsummaryrefslogtreecommitdiff
path: root/repos/alpine_linux.py
diff options
context:
space:
mode:
Diffstat (limited to 'repos/alpine_linux.py')
-rw-r--r--repos/alpine_linux.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/repos/alpine_linux.py b/repos/alpine_linux.py
index 64f159a..7c646cc 100644
--- a/repos/alpine_linux.py
+++ b/repos/alpine_linux.py
@@ -1,9 +1,10 @@
from io import TextIOWrapper
from pathlib import Path
+import re
import tarfile
from typing import Mapping, TextIO
-from .base import Repository
+from .base import Repository, Version
__all__ = [
'stable_main_x86_64',
@@ -13,7 +14,9 @@ __all__ = [
'edge_testing_x86_64',
]
-def parse_apkindex(apkindex: TextIO) -> Mapping[str, str]:
+PACKAGE_REVISION_INFO = re.compile(r'-r\d+$')
+
+def parse_apkindex(apkindex: TextIO) -> Mapping[str, Version]:
result = dict()
current_package = None
current_version = None
@@ -37,14 +40,16 @@ def parse_apkindex(apkindex: TextIO) -> Mapping[str, str]:
elif line_type == 'P':
current_package = line_data
elif line_type == 'V':
- current_version = line_data
+ version = line_data
+ clean_version = PACKAGE_REVISION_INFO.sub('', version)
+ current_version = Version(version, clean_version)
elif line_type in ignore_lines:
pass
else:
raise ValueError('unknown line type: ' + line_type + ' in line ' + repr(line))
return result
-def parse_cached(cached: Path) -> Mapping[str, str]:
+def parse_cached(cached: Path) -> Mapping[str, Version]:
apkindex = tarfile.open(cached)
for archive_member in apkindex.getmembers():
if archive_member.name == 'APKINDEX':
@@ -52,7 +57,7 @@ def parse_cached(cached: Path) -> Mapping[str, str]:
apkindex_file = TextIOWrapper(apkindex_file)
return parse_apkindex(apkindex_file)
-def build_repo(name: str, url_path: str):
+def build_repo(name: str, url_path: str) -> Repository:
url = f'http://dl-cdn.alpinelinux.org/alpine/{url_path}/APKINDEX.tar.gz'
return Repository(
family='Alpine Linux',