Add ability to ignore arches, and skip 404 updateinfos

This commit is contained in:
Mustafa Gezen 2023-02-04 10:13:20 +01:00
parent d157846fb7
commit bb0d22c63c
Signed by untrusted user who does not match committer: mustafa
GPG Key ID: DCDF010D946438C1
1 changed files with 27 additions and 4 deletions

View File

@ -34,6 +34,7 @@ async def scan_path(
base_path: str, base_path: str,
fmt: str, fmt: str,
ignore_repos: list[str], ignore_repos: list[str],
ignore_arches: list[str],
): ):
""" """
Scan base path for repositories Scan base path for repositories
@ -68,9 +69,15 @@ async def scan_path(
current_parts = parts current_parts = parts
if repo_first: if repo_first:
repo_name = directory repo_name = directory
if repo_name in ignore_repos:
logger.info("Ignoring repo: %s", repo_name)
continue
logger.info("Found repo: %s", repo_name) logger.info("Found repo: %s", repo_name)
else: else:
arch = directory arch = directory
if arch in ignore_arches:
logger.info("Ignoring arch: %s", arch)
continue
logger.info("Found arch: %s", arch) logger.info("Found arch: %s", arch)
repo_base = os.path.join(root, directory) repo_base = os.path.join(root, directory)
@ -120,8 +127,6 @@ async def scan_path(
} }
if repo_name not in repos: if repo_name not in repos:
repos[repo_name] = [] repos[repo_name] = []
if repo_name not in ignore_repos:
repos[repo_name].append(repo)
return repos return repos
@ -140,9 +145,13 @@ async def fetch_updateinfo_from_apollo(
logger.info("Fetching updateinfo from %s", api_url) logger.info("Fetching updateinfo from %s", api_url)
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.get(api_url) as resp: async with session.get(api_url) as resp:
if resp.status != 200: if resp.status != 200 and resp.status != 404:
logger.error("Failed to fetch updateinfo from %s", api_url) logger.warning(
"Failed to fetch updateinfo from %s, skipping", api_url
)
return None return None
if resp.status != 200:
raise Exception(f"Failed to fetch updateinfo from {api_url}")
return await resp.text() return await resp.text()
@ -284,6 +293,7 @@ async def run_apollo_tree(
auto_scan: bool, auto_scan: bool,
path: str, path: str,
ignore: list[str], ignore: list[str],
ignore_arch: list[str],
product_name: str, product_name: str,
): ):
if manual: if manual:
@ -294,6 +304,7 @@ async def run_apollo_tree(
path, path,
base_format, base_format,
ignore, ignore,
ignore_arch,
) )
for _, repo_variants in repos.items(): for _, repo_variants in repos.items():
@ -302,6 +313,9 @@ async def run_apollo_tree(
repo, repo,
product_name, product_name,
) )
if not updateinfo:
logger.warning("No updateinfo found for %s", repo["name"])
continue
gzipped = await gzip_updateinfo(updateinfo) gzipped = await gzip_updateinfo(updateinfo)
await write_updateinfo_to_file( await write_updateinfo_to_file(
@ -360,6 +374,14 @@ if __name__ == "__main__":
default=[], default=[],
help="Repos to ignore in auto-scan mode", help="Repos to ignore in auto-scan mode",
) )
parser.add_argument(
"-x",
"--ignore-arch",
nargs="+",
action="append",
default=[],
help="Arches to ignore in auto-scan mode",
)
parser.add_argument( parser.add_argument(
"-n", "-n",
"--product-name", "--product-name",
@ -384,6 +406,7 @@ if __name__ == "__main__":
p_args.auto_scan, p_args.auto_scan,
p_args.path, p_args.path,
[y for x in p_args.ignore for y in x], [y for x in p_args.ignore for y in x],
[y for x in p_args.ignore_arch for y in x],
p_args.product_name, p_args.product_name,
) )
) )