enforce E501 in pmb/config (MR 2058)

This commit is contained in:
Caio Fontes 2021-05-19 16:24:52 -03:00 committed by Oliver Smith
parent fb98ad5329
commit f3b3fe906b
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
4 changed files with 43 additions and 25 deletions

View File

@ -79,7 +79,8 @@ defaults = {
"ccache_size": "5G", "ccache_size": "5G",
"is_default_channel": True, "is_default_channel": True,
"cipher": "aes-xts-plain64", "cipher": "aes-xts-plain64",
"config": (os.environ.get('XDG_CONFIG_HOME') or os.path.expanduser("~/.config")) + "/pmbootstrap.cfg", "config": os.environ.get('XDG_CONFIG_HOME') or
((os.path.expanduser("~/.config")) + "/pmbootstrap.cfg"),
"device": "qemu-amd64", "device": "qemu-amd64",
"extra_packages": "none", "extra_packages": "none",
"fork_alpine": False, "fork_alpine": False,
@ -521,10 +522,11 @@ flashers = {
"boot", "$BOOT/boot.img-$FLAVOR"]], "boot", "$BOOT/boot.img-$FLAVOR"]],
}, },
}, },
# Some devices provide Fastboot but using Android boot images is not practical # Some devices provide Fastboot but using Android boot images is not
# for them (e.g. because they support booting from FAT32 partitions directly # practical for them (e.g. because they support booting from FAT32
# and/or the Android boot partition is too small). This can be implemented # partitions directly and/or the Android boot partition is too small).
# using --split (separate image files for boot and rootfs). # This can be implemented using --split (separate image files for boot and
# rootfs).
# This flasher allows flashing the split image files using Fastboot. # This flasher allows flashing the split image files using Fastboot.
"fastboot-bootpart": { "fastboot-bootpart": {
"split": True, "split": True,
@ -567,7 +569,8 @@ flashers = {
["heimdall", "flash", "--$PARTITION_SYSTEM", "$IMAGE"]], ["heimdall", "flash", "--$PARTITION_SYSTEM", "$IMAGE"]],
"flash_kernel": [ "flash_kernel": [
["heimdall_wait_for_device.sh"], ["heimdall_wait_for_device.sh"],
["heimdall", "flash", "--$PARTITION_KERNEL", "$BOOT/boot.img-$FLAVOR"]], ["heimdall", "flash", "--$PARTITION_KERNEL",
"$BOOT/boot.img-$FLAVOR"]],
"flash_vbmeta": [ "flash_vbmeta": [
["avbtool", "make_vbmeta_image", "--flags", "2", ["avbtool", "make_vbmeta_image", "--flags", "2",
"--padding_size", "$FLASH_PAGESIZE", "--padding_size", "$FLASH_PAGESIZE",
@ -660,8 +663,10 @@ newapkbuild_arguments_switches_other = [
# #
# UPGRADE # UPGRADE
# #
# Patterns of package names to ignore for automatic pmaport upgrading ("pmbootstrap aportupgrade --all") # Patterns of package names to ignore for automatic pmaport upgrading
upgrade_ignore = ["device-*", "firmware-*", "linux-*", "postmarketos-*", "*-aarch64", "*-armhf", "*-armv7"] # ("pmbootstrap aportupgrade --all")
upgrade_ignore = ["device-*", "firmware-*", "linux-*", "postmarketos-*",
"*-aarch64", "*-armhf", "*-armv7"]
# #
# SIDELOAD # SIDELOAD

View File

@ -137,7 +137,8 @@ def ask_for_ui_extras(args, ui):
if extra is None: if extra is None:
return False return False
logging.info("This user interface has an extra package: " + extra["pkgdesc"]) logging.info("This user interface has an extra package: " +
extra["pkgdesc"])
return pmb.helpers.cli.confirm(args, "Enable this package?", return pmb.helpers.cli.confirm(args, "Enable this package?",
default=args.ui_extras) default=args.ui_extras)
@ -179,7 +180,8 @@ def ask_for_timezone(args):
pass pass
if tz: if tz:
logging.info("Your host timezone: " + tz) logging.info("Your host timezone: " + tz)
if pmb.helpers.cli.confirm(args, "Use this timezone instead of GMT?", if pmb.helpers.cli.confirm(args,
"Use this timezone instead of GMT?",
default="y"): default="y"):
return tz return tz
logging.info("WARNING: Unable to determine timezone configuration on host," logging.info("WARNING: Unable to determine timezone configuration on host,"
@ -267,7 +269,8 @@ def ask_for_device_nonfree(args, device):
subpkgname = "device-" + device + "-nonfree-" + type subpkgname = "device-" + device + "-nonfree-" + type
subpkg = apkbuild["subpackages"].get(subpkgname, {}) subpkg = apkbuild["subpackages"].get(subpkgname, {})
if subpkg is None: if subpkg is None:
raise RuntimeError("Cannot find subpackage function for " + subpkgname) raise RuntimeError("Cannot find subpackage function for "
f"{subpkgname}")
if subpkg: if subpkg:
logging.info(subpkgname + ": " + subpkg["pkgdesc"]) logging.info(subpkgname + ": " + subpkg["pkgdesc"])
ret[type] = pmb.helpers.cli.confirm(args, "Enable this package?", ret[type] = pmb.helpers.cli.confirm(args, "Enable this package?",
@ -302,10 +305,11 @@ def ask_for_device(args):
continue continue
else: else:
# Unmaintained devices can be selected, but are not displayed # Unmaintained devices can be selected, but are not displayed
devices = sorted(pmb.helpers.devices.list_codenames(args, vendor, unmaintained=False)) devices = sorted(pmb.helpers.devices.list_codenames(
args, vendor, unmaintained=False))
# Remove "vendor-" prefixes from device list # Remove "vendor-" prefixes from device list
codenames = [x.split('-', 1)[1] for x in devices] codenames = [x.split('-', 1)[1] for x in devices]
logging.info("Available codenames (" + str(len(codenames)) + "): " + logging.info(f"Available codenames ({len(codenames)}): " +
", ".join(codenames)) ", ".join(codenames))
if current_vendor != vendor: if current_vendor != vendor:
@ -387,11 +391,13 @@ def ask_for_additional_options(args, cfg):
# Ccache size # Ccache size
logging.info("We use ccache to speed up building the same code multiple" logging.info("We use ccache to speed up building the same code multiple"
" times. How much space should the ccache folder take up per" " times. How much space should the ccache folder take up per"
" architecture? After init is through, you can check the current" " architecture? After init is through, you can check the"
" usage with 'pmbootstrap stats'. Answer with 0 for infinite.") " current usage with 'pmbootstrap stats'. Answer with 0 for"
" infinite.")
regex = "0|[0-9]+(k|M|G|T|Ki|Mi|Gi|Ti)" regex = "0|[0-9]+(k|M|G|T|Ki|Mi|Gi|Ti)"
answer = pmb.helpers.cli.ask(args, "Ccache size", None, args.ccache_size, answer = pmb.helpers.cli.ask(args, "Ccache size", None, args.ccache_size,
lowercase_answer=False, validation_regex=regex) lowercase_answer=False,
validation_regex=regex)
cfg["pmbootstrap"]["ccache_size"] = answer cfg["pmbootstrap"]["ccache_size"] = answer
# Sudo timer # Sudo timer
@ -408,7 +414,8 @@ def ask_for_additional_options(args, cfg):
def ask_for_hostname(args, device): def ask_for_hostname(args, device):
while True: while True:
ret = pmb.helpers.cli.ask(args, "Device hostname (short form, e.g. 'foo')", ret = pmb.helpers.cli.ask(args,
"Device hostname (short form, e.g. 'foo')",
None, (args.hostname or device), True) None, (args.hostname or device), True)
if not pmb.helpers.other.validate_hostname(ret): if not pmb.helpers.other.validate_hostname(ret):
continue continue
@ -422,7 +429,8 @@ def ask_for_ssh_keys(args):
if not len(glob.glob(os.path.expanduser("~/.ssh/id_*.pub"))): if not len(glob.glob(os.path.expanduser("~/.ssh/id_*.pub"))):
return False return False
return pmb.helpers.cli.confirm(args, return pmb.helpers.cli.confirm(args,
"Would you like to copy your SSH public keys to the device?", "Would you like to copy your SSH public"
" keys to the device?",
default=args.ssh_keys) default=args.ssh_keys)
@ -514,7 +522,8 @@ def frontend(args):
cfg["pmbootstrap"]["aports"] = args.aports cfg["pmbootstrap"]["aports"] = args.aports
# Build outdated packages in pmbootstrap install # Build outdated packages in pmbootstrap install
cfg["pmbootstrap"]["build_pkgs_on_install"] = str(ask_build_pkgs_on_install(args)) cfg["pmbootstrap"]["build_pkgs_on_install"] = str(
ask_build_pkgs_on_install(args))
# Save config # Save config
pmb.config.save(args, cfg) pmb.config.save(args, cfg)
@ -522,7 +531,9 @@ def frontend(args):
# Zap existing chroots # Zap existing chroots
if (work_exists and device_exists and if (work_exists and device_exists and
len(glob.glob(args.work + "/chroot_*")) and len(glob.glob(args.work + "/chroot_*")) and
pmb.helpers.cli.confirm(args, "Zap existing chroots to apply configuration?", default=True)): pmb.helpers.cli.confirm(
args, "Zap existing chroots to apply configuration?",
default=True)):
setattr(args, "deviceinfo", pmb.parse.deviceinfo(args, device=device)) setattr(args, "deviceinfo", pmb.parse.deviceinfo(args, device=device))
# Do not zap any existing packages or cache_http directories # Do not zap any existing packages or cache_http directories

View File

@ -20,12 +20,13 @@ def load(args):
# We used to save default values in the config, which can *not* be # We used to save default values in the config, which can *not* be
# configured in "pmbootstrap init". That doesn't make sense, we always # configured in "pmbootstrap init". That doesn't make sense, we always
# want to use the defaults from pmb/config/__init__.py in that case, not # want to use the defaults from pmb/config/__init__.py in that case,
# some outdated version we saved some time back (eg. aports folder, # not some outdated version we saved some time back (eg. aports folder,
# postmarketOS binary packages mirror). # postmarketOS binary packages mirror).
if key not in pmb.config.config_keys and key in cfg["pmbootstrap"]: if key not in pmb.config.config_keys and key in cfg["pmbootstrap"]:
logging.debug("Ignored unconfigurable and possibly outdated default" logging.debug("Ignored unconfigurable and possibly outdated"
" value from config: " + str(cfg["pmbootstrap"][key])) " default value from config:"
f" {cfg['pmbootstrap'][key]}")
del cfg["pmbootstrap"][key] del cfg["pmbootstrap"][key]
return cfg return cfg

View File

@ -6,7 +6,8 @@ import pmb.config
def merge_with_args(args): def merge_with_args(args):
""" """
We have the internal config (pmb/config/__init__.py) and the user config We have the internal config (pmb/config/__init__.py) and the user config
(usually ~/.config/pmbootstrap.cfg, can be changed with the '-c' parameter). (usually ~/.config/pmbootstrap.cfg, can be changed with the '-c'
parameter).
Args holds the variables parsed from the commandline (e.g. -j fills out Args holds the variables parsed from the commandline (e.g. -j fills out
args.jobs), and values specified on the commandline count the most. args.jobs), and values specified on the commandline count the most.