allow specifying multiple postmarketOS mirrors (!1718)

Multiple -mp arguments can be used to list multiple mirrors:
$ pmbootstrap -mp=first -mp=second chroot -- cat /etc/apk/repositories

This is needed for the new build infrastructure, so we can have a WIP
repository to which we push packages until all of them are up to date,
and then publish all of them at once. Software like KDE/Plasma Mobile,
which expect a lot of packages to be updated from one version to
another will not end up with a half-way through upgrade that way.
This commit is contained in:
Oliver Smith 2018-11-19 08:36:49 +01:00
parent a92e6a89d0
commit a5a64158e9
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
5 changed files with 35 additions and 12 deletions

View File

@ -76,7 +76,7 @@ defaults = {
"keymap": "",
"log": "$WORK/log.txt",
"mirror_alpine": "http://dl-cdn.alpinelinux.org/alpine/",
"mirror_postmarketos": "http://postmarketos.brixit.nl",
"mirrors_postmarketos": ["http://postmarketos.brixit.nl"],
"nonfree_firmware": True,
"nonfree_userland": False,
"port_distccd": "33632",

View File

@ -82,6 +82,26 @@ import pmb.config
"""
def fix_mirrors_postmarketos(args):
""" Fix args.mirrors_postmarketos when it is supposed to be empty or the
default value.
In pmb/parse/arguments.py, we set the -mp/--mirror-pmOS argument to
action="append" and start off with an empty list. That way, users can
specify multiple custom mirrors by specifying -mp multiple times on the
command line. Here we fix the default and no mirrors case.
NOTE: we don't use nargs="+", because it does not play nicely with
subparsers: <https://bugs.python.org/issue9338> """
# -mp not specified: use default mirrors
if not args.mirrors_postmarketos:
args.mirrors_postmarketos = pmb.config.defaults["mirrors_postmarketos"]
# -mp="": use no postmarketOS mirrors (build everything locally)
if args.mirrors_postmarketos == [""]:
args.mirrors_postmarketos = []
def check_pmaports_path(args):
""" Make sure that args.aports exists when it was overridden by --aports.
Without this check, 'pmbootstrap init' would start cloning the
@ -134,6 +154,7 @@ def add_deviceinfo(args):
def init(args):
# Basic initialization
fix_mirrors_postmarketos(args)
pmb.config.merge_with_args(args)
replace_variables(args)
add_shortcuts(args)

View File

@ -76,9 +76,9 @@ def auto_apkindex_files(args):
if os.path.exists(local):
ret[arch].append(local)
if args.mirror_postmarketos:
for mirror in args.mirrors_postmarketos:
path = (args.work + "/cache_apk_" + arch + "/APKINDEX." +
pmb.helpers.repo.hash(args.mirror_postmarketos) + ".tar.gz")
pmb.helpers.repo.hash(mirror) + ".tar.gz")
ret[arch].append(path)
return ret

View File

@ -67,8 +67,9 @@ def urls(args, user_repository=True, postmarketos_mirror=True):
ret.append("/mnt/pmbootstrap-packages")
# Upstream postmarketOS binary repository
if postmarketos_mirror and args.mirror_postmarketos:
ret.append(args.mirror_postmarketos)
if postmarketos_mirror:
for mirror in args.mirrors_postmarketos:
ret.append(mirror)
# Upstream Alpine Linux repositories
directories = ["main", "community"]
@ -93,9 +94,9 @@ def apkindex_files(args, arch=None):
# Upstream postmarketOS binary repository
urls_todo = []
mirror = args.mirror_postmarketos
if mirror:
urls_todo.append(mirror)
for mirror in args.mirrors_postmarketos:
if mirror:
urls_todo.append(mirror)
# Resolve the APKINDEX.$HASH.tar.gz files
urls_todo += urls(args, False, False)

View File

@ -260,6 +260,7 @@ def arguments():
parser = argparse.ArgumentParser(prog="pmbootstrap")
arch_native = pmb.parse.arch.alpine_native()
arch_choices = set(pmb.config.build_device_architectures + [arch_native])
mirrors_pmos_default = pmb.config.defaults["mirrors_postmarketos"]
# Other
parser.add_argument("-V", "--version", action="version",
@ -269,11 +270,11 @@ def arguments():
parser.add_argument("-c", "--config", dest="config",
default=pmb.config.defaults["config"])
parser.add_argument("-d", "--port-distccd", dest="port_distccd")
parser.add_argument("-mp", "--mirror-pmOS", dest="mirror_postmarketos",
parser.add_argument("-mp", "--mirror-pmOS", dest="mirrors_postmarketos",
help="postmarketOS mirror, disable with: -mp='',"
" default: " +
pmb.config.defaults["mirror_postmarketos"],
metavar="URL")
" specify multiple with: -mp='one' -mp='two',"
" default: " + ", ".join(mirrors_pmos_default),
metavar="URL", action="append", default=[])
parser.add_argument("-m", "--mirror-alpine", dest="mirror_alpine",
help="Alpine Linux mirror, default: " +
pmb.config.defaults["mirror_alpine"],