Skip to content
Snippets Groups Projects
Commit 92aed6ea authored by Dylan Aïssi's avatar Dylan Aïssi
Browse files

apertis-pkg-pull-updates: add mirror to snapshot.debian.org as a fallback


Sometime the main server of snapshot.debian.org is not sync
which block us from downloading new packages from Debian.
Thus to avoid depending on a single server add a mirror
as fallback.

Signed-off-by: default avatarDylan Aïssi <dylan.aissi@collabora.com>
parent adfc9d2a
No related branches found
No related tags found
3 merge requests!82Merge changes from apertis/v2024-updates into apertis/v2024,!76Backport v2024 <- v2025dev3: apertis-pkg-pull-updates: add mirror to snapshot.debian.org as a fallback,!75apertis-pkg-pull-updates: add mirror to snapshot.debian.org as a fallback
......@@ -200,8 +200,11 @@ def should_update(upstream_suite, package_name, local_version, missing_is_fatal=
return remote_version
return None
def get_remote_dsc_path(package_name, version):
url = 'https://snapshot.debian.org/mr/package/{}/{}/srcfiles?fileinfo=1'.format(package_name, version)
def get_remote_dsc_path(package_name, version, mirror=False):
if not mirror:
url = 'https://snapshot.debian.org/mr/package/{}/{}/srcfiles?fileinfo=1'.format(package_name, version)
else:
url = 'https://snapshot-mlm-01.debian.org/mr/package/{}/{}/srcfiles?fileinfo=1'.format(package_name, version)
print('fetch', url)
with urllib.request.urlopen(url) as response:
data = json.loads(response.read().decode('utf-8'))
......@@ -279,7 +282,14 @@ def main():
remote_version = should_update(suite, package_name, local_version, upstream_suite==suite)
if remote_version:
print('update to', remote_version)
dsc = re.sub(r'/debian/*', '/', mirror) + '/' + get_remote_dsc_path(package_name, remote_version)
try:
remote_dsc_path = get_remote_dsc_path(package_name, remote_version)
except urllib.error.HTTPError:
print('⚠️ Fail to get dsc from main snapshot.debian.org, trying from a mirror')
remote_dsc_path = get_remote_dsc_path(package_name, remote_version, mirror=True)
dsc = re.sub(r'/debian/*', '/', mirror) + '/' + remote_dsc_path
print('download', dsc)
with tempfile.TemporaryDirectory(prefix='pull-updates') as tmpdir:
local_dsc = get_remote_sources(dsc, tmpdir)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment