In the last team meeting we decided it makes more sense to move the kconfig checks to pmaports.git. This avoids the problem we currently have, that when we require a new option in edge, the kconfig check will fail on stable unless we also change the kernels there.
As format we figured a json file from which we strip comments before parsing in python (as python's json parser doesn't handle comments), would make sense. Then it looks almost the same as the current format.
This file should also be added to v22.06, so kconfig check still works there. For earlier releases pmbootstrap kconfig check will break, but that's fine, these are EOL anyway. Let's print an error that the file is missing on that branch in pmaports in that case.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items 0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items 0
Link issues together to show that they're related.
Learn more.
currently we have pmbootstrap kconfig check --waydroid --nftables --iwd etc. arguments, one for each check component. this syntax needs to be reworked when moving the kconfig checks to pmaports since we only know the components after parsing the json file, not yet at the time when we parse the command-line arguments. we can probably change it to pmbootstrap kconfig check -c waydroid,iwd,nftables etc.
I'd name the file kconfig_checks.json and put it in the root of pmaports.git
besides the checks themselves, the json should have this information:
which components the "community" component implies
the enforce_check parameter, that is currently not set for devices in testing. TBH I think this was a mistake now, sorry for not realizing this earlier. After moving the kernel config checks to pmaports, let's make it so that we can enable the enforce_check paramter to address pmaports#1799 (closed) and not have print pmbootstrap kconfig check print misleading errors by default. For devices that don't pass it, we can either remove pmb:kconfig-check-community from the APKBUILD options, or we fix them up.
note that if we get #2190 done, it should be quite feasible to change a lot of kernels at once
JSON with comments doesn't seem to be that suitable, because:
In pure json you can't let the last item of an object end with a comma: {example: "value",}
This leads to unclean diffs as you always need to modify the line above the last one when adding a new line to add a comma there
And it's error prone because it's not intuitive that this is not allowed
(and of course comments are not allowed in json, but stripping them is feasible)
If we did something like json, we would basically need json5. But that would need an extra library for python, and pmbootstrap so far doesn't require any python libraries. So I don't think it's worth it.
an improved version of ini that python can do natively since 3.11. (currently we support all non-EOL versions of python3, which means >= 3.9, before that it needs a library)
but the format itself doesn't seem to be so suitable for our use case: it would make sense to have different sections for each category-versions-architectures combination. But object levels are split with dots, whereas our versions have dots (>=0.0.0), so it wouldn't split it right / need a workaround for that.
So I've arrived at the good old configparser library that python speaks natively, and which we already use in pmbootstrap code and in pmaports with pmaports.cfg, channels.cfg. It's like ini and has comments, and editors typically provide syntax highlighting for it (neovim and mediawiki highlight the sections in a different colors too, unfortunately gitlab doesn't do it).
Sections look like this:
[<category> <versions> <arches>]
category: "nftables", "containers" etc.
versions: in the format ">=0.0.0" or "<5.17" or ">=3.13.0,<5.17"
arches: in the format "all" or "x86_64" or "x86_64,aarch64"
Examples:
# this is a comment[nftables >=3.13.0 all]NETFILTER=trueNF_CONNTRACK=true[nftables >=3.13.0,<5.17 all]NFT_COUNTER=true[containers >=0.0.0 all]NAMESPACES=trueNET_NS=truePID_NS=trueIPC_NS=trueUTS_NS=trueCGROUPS=true[containers >=3.6 x86,x86_64]HUGETLB_PAGE=trueCGROUP_HUGETLB=true[containers >=3.6,<6.1_rc1 all]MEMCG_SWAP=true
Fully converted file of current pmbootstrap kconfig opts (+ Luca's patch to add usb options):
#!/usr/bin/env python3importsyssys.path.append("/home/user/code/pmbootstrap/")importpmb.configimportpmb.parse.kconfigdefprint_component(name,opts):forversioninopts.keys():forarchinopts[version].keys():section=namesection+=f"{version.replace('',',')}"section+=f"{arch.replace('',',')}"print(f"[{section}]")forkey,valinopts[version][arch].items():ifisinstance(val,list):val=str(val)elifisinstance(val,str):val=strelifvalin[True,False]:val="true"ifTrueelse"false"else:raiseRuntimeError(f"{key}: can't handle type of {val}")print(f"{key} = {val}")defprint_components():# NOTE: the postmarketOS component will be renamed to be more obvious, it has# the options that are required for all devices, no matter in which device categorycomponents_list=["postmarketOS"]+pmb.parse.kconfig.get_all_component_names()fornameincomponents_list:ifname=="postmarketOS":pmb_config_var="kconfig_options"else:pmb_config_var=f"kconfig_options_{name}"opts=getattr(pmb.config,pmb_config_var,None)assertopts,f"invalid kconfig component name: {name}"print_component(name,opts)print("")print_components()
I'm not 100% sure if storing arrays like the following is a good idea, that will become more obvious when adjusting the code to parse the ini file:
but the format itself doesn't seem to be so suitable for our use case: it would make sense to have different sections for each category-versions-architectures combination. But object levels are split with dots, whereas our versions have dots (>=0.0.0), so it wouldn't split it right / need a workaround for that.
I would personally prefer Toml over "ini" since it's well-defined with a clear standard unlike ini which is different depending on what implementation you use.