From 5a256f66de6e68d37bc4ef695db1a937b83b2c47 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Mon, 13 Apr 2020 01:16:52 +0200 Subject: [PATCH] pmb.helpers.pkgrel_bump.auto_apkindex_files: remove (MR 1912) Replace the call to this function with the almost identical pmb.helpers.repo.apkindex_files(), so release channel related changes only need to be done in one place. --- pmb/helpers/pkgrel_bump.py | 27 ++------------------------- pmb/helpers/repo.py | 31 ++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/pmb/helpers/pkgrel_bump.py b/pmb/helpers/pkgrel_bump.py index 74bddc06..68c2473a 100644 --- a/pmb/helpers/pkgrel_bump.py +++ b/pmb/helpers/pkgrel_bump.py @@ -1,7 +1,6 @@ # Copyright 2020 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later import logging -import os import pmb.helpers.file import pmb.helpers.pmaports @@ -44,29 +43,6 @@ def package(args, pkgname, reason="", dry=False): path) -def auto_apkindex_files(args): - """ - Get the paths to the APKINDEX files, that need to be analyzed, sorted by - arch. Relevant are the local pmbootstrap generated APKINDEX as well as the - APKINDEX from the pmOS binary repo. - - :returns: {"armhf": "...../APKINDEX.tar.gz", ...} - """ - pmb.helpers.repo.update(args) - ret = {} - for arch in pmb.config.build_device_architectures: - ret[arch] = [] - local = args.work + "/packages/" + arch + "/APKINDEX.tar.gz" - if os.path.exists(local): - ret[arch].append(local) - - for mirror in args.mirrors_postmarketos: - path = (args.work + "/cache_apk_" + arch + "/APKINDEX." + - pmb.helpers.repo.hash(mirror) + ".tar.gz") - ret[arch].append(path) - return ret - - def auto_apkindex_package(args, arch, aport, apk, dry=False): """ Bump the pkgrel of a specific package if it is outdated in the given @@ -127,7 +103,8 @@ def auto(args, dry=False): :returns: list of aport names, where the pkgrel needed to be changed """ ret = [] - for arch, paths in auto_apkindex_files(args).items(): + for arch in pmb.config.build_device_architectures: + paths = pmb.helpers.repo.apkindex_files(args, arch, alpine=False) for path in paths: logging.info("scan " + path) index = pmb.parse.apkindex.parse(args, path, False) diff --git a/pmb/helpers/repo.py b/pmb/helpers/repo.py index 0e6e1800..ec1cdbce 100644 --- a/pmb/helpers/repo.py +++ b/pmb/helpers/repo.py @@ -40,9 +40,14 @@ def hash(url, length=8): return ret -def urls(args, user_repository=True, postmarketos_mirror=True): +def urls(args, user_repository=True, postmarketos_mirror=True, alpine=True): """ Get a list of repository URLs, as they are in /etc/apk/repositories. + :param user_repository: add /mnt/pmbootstrap-packages + :param postmarketos_mirror: add postmarketos mirror URLs + :param alpine: add alpine mirror URLs + :returns: list of mirror strings, like ["/mnt/pmbootstrap-packages", + "http://...", ...] """ ret = [] @@ -70,28 +75,36 @@ def urls(args, user_repository=True, postmarketos_mirror=True): ret.append(f"{mirror}{mirrordir_pmos}") # Upstream Alpine Linux repositories - directories = ["main", "community"] - if mirrordir_alpine == "edge": - directories.append("testing") - for dir in directories: - ret.append(f"{args.mirror_alpine}{mirrordir_alpine}/{dir}") + if alpine: + directories = ["main", "community"] + if mirrordir_alpine == "edge": + directories.append("testing") + for dir in directories: + ret.append(f"{args.mirror_alpine}{mirrordir_alpine}/{dir}") return ret -def apkindex_files(args, arch=None): +def apkindex_files(args, arch=None, user_repository=True, pmos=True, + alpine=True): """ Get a list of outside paths to all resolved APKINDEX.tar.gz files for a specific arch. :param arch: defaults to native + :param user_repository: add path to index of locally built packages + :param pmos: add paths to indexes of postmarketos mirrors + :param alpine: add paths to indexes of alpine mirrors + :returns: list of absolute APKINDEX.tar.gz file paths """ if not arch: arch = args.arch_native + ret = [] # Local user repository (for packages compiled with pmbootstrap) - ret = [args.work + "/packages/" + arch + "/APKINDEX.tar.gz"] + if user_repository: + ret = [args.work + "/packages/" + arch + "/APKINDEX.tar.gz"] # Resolve the APKINDEX.$HASH.tar.gz files - for url in urls(args, False): + for url in urls(args, False, pmos, alpine): ret.append(args.work + "/cache_apk_" + arch + "/APKINDEX." + hash(url) + ".tar.gz")