From 25d3c2ce0ee6f074dfe39eba513aac2bddeee8b9 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Jan 28 2022 17:51:34 +0000 Subject: [PATCH 1/2] lookaside: fix undefined DownloadError traceback --- diff --git a/rpkglib/lookaside_cache.py b/rpkglib/lookaside_cache.py index 0a38152..64c257f 100644 --- a/rpkglib/lookaside_cache.py +++ b/rpkglib/lookaside_cache.py @@ -51,7 +51,7 @@ class LookasideCache(object): try: result_url = self.download_url % subs except Exception as e: - raise DownloadError( + raise RpkgError( 'Could not get download url from %s template. ' 'Original error: %s.' % (self.download_url, str(e))) From 76c284e9ea647b0e300187d545f20e0addd1376c Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Jan 28 2022 17:51:34 +0000 Subject: [PATCH 2/2] lookaside: define %(ns) and %(name)s This is useful for clone_urls of forks, like: https://src.fedoraproject.org/forks/praiskup/rpms/passwd.git We can configure Fedora Copr to download files just from %(ns1)/%(name) (rpms/passwd) instead of full path (forks/praiskup/rpms/passwd) which doesn't exist in lookaside cache. Merges: #38 --- diff --git a/rpkglib/lookaside_cache.py b/rpkglib/lookaside_cache.py index 64c257f..c65454e 100644 --- a/rpkglib/lookaside_cache.py +++ b/rpkglib/lookaside_cache.py @@ -48,6 +48,15 @@ class LookasideCache(object): 'hash': hash, } subs.update(kwargs) + + repo_path_parts = subs['repo_path'].split('/') + subs['name'] = repo_path_parts[-1] + ns_index = 1 + for part in reversed(repo_path_parts[:-1]): + key = 'ns'+str(ns_index) + subs[key] = part + ns_index += 1 + try: result_url = self.download_url % subs except Exception as e: